From gitlab at gitlab.haskell.org Thu Dec 1 00:24:20 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 30 Nov 2022 19:24:20 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Properly cast values when writing/reading unboxed sums. Message-ID: <6387f434f265f_17512e526ac3433d9@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - 7bc073f0 by Simon Peyton Jones at 2022-11-30T19:24:10-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 4117ea91 by M Farkas-Dyck at 2022-11-30T19:24:11-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - 1da2e70e by Bryan Richter at 2022-11-30T19:24:11-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - 8fb98d3f by Bryan Richter at 2022-11-30T19:24:11-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - 22 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + compiler/GHC/Core/TyCo/FVs.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Stg/Lift/Analysis.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f77a6f25bc0319074a833f12ff639b6eb598666c...8fb98d3f5eacbf49517d9cbd4b1c6bb5722334b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f77a6f25bc0319074a833f12ff639b6eb598666c...8fb98d3f5eacbf49517d9cbd4b1c6bb5722334b7 You're receiving 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 Dec 1 04:44:35 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 30 Nov 2022 23:44:35 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Make Functor a quantified superclass of Bifunctor. Message-ID: <63883133a9ddd_17512effe7220364097@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 08310fb9 by Simon Peyton Jones at 2022-11-30T23:44:26-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 6acc6bdf by M Farkas-Dyck at 2022-11-30T23:44:26-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - 997badc2 by Bryan Richter at 2022-11-30T23:44:26-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - afbbef0c by Bryan Richter at 2022-11-30T23:44:27-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - 30 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + compiler/GHC/Core/TyCo/FVs.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/Data/Graph/Inductive/PatriciaTree.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - libraries/base/Data/Bifunctor.hs - libraries/base/GHC/Base.hs - libraries/base/changelog.md - testsuite/tests/deriving/should_compile/T9968a.hs - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-via-compile.hs - testsuite/tests/driver/all.T - testsuite/tests/ghci/T13786/all.T - testsuite/tests/ghci/linking/all.T - testsuite/tests/ghci/linking/dyn/all.T - testsuite/tests/ghci/prog001/prog001.T - testsuite/tests/ghci/prog002/prog002.T - testsuite/tests/ghci/prog010/all.T - testsuite/tests/ghci/scripts/T12550.stdout - testsuite/tests/ghci/scripts/all.T - testsuite/tests/package/T20010/all.T - testsuite/tests/plugins/all.T - testsuite/tests/rts/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fb98d3f5eacbf49517d9cbd4b1c6bb5722334b7...afbbef0cef13c9a6e233884a10761d1f9702c884 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fb98d3f5eacbf49517d9cbd4b1c6bb5722334b7...afbbef0cef13c9a6e233884a10761d1f9702c884 You're receiving 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 Dec 1 08:34:04 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 01 Dec 2022 03:34:04 -0500 Subject: [Git][ghc/ghc][wip/T22491] 8 commits: Add Javascript backend Message-ID: <638866fcdaa3e_17512effe7220400669@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22491 at Glasgow Haskell Compiler / GHC Commits: cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - a490b299 by Simon Peyton Jones at 2022-12-01T08:35:47+00:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Rep.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backend/Internal.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config/StgToCmm.hs - + compiler/GHC/Driver/Config/StgToJS.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Phases.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Pipeline/Phases.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - + compiler/GHC/HsToCore/Foreign/JavaScript.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ba0f37df7b9b8f1f83ac2a31f2e13c7caeb86f1...a490b299d9d43303dc49c2df04dfc72a3915fd2c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3ba0f37df7b9b8f1f83ac2a31f2e13c7caeb86f1...a490b299d9d43303dc49c2df04dfc72a3915fd2c You're receiving 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 Dec 1 09:05:28 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Dec 2022 04:05:28 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: FastString: SAT bucket_match Message-ID: <63886e58c0462_17512e16a1811c4243fb@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2974d708 by doyougnu at 2022-12-01T04:05:01-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 5596f997 by M Farkas-Dyck at 2022-12-01T04:05:01-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - 0a2f0188 by Bryan Richter at 2022-12-01T04:05:01-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - b7f10c9c by Bryan Richter at 2022-12-01T04:05:01-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - 15 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Data/FastString.hs - testsuite/tests/driver/all.T - testsuite/tests/ghci/T13786/all.T - testsuite/tests/ghci/linking/all.T - testsuite/tests/ghci/linking/dyn/all.T - testsuite/tests/ghci/prog001/prog001.T - testsuite/tests/ghci/prog002/prog002.T - testsuite/tests/ghci/prog010/all.T - testsuite/tests/ghci/scripts/all.T - testsuite/tests/package/T20010/all.T - testsuite/tests/plugins/all.T - testsuite/tests/rts/all.T - testsuite/tests/rts/linker/all.T Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -101,7 +101,7 @@ data Opsys data LinuxDistro = Debian11 | Debian10 | Debian9 | Fedora33 | Ubuntu2004 | Centos7 | Alpine deriving (Eq) -data Arch = Amd64 | AArch64 | ARMv7 | I386 +data Arch = Amd64 | AArch64 | I386 data BignumBackend = Native | Gmp deriving Eq @@ -230,7 +230,6 @@ runnerTag arch (Linux distro) = case arch of Amd64 -> "x86_64-linux" AArch64 -> "aarch64-linux" - ARMv7 -> "armv7-linux" I386 -> "x86_64-linux" runnerTag AArch64 Darwin = "aarch64-darwin" runnerTag Amd64 Darwin = "x86_64-darwin-m1" @@ -260,7 +259,6 @@ opsysName Windows = "windows" archName :: Arch -> String archName Amd64 = "x86_64" archName AArch64 = "aarch64" -archName ARMv7 = "armv7" archName I386 = "i386" binDistName :: Arch -> Opsys -> BuildConfig -> String @@ -347,18 +345,6 @@ opsysVariables _ FreeBSD13 = mconcat , "GHC_VERSION" =: "9.2.2" , "CABAL_INSTALL_VERSION" =: "3.6.2.0" ] -opsysVariables ARMv7 (Linux distro) = - distroVariables distro <> - mconcat [ "CONFIGURE_ARGS" =: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" - -- N.B. We disable ld.lld explicitly here because it appears to fail - -- non-deterministically on ARMv7. See #18280. - , "LD" =: "ld.gold" - , "GccUseLdOpt" =: "-fuse-ld=gold" - -- Awkwardly, this appears to be necessary to work around a - -- live-lock exhibited by the CPython (at least in 3.9 and 3.8) - -- interpreter on ARMv7 - , "HADRIAN_ARGS" =: "--test-verbose=3" - ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = mconcat [ "NIX_SYSTEM" =: "aarch64-darwin" @@ -525,7 +511,6 @@ data Rule = FastCI -- ^ Run this job when the fast-ci label is set | Nightly -- ^ Only run this job in the nightly pipeline | LLVMBackend -- ^ Only run this job when the "LLVM backend" label is present | FreeBSDLabel -- ^ Only run this job when the "FreeBSD" label is set. - | ARMLabel -- ^ Only run this job when the "ARM" label is set. | Disable -- ^ Don't run this job. deriving (Bounded, Enum, Ord, Eq) @@ -546,8 +531,6 @@ ruleString On LLVMBackend = "$CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/" ruleString Off LLVMBackend = true ruleString On FreeBSDLabel = "$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/" ruleString Off FreeBSDLabel = true -ruleString On ARMLabel = "$CI_MERGE_REQUEST_LABELS =~ /.*ARM.*/" -ruleString Off ARMLabel = true ruleString On ReleaseOnly = "$RELEASE_JOB == \"yes\"" ruleString Off ReleaseOnly = "$RELEASE_JOB != \"yes\"" ruleString On Nightly = "$NIGHTLY" @@ -824,9 +807,8 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , allowFailureGroup (addValidateRule ARMLabel (standardBuilds ARMv7 (Linux Debian10))) , standardBuilds I386 (Linux Debian9) - , allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) static) + , standardBuildsWithConfig Amd64 (Linux Alpine) static , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure") ===================================== .gitlab/jobs.yaml ===================================== @@ -35,7 +35,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -97,7 +97,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -120,67 +120,6 @@ "TEST_ENV": "aarch64-linux-deb10-validate" } }, - "armv7-linux-deb10-validate": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "2 weeks", - "paths": [ - "ghc-armv7-linux-deb10-validate.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*ARM.*/) && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-validate" - } - }, "i386-linux-deb9-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -216,7 +155,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -274,7 +213,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -337,7 +276,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -361,68 +300,6 @@ "XZ_OPT": "-9" } }, - "nightly-armv7-linux-deb10-validate": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "8 weeks", - "paths": [ - "ghc-armv7-linux-deb10-validate.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-validate", - "XZ_OPT": "-9" - } - }, "nightly-i386-linux-deb9-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -458,7 +335,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -517,7 +394,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -582,7 +459,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -643,7 +520,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -676,7 +553,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "8 weeks", "paths": [ @@ -705,7 +582,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -767,7 +644,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -827,7 +704,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -886,7 +763,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -945,7 +822,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1005,7 +882,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1064,7 +941,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1123,7 +1000,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1182,7 +1059,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1241,7 +1118,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1302,7 +1179,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1363,7 +1240,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1424,7 +1301,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1483,7 +1360,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1542,7 +1419,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1603,7 +1480,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1665,7 +1542,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1726,7 +1603,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1781,7 +1658,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1840,7 +1717,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1903,7 +1780,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1967,7 +1844,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1992,69 +1869,6 @@ "XZ_OPT": "-9" } }, - "release-armv7-linux-deb10-release": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "1 year", - "paths": [ - "ghc-armv7-linux-deb10-release.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-release", - "BUILD_FLAVOUR": "release", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "IGNORE_PERF_FAILURES": "all", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-release", - "XZ_OPT": "-9" - } - }, "release-i386-linux-deb9-release": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -2090,7 +1904,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2150,7 +1964,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2216,7 +2030,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2278,7 +2092,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2312,7 +2126,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "1 year", "paths": [ @@ -2341,7 +2155,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2404,7 +2218,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2465,7 +2279,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2525,7 +2339,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2585,7 +2399,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2645,7 +2459,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2705,7 +2519,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2767,7 +2581,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2829,7 +2643,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2892,7 +2706,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2948,7 +2762,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3008,7 +2822,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3072,7 +2886,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3136,7 +2950,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/) && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/) && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3196,7 +3010,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3228,7 +3042,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "2 weeks", "paths": [ @@ -3257,7 +3071,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3318,7 +3132,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3377,7 +3191,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3436,7 +3250,7 @@ "rules": [ { "allow_failure": true, - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "manual" } ], @@ -3494,7 +3308,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3553,7 +3367,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3611,7 +3425,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3669,7 +3483,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3727,7 +3541,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && ($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && ($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/) && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3786,7 +3600,7 @@ "rules": [ { "allow_failure": true, - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "manual" } ], @@ -3846,7 +3660,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3906,7 +3720,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3966,7 +3780,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4024,7 +3838,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4082,7 +3896,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -4142,7 +3956,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4203,7 +4017,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4263,7 +4077,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4317,7 +4131,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4375,7 +4189,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -465,8 +465,7 @@ mkFastStringWith mk_fs sbs = do FastStringTableSegment lock _ buckets# <- readIORef segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket sbs - case res of + case bucket_match bucket sbs of Just found -> return found Nothing -> do -- The withMVar below is not dupable. It can lead to deadlock if it is @@ -485,8 +484,7 @@ mkFastStringWith mk_fs sbs = do FastStringTableSegment _ counter buckets# <- maybeResizeSegment segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket sbs - case res of + case bucket_match bucket sbs of -- The FastString was added by another thread after previous read and -- before we acquired the write lock. Just found -> return found @@ -497,11 +495,12 @@ mkFastStringWith mk_fs sbs = do _ <- atomicFetchAddFastMut counter 1 return fs -bucket_match :: [FastString] -> ShortByteString -> IO (Maybe FastString) -bucket_match [] _ = return Nothing -bucket_match (fs@(FastString {fs_sbs=fs_sbs}) : ls) sbs - | fs_sbs == sbs = return (Just fs) - | otherwise = bucket_match ls sbs +bucket_match :: [FastString] -> ShortByteString -> Maybe FastString +bucket_match fs sbs = go fs + where go [] = Nothing + go (fs@(FastString {fs_sbs=fs_sbs}) : ls) + | fs_sbs == sbs = Just fs + | otherwise = go ls mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== testsuite/tests/driver/all.T ===================================== @@ -126,7 +126,7 @@ test('static001', [extra_files(['Static001.hs']), makefile_test, ['static001']) test('dynHelloWorld', - only_ways(['dyn']), + [only_ways(['dyn']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], compile_and_run, ['']) ===================================== testsuite/tests/ghci/T13786/all.T ===================================== @@ -1,4 +1,4 @@ test('T13786', - [when(unregisterised(), fragile(17018)), js_broken(22359)], + [when(unregisterised(), fragile(17018)), js_broken(22359), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/ghci/linking/all.T ===================================== @@ -32,7 +32,8 @@ test('ghcilink005', when(unregisterised(), fragile(16085)), unless(doing_ghci, skip), req_dynamic_lib_support, - req_interp], + req_interp, + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['ghcilink005']) test('ghcilink006', ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -3,6 +3,7 @@ setTestOpts(req_dynamic_lib_support) test('load_short_name', [ extra_files(['A.c']) , unless(doing_ghci, skip) , req_c + , when(opsys('linux') and not ghc_dynamic(), expect_broken(20706)) ], makefile_test, ['load_short_name']) @@ -11,7 +12,8 @@ test('T1407', unless(doing_ghci, skip), pre_cmd('$MAKE -s --no-print-directory compile_libT1407'), extra_hc_opts('-L"$PWD/T1407dir"'), - js_broken(22359)], + js_broken(22359), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('T3242', ===================================== testsuite/tests/ghci/prog001/prog001.T ===================================== @@ -3,5 +3,6 @@ test('prog001', when(arch('arm'), fragile(17555)), cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), req_interp, - unless(opsys('mingw32') or not config.have_RTS_linker, extra_ways(['ghci-ext']))], + unless(opsys('mingw32') or not config.have_RTS_linker, extra_ways(['ghci-ext'])), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['prog001.script']) ===================================== testsuite/tests/ghci/prog002/prog002.T ===================================== @@ -1,3 +1,4 @@ test('prog002', [extra_files(['../shell.hs', 'A1.hs', 'A2.hs', 'B.hs', 'C.hs', 'D.hs']), - cmd_prefix('ghciWayFlags=' + config.ghci_way_flags)], + cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['prog002.script']) ===================================== testsuite/tests/ghci/prog010/all.T ===================================== @@ -1,4 +1,5 @@ test('ghci.prog010', [cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), - extra_files(['../shell.hs', 'A.hs', 'B.hs'])], + extra_files(['../shell.hs', 'A.hs', 'B.hs']), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['ghci.prog010.script']) ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -159,7 +159,8 @@ test('T6106', [extra_files(['../shell.hs']), test('T6105', normal, ghci_script, ['T6105.script']) test('T7117', normal, ghci_script, ['T7117.script']) test('ghci058', [extra_files(['../shell.hs']), - cmd_prefix('ghciWayFlags=' + config.ghci_way_flags)], + cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['ghci058.script']) test('T7587', normal, ghci_script, ['T7587.script']) test('T7688', normal, ghci_script, ['T7688.script']) ===================================== testsuite/tests/package/T20010/all.T ===================================== @@ -1,4 +1,4 @@ # Test that GHC links to the C++ standard library as expected # when the system-cxx-std-lib package is used. test('T20010', req_c, makefile_test, []) -test('T20010-ghci', [req_c, extra_files(['T20010_c.cpp', 'T20010.hs'])], makefile_test, []) +test('T20010-ghci', [req_c, extra_files(['T20010_c.cpp', 'T20010.hs']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/plugins/all.T ===================================== @@ -115,7 +115,7 @@ test('T10294a', pre_cmd('$MAKE -s --no-print-directory -C annotation-plugin package.T10294a TOP={top}')], makefile_test, []) -test('frontend01', [extra_files(['FrontendPlugin.hs'])], +test('frontend01', [extra_files(['FrontendPlugin.hs']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('T11244', @@ -294,25 +294,30 @@ test('T20803b', test('test-echo-in-turn', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-line', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-turn-many-args', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-line-many-args', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('plugins-external', [extra_files(['shared-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C shared-plugin package.plugins01 TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C shared-plugin package.plugins01 TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/rts/all.T ===================================== @@ -272,7 +272,8 @@ test('T7040_ghci', only_ways(['ghci']), # Fragile when unregisterised; see #16085 when(unregisterised(), skip), - pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup')], + pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], compile_and_run, ['T7040_ghci_c.o']) test('T7227', [extra_run_opts('+RTS -tT7227.stat --machine-readable -RTS')], @@ -497,7 +498,8 @@ test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) test('T13676', [when(opsys('mingw32'), expect_broken(17447)), - extra_files(['T13676.hs'])], + extra_files(['T13676.hs']), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['T13676.script']) test('InitEventLogging', [ only_ways(['normal']) ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -59,7 +59,8 @@ def checkDynAsm(actual_file, normaliser): test('T5435_v_asm_a', [extra_files(['T5435.hs', 'T5435_asm.c']), req_rts_linker, - when(arch('arm'), expect_broken(17559))], + when(arch('arm'), expect_broken(17559)), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_asm_a']) # this one just needs to run on linux, as darwin/mingw32 are covered # by the _a test already. @@ -67,12 +68,14 @@ test('T5435_v_asm_b', [extra_files(['T5435.hs', 'T5435_asm.c']), req_rts_linker, when(arch('arm'), expect_broken(17559)), - when(opsys('darwin') or opsys('mingw32'), skip)], + when(opsys('darwin') or opsys('mingw32'), skip), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_asm_b']) test('T5435_v_gcc', [extra_files(['T5435.hs', 'T5435_gcc.c']), req_rts_linker, - when(arch('arm'), expect_broken(17559))], + when(arch('arm'), expect_broken(17559)), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_gcc']) test('T5435_dyn_asm', [extra_files(['T5435.hs', 'T5435_asm.c']), @@ -126,7 +129,7 @@ test('T7072', req_rts_linker], makefile_test, ['T7072']) -test('T20494', [req_rts_linker], +test('T20494', [req_rts_linker, when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T20494']) test('T20918', View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/afbbef0cef13c9a6e233884a10761d1f9702c884...b7f10c9c7d8e6baa3196486a6e1a1fb47a9d5ff9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/afbbef0cef13c9a6e233884a10761d1f9702c884...b7f10c9c7d8e6baa3196486a6e1a1fb47a9d5ff9 You're receiving 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 Dec 1 10:08:09 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 01 Dec 2022 05:08:09 -0500 Subject: [Git][ghc/ghc][wip/T22324] Make (^) INLINE (#22324) Message-ID: <63887d09bb710_17512e52be8435150@gitlab.mail> Sebastian Graf pushed to branch wip/T22324 at Glasgow Haskell Compiler / GHC Commits: ca4604f0 by Sebastian Graf at 2022-12-01T11:08:02+01:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 2 changed files: - libraries/base/GHC/Real.hs - testsuite/tests/simplCore/should_compile/T12603.stdout Changes: ===================================== libraries/base/GHC/Real.hs ===================================== @@ -671,27 +671,37 @@ odd = not . even ------------------------------------------------------- -- | raise a number to a non-negative integral power -{-# SPECIALISE [1] (^) :: - Integer -> Integer -> Integer, - Integer -> Int -> Integer, - Int -> Int -> Int #-} -{-# INLINABLE [1] (^) #-} -- See Note [Inlining (^)] +{-# INLINE [1] (^) #-} -- See Note [Inlining (^)] (^) :: (Num a, Integral b) => a -> b -> a x0 ^ y0 | y0 < 0 = errorWithoutStackTrace "Negative exponent" | y0 == 0 = 1 - | otherwise = f x0 y0 - where -- f : x0 ^ y0 = x ^ y - f x y | even y = f (x * x) (y `quot` 2) - | y == 1 = x - | otherwise = g (x * x) (y `quot` 2) x -- See Note [Half of y - 1] - -- g : x0 ^ y0 = (x ^ y) * z - g x y z | even y = g (x * x) (y `quot` 2) z - | y == 1 = x * z - | otherwise = g (x * x) (y `quot` 2) (x * z) -- See Note [Half of y - 1] + | otherwise = powImpl x0 y0 + +{-# SPECIALISE powImpl :: + Integer -> Integer -> Integer, + Integer -> Int -> Integer, + Int -> Int -> Int #-} +{-# INLINABLE powImpl #-} -- See Note [Inlining (^)] +powImpl :: (Num a, Integral b) => a -> b -> a +-- powImpl : x0 ^ y0 = (x ^ y) +powImpl x y | even y = powImpl (x * x) (y `quot` 2) + | y == 1 = x + | otherwise = powImplAcc (x * x) (y `quot` 2) x -- See Note [Half of y - 1] + +{-# SPECIALISE powImplAcc :: + Integer -> Integer -> Integer -> Integer, + Integer -> Int -> Integer -> Integer, + Int -> Int -> Int -> Int #-} +{-# INLINABLE powImplAcc #-} -- See Note [Inlining (^)] +powImplAcc :: (Num a, Integral b) => a -> b -> a -> a +-- powImplAcc : x0 ^ y0 = (x ^ y) * z +powImplAcc x y z | even y = powImplAcc (x * x) (y `quot` 2) z + | y == 1 = x * z + | otherwise = powImplAcc (x * x) (y `quot` 2) (x * z) -- See Note [Half of y - 1] -- | raise a number to an integral power (^^) :: (Fractional a, Integral b) => a -> b -> a -{-# INLINABLE [1] (^^) #-} -- See Note [Inlining (^) +{-# INLINE [1] (^^) #-} -- See Note [Inlining (^) x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) {- Note [Half of y - 1] @@ -699,15 +709,17 @@ x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) Since y is guaranteed to be odd and positive here, half of y - 1 can be computed as y `quot` 2, optimising subtraction away. -Note [Inlining (^) -~~~~~~~~~~~~~~~~~~ -The INLINABLE [1] pragma allows (^) to be specialised at its call sites. -If it is called repeatedly at the same type, that can make a huge -difference, because of those constants which can be repeatedly -calculated. - -We don't inline until phase 1, to give a chance for the RULES -"^2/Int" etc to fire first. +Note [Inlining (^)] +~~~~~~~~~~~~~~~~~~~ +We mark (^) as INLINE[1] so that it inlines aggressively (after the RULEs in +Note [Powers with small exponent] had a chance to fire before phase 1) and we +expose the strict loop `powImpl`, so that we don't need to allocate a box for +the base `x0`. Then we mark `powImpl` as INLINABLE so that auto-specialisation +in client modules to, e.g., `Complex Double` can happen. + +Specialisation can make a huge difference for repeated calls, because of +constants which would otherwise be calculated repeatedly and unboxing of +arguments. Currently the fromInteger calls are not floated because we get \d1 d2 x y -> blah ===================================== testsuite/tests/simplCore/should_compile/T12603.stdout ===================================== @@ -1 +1 @@ -lvl = case GHC.Real.$wf1 2# 8# of v { __DEFAULT -> GHC.Types.I# v } + = case GHC.Real.$w$spowImpl1 2# 8# of v { __DEFAULT -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca4604f0a5ed3780b389312c48cbfd54bcdb16ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca4604f0a5ed3780b389312c48cbfd54bcdb16ba You're receiving 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 Dec 1 10:13:31 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 01 Dec 2022 05:13:31 -0500 Subject: [Git][ghc/ghc][wip/T22324] Make (^) INLINE (#22324) Message-ID: <63887e4b40ffe_17512e52bac4354a1@gitlab.mail> Sebastian Graf pushed to branch wip/T22324 at Glasgow Haskell Compiler / GHC Commits: e64882ed by Sebastian Graf at 2022-12-01T11:13:25+01:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 2 changed files: - libraries/base/GHC/Real.hs - testsuite/tests/simplCore/should_compile/T12603.stdout Changes: ===================================== libraries/base/GHC/Real.hs ===================================== @@ -671,27 +671,37 @@ odd = not . even ------------------------------------------------------- -- | raise a number to a non-negative integral power -{-# SPECIALISE [1] (^) :: - Integer -> Integer -> Integer, - Integer -> Int -> Integer, - Int -> Int -> Int #-} -{-# INLINABLE [1] (^) #-} -- See Note [Inlining (^)] +{-# INLINE [1] (^) #-} -- See Note [Inlining (^)] (^) :: (Num a, Integral b) => a -> b -> a x0 ^ y0 | y0 < 0 = errorWithoutStackTrace "Negative exponent" | y0 == 0 = 1 - | otherwise = f x0 y0 - where -- f : x0 ^ y0 = x ^ y - f x y | even y = f (x * x) (y `quot` 2) - | y == 1 = x - | otherwise = g (x * x) (y `quot` 2) x -- See Note [Half of y - 1] - -- g : x0 ^ y0 = (x ^ y) * z - g x y z | even y = g (x * x) (y `quot` 2) z - | y == 1 = x * z - | otherwise = g (x * x) (y `quot` 2) (x * z) -- See Note [Half of y - 1] + | otherwise = powImpl x0 y0 + +{-# SPECIALISE powImpl :: + Integer -> Integer -> Integer, + Integer -> Int -> Integer, + Int -> Int -> Int #-} +{-# INLINABLE powImpl #-} -- See Note [Inlining (^)] +powImpl :: (Num a, Integral b) => a -> b -> a +-- powImpl : x0 ^ y0 = (x ^ y) +powImpl x y | even y = powImpl (x * x) (y `quot` 2) + | y == 1 = x + | otherwise = powImplAcc (x * x) (y `quot` 2) x -- See Note [Half of y - 1] + +{-# SPECIALISE powImplAcc :: + Integer -> Integer -> Integer -> Integer, + Integer -> Int -> Integer -> Integer, + Int -> Int -> Int -> Int #-} +{-# INLINABLE powImplAcc #-} -- See Note [Inlining (^)] +powImplAcc :: (Num a, Integral b) => a -> b -> a -> a +-- powImplAcc : x0 ^ y0 = (x ^ y) * z +powImplAcc x y z | even y = powImplAcc (x * x) (y `quot` 2) z + | y == 1 = x * z + | otherwise = powImplAcc (x * x) (y `quot` 2) (x * z) -- See Note [Half of y - 1] -- | raise a number to an integral power (^^) :: (Fractional a, Integral b) => a -> b -> a -{-# INLINABLE [1] (^^) #-} -- See Note [Inlining (^) +{-# INLINE [1] (^^) #-} -- See Note [Inlining (^) x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) {- Note [Half of y - 1] @@ -699,20 +709,30 @@ x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) Since y is guaranteed to be odd and positive here, half of y - 1 can be computed as y `quot` 2, optimising subtraction away. -Note [Inlining (^) -~~~~~~~~~~~~~~~~~~ -The INLINABLE [1] pragma allows (^) to be specialised at its call sites. -If it is called repeatedly at the same type, that can make a huge -difference, because of those constants which can be repeatedly -calculated. +Note [Inlining (^)] +~~~~~~~~~~~~~~~~~~~ +We mark (^) as INLINE[1] so that it inlines aggressively (after the RULEs in +Note [Powers with small exponent] had a chance to fire before phase 1) and we +expose the strict loop `powImpl`, so that we don't need to allocate a box for +the base `x0`. Then we mark `powImpl` as INLINABLE so that auto-specialisation +in client modules to, e.g., `Complex Double` can happen and we see its deep +strictness. -We don't inline until phase 1, to give a chance for the RULES -"^2/Int" etc to fire first. +Specialisation can make a huge difference for repeated calls, because of +constants which would otherwise be calculated repeatedly and unboxing of +arguments. Currently the fromInteger calls are not floated because we get \d1 d2 x y -> blah after the gentle round of simplification. +Why not make (^) strict in `x0` with a bang and make it INLINABLE? Well, because +it is futile: Being strict in the `Complex Double` pair won't be enough to unbox +the `Double`s anyway. Even after deep specisalisation, we will only unbox the +`Double`s when we inline (^), because (^) remains lazy in the `Double` fields. +Given that (^) must always inline to yield good code, we can just as well mark +it as such. + Note [Powers with small exponent] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For small exponents, (^) is inefficient compared to manually ===================================== testsuite/tests/simplCore/should_compile/T12603.stdout ===================================== @@ -1 +1 @@ -lvl = case GHC.Real.$wf1 2# 8# of v { __DEFAULT -> GHC.Types.I# v } + = case GHC.Real.$w$spowImpl1 2# 8# of v { __DEFAULT -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e64882ed371becec194d441730f3e6cab340e938 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e64882ed371becec194d441730f3e6cab340e938 You're receiving 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 Dec 1 11:02:16 2022 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Thu, 01 Dec 2022 06:02:16 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/js-fileStat Message-ID: <638889b864a46_17512e64b9d704392c9@gitlab.mail> Josh Meredith pushed new branch wip/js-fileStat at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/js-fileStat You're receiving 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 Dec 1 11:45:40 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Dec 2022 06:45:40 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: FastString: SAT bucket_match Message-ID: <638893e4b2b8c_17512e16a1811c457343@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 53f4a02d by doyougnu at 2022-12-01T06:45:19-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - d80d13e0 by M Farkas-Dyck at 2022-12-01T06:45:20-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - 8fcd1035 by Bryan Richter at 2022-12-01T06:45:20-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - c70da26a by Bryan Richter at 2022-12-01T06:45:20-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - 15 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Data/FastString.hs - testsuite/tests/driver/all.T - testsuite/tests/ghci/T13786/all.T - testsuite/tests/ghci/linking/all.T - testsuite/tests/ghci/linking/dyn/all.T - testsuite/tests/ghci/prog001/prog001.T - testsuite/tests/ghci/prog002/prog002.T - testsuite/tests/ghci/prog010/all.T - testsuite/tests/ghci/scripts/all.T - testsuite/tests/package/T20010/all.T - testsuite/tests/plugins/all.T - testsuite/tests/rts/all.T - testsuite/tests/rts/linker/all.T Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -101,7 +101,7 @@ data Opsys data LinuxDistro = Debian11 | Debian10 | Debian9 | Fedora33 | Ubuntu2004 | Centos7 | Alpine deriving (Eq) -data Arch = Amd64 | AArch64 | ARMv7 | I386 +data Arch = Amd64 | AArch64 | I386 data BignumBackend = Native | Gmp deriving Eq @@ -230,7 +230,6 @@ runnerTag arch (Linux distro) = case arch of Amd64 -> "x86_64-linux" AArch64 -> "aarch64-linux" - ARMv7 -> "armv7-linux" I386 -> "x86_64-linux" runnerTag AArch64 Darwin = "aarch64-darwin" runnerTag Amd64 Darwin = "x86_64-darwin-m1" @@ -260,7 +259,6 @@ opsysName Windows = "windows" archName :: Arch -> String archName Amd64 = "x86_64" archName AArch64 = "aarch64" -archName ARMv7 = "armv7" archName I386 = "i386" binDistName :: Arch -> Opsys -> BuildConfig -> String @@ -347,18 +345,6 @@ opsysVariables _ FreeBSD13 = mconcat , "GHC_VERSION" =: "9.2.2" , "CABAL_INSTALL_VERSION" =: "3.6.2.0" ] -opsysVariables ARMv7 (Linux distro) = - distroVariables distro <> - mconcat [ "CONFIGURE_ARGS" =: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" - -- N.B. We disable ld.lld explicitly here because it appears to fail - -- non-deterministically on ARMv7. See #18280. - , "LD" =: "ld.gold" - , "GccUseLdOpt" =: "-fuse-ld=gold" - -- Awkwardly, this appears to be necessary to work around a - -- live-lock exhibited by the CPython (at least in 3.9 and 3.8) - -- interpreter on ARMv7 - , "HADRIAN_ARGS" =: "--test-verbose=3" - ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = mconcat [ "NIX_SYSTEM" =: "aarch64-darwin" @@ -525,7 +511,6 @@ data Rule = FastCI -- ^ Run this job when the fast-ci label is set | Nightly -- ^ Only run this job in the nightly pipeline | LLVMBackend -- ^ Only run this job when the "LLVM backend" label is present | FreeBSDLabel -- ^ Only run this job when the "FreeBSD" label is set. - | ARMLabel -- ^ Only run this job when the "ARM" label is set. | Disable -- ^ Don't run this job. deriving (Bounded, Enum, Ord, Eq) @@ -546,8 +531,6 @@ ruleString On LLVMBackend = "$CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/" ruleString Off LLVMBackend = true ruleString On FreeBSDLabel = "$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/" ruleString Off FreeBSDLabel = true -ruleString On ARMLabel = "$CI_MERGE_REQUEST_LABELS =~ /.*ARM.*/" -ruleString Off ARMLabel = true ruleString On ReleaseOnly = "$RELEASE_JOB == \"yes\"" ruleString Off ReleaseOnly = "$RELEASE_JOB != \"yes\"" ruleString On Nightly = "$NIGHTLY" @@ -824,9 +807,8 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , allowFailureGroup (addValidateRule ARMLabel (standardBuilds ARMv7 (Linux Debian10))) , standardBuilds I386 (Linux Debian9) - , allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) static) + , standardBuildsWithConfig Amd64 (Linux Alpine) static , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure") ===================================== .gitlab/jobs.yaml ===================================== @@ -35,7 +35,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -97,7 +97,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -120,67 +120,6 @@ "TEST_ENV": "aarch64-linux-deb10-validate" } }, - "armv7-linux-deb10-validate": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "2 weeks", - "paths": [ - "ghc-armv7-linux-deb10-validate.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*ARM.*/) && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-validate" - } - }, "i386-linux-deb9-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -216,7 +155,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -274,7 +213,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -337,7 +276,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -361,68 +300,6 @@ "XZ_OPT": "-9" } }, - "nightly-armv7-linux-deb10-validate": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "8 weeks", - "paths": [ - "ghc-armv7-linux-deb10-validate.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-validate", - "XZ_OPT": "-9" - } - }, "nightly-i386-linux-deb9-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -458,7 +335,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -517,7 +394,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -582,7 +459,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -643,7 +520,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -676,7 +553,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "8 weeks", "paths": [ @@ -705,7 +582,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -767,7 +644,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -827,7 +704,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -886,7 +763,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -945,7 +822,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1005,7 +882,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1064,7 +941,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1123,7 +1000,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1182,7 +1059,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1241,7 +1118,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1302,7 +1179,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1363,7 +1240,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1424,7 +1301,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1483,7 +1360,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1542,7 +1419,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1603,7 +1480,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1665,7 +1542,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1726,7 +1603,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1781,7 +1658,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1840,7 +1717,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1903,7 +1780,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1967,7 +1844,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1992,69 +1869,6 @@ "XZ_OPT": "-9" } }, - "release-armv7-linux-deb10-release": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "1 year", - "paths": [ - "ghc-armv7-linux-deb10-release.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-release", - "BUILD_FLAVOUR": "release", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "IGNORE_PERF_FAILURES": "all", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-release", - "XZ_OPT": "-9" - } - }, "release-i386-linux-deb9-release": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -2090,7 +1904,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2150,7 +1964,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2216,7 +2030,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2278,7 +2092,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2312,7 +2126,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "1 year", "paths": [ @@ -2341,7 +2155,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2404,7 +2218,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2465,7 +2279,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2525,7 +2339,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2585,7 +2399,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2645,7 +2459,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2705,7 +2519,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2767,7 +2581,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2829,7 +2643,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2892,7 +2706,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2948,7 +2762,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3008,7 +2822,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3072,7 +2886,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3136,7 +2950,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/) && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/) && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3196,7 +3010,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3228,7 +3042,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "2 weeks", "paths": [ @@ -3257,7 +3071,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3318,7 +3132,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3377,7 +3191,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3436,7 +3250,7 @@ "rules": [ { "allow_failure": true, - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "manual" } ], @@ -3494,7 +3308,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3553,7 +3367,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3611,7 +3425,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3669,7 +3483,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3727,7 +3541,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && ($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && ($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/) && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3786,7 +3600,7 @@ "rules": [ { "allow_failure": true, - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "manual" } ], @@ -3846,7 +3660,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3906,7 +3720,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3966,7 +3780,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4024,7 +3838,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4082,7 +3896,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -4142,7 +3956,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4203,7 +4017,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4263,7 +4077,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4317,7 +4131,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4375,7 +4189,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -465,8 +465,7 @@ mkFastStringWith mk_fs sbs = do FastStringTableSegment lock _ buckets# <- readIORef segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket sbs - case res of + case bucket_match bucket sbs of Just found -> return found Nothing -> do -- The withMVar below is not dupable. It can lead to deadlock if it is @@ -485,8 +484,7 @@ mkFastStringWith mk_fs sbs = do FastStringTableSegment _ counter buckets# <- maybeResizeSegment segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket sbs - case res of + case bucket_match bucket sbs of -- The FastString was added by another thread after previous read and -- before we acquired the write lock. Just found -> return found @@ -497,11 +495,12 @@ mkFastStringWith mk_fs sbs = do _ <- atomicFetchAddFastMut counter 1 return fs -bucket_match :: [FastString] -> ShortByteString -> IO (Maybe FastString) -bucket_match [] _ = return Nothing -bucket_match (fs@(FastString {fs_sbs=fs_sbs}) : ls) sbs - | fs_sbs == sbs = return (Just fs) - | otherwise = bucket_match ls sbs +bucket_match :: [FastString] -> ShortByteString -> Maybe FastString +bucket_match fs sbs = go fs + where go [] = Nothing + go (fs@(FastString {fs_sbs=fs_sbs}) : ls) + | fs_sbs == sbs = Just fs + | otherwise = go ls mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== testsuite/tests/driver/all.T ===================================== @@ -126,7 +126,7 @@ test('static001', [extra_files(['Static001.hs']), makefile_test, ['static001']) test('dynHelloWorld', - only_ways(['dyn']), + [only_ways(['dyn']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], compile_and_run, ['']) ===================================== testsuite/tests/ghci/T13786/all.T ===================================== @@ -1,4 +1,4 @@ test('T13786', - [when(unregisterised(), fragile(17018)), js_broken(22359)], + [when(unregisterised(), fragile(17018)), js_broken(22359), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/ghci/linking/all.T ===================================== @@ -32,7 +32,8 @@ test('ghcilink005', when(unregisterised(), fragile(16085)), unless(doing_ghci, skip), req_dynamic_lib_support, - req_interp], + req_interp, + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['ghcilink005']) test('ghcilink006', ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -3,6 +3,7 @@ setTestOpts(req_dynamic_lib_support) test('load_short_name', [ extra_files(['A.c']) , unless(doing_ghci, skip) , req_c + , when(opsys('linux') and not ghc_dynamic(), expect_broken(20706)) ], makefile_test, ['load_short_name']) @@ -11,7 +12,8 @@ test('T1407', unless(doing_ghci, skip), pre_cmd('$MAKE -s --no-print-directory compile_libT1407'), extra_hc_opts('-L"$PWD/T1407dir"'), - js_broken(22359)], + js_broken(22359), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('T3242', ===================================== testsuite/tests/ghci/prog001/prog001.T ===================================== @@ -3,5 +3,6 @@ test('prog001', when(arch('arm'), fragile(17555)), cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), req_interp, - unless(opsys('mingw32') or not config.have_RTS_linker, extra_ways(['ghci-ext']))], + unless(opsys('mingw32') or not config.have_RTS_linker, extra_ways(['ghci-ext'])), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['prog001.script']) ===================================== testsuite/tests/ghci/prog002/prog002.T ===================================== @@ -1,3 +1,4 @@ test('prog002', [extra_files(['../shell.hs', 'A1.hs', 'A2.hs', 'B.hs', 'C.hs', 'D.hs']), - cmd_prefix('ghciWayFlags=' + config.ghci_way_flags)], + cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['prog002.script']) ===================================== testsuite/tests/ghci/prog010/all.T ===================================== @@ -1,4 +1,5 @@ test('ghci.prog010', [cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), - extra_files(['../shell.hs', 'A.hs', 'B.hs'])], + extra_files(['../shell.hs', 'A.hs', 'B.hs']), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['ghci.prog010.script']) ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -159,7 +159,8 @@ test('T6106', [extra_files(['../shell.hs']), test('T6105', normal, ghci_script, ['T6105.script']) test('T7117', normal, ghci_script, ['T7117.script']) test('ghci058', [extra_files(['../shell.hs']), - cmd_prefix('ghciWayFlags=' + config.ghci_way_flags)], + cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['ghci058.script']) test('T7587', normal, ghci_script, ['T7587.script']) test('T7688', normal, ghci_script, ['T7688.script']) ===================================== testsuite/tests/package/T20010/all.T ===================================== @@ -1,4 +1,4 @@ # Test that GHC links to the C++ standard library as expected # when the system-cxx-std-lib package is used. test('T20010', req_c, makefile_test, []) -test('T20010-ghci', [req_c, extra_files(['T20010_c.cpp', 'T20010.hs'])], makefile_test, []) +test('T20010-ghci', [req_c, extra_files(['T20010_c.cpp', 'T20010.hs']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/plugins/all.T ===================================== @@ -115,7 +115,7 @@ test('T10294a', pre_cmd('$MAKE -s --no-print-directory -C annotation-plugin package.T10294a TOP={top}')], makefile_test, []) -test('frontend01', [extra_files(['FrontendPlugin.hs'])], +test('frontend01', [extra_files(['FrontendPlugin.hs']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('T11244', @@ -294,25 +294,30 @@ test('T20803b', test('test-echo-in-turn', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-line', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-turn-many-args', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-line-many-args', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('plugins-external', [extra_files(['shared-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C shared-plugin package.plugins01 TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C shared-plugin package.plugins01 TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/rts/all.T ===================================== @@ -272,7 +272,8 @@ test('T7040_ghci', only_ways(['ghci']), # Fragile when unregisterised; see #16085 when(unregisterised(), skip), - pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup')], + pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], compile_and_run, ['T7040_ghci_c.o']) test('T7227', [extra_run_opts('+RTS -tT7227.stat --machine-readable -RTS')], @@ -497,7 +498,8 @@ test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) test('T13676', [when(opsys('mingw32'), expect_broken(17447)), - extra_files(['T13676.hs'])], + extra_files(['T13676.hs']), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['T13676.script']) test('InitEventLogging', [ only_ways(['normal']) ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -59,7 +59,8 @@ def checkDynAsm(actual_file, normaliser): test('T5435_v_asm_a', [extra_files(['T5435.hs', 'T5435_asm.c']), req_rts_linker, - when(arch('arm'), expect_broken(17559))], + when(arch('arm'), expect_broken(17559)), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_asm_a']) # this one just needs to run on linux, as darwin/mingw32 are covered # by the _a test already. @@ -67,12 +68,14 @@ test('T5435_v_asm_b', [extra_files(['T5435.hs', 'T5435_asm.c']), req_rts_linker, when(arch('arm'), expect_broken(17559)), - when(opsys('darwin') or opsys('mingw32'), skip)], + when(opsys('darwin') or opsys('mingw32'), skip), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_asm_b']) test('T5435_v_gcc', [extra_files(['T5435.hs', 'T5435_gcc.c']), req_rts_linker, - when(arch('arm'), expect_broken(17559))], + when(arch('arm'), expect_broken(17559)), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_gcc']) test('T5435_dyn_asm', [extra_files(['T5435.hs', 'T5435_asm.c']), @@ -126,7 +129,7 @@ test('T7072', req_rts_linker], makefile_test, ['T7072']) -test('T20494', [req_rts_linker], +test('T20494', [req_rts_linker, when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T20494']) test('T20918', View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7f10c9c7d8e6baa3196486a6e1a1fb47a9d5ff9...c70da26add8b557ae9d21db7c3a84ac87d5802ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b7f10c9c7d8e6baa3196486a6e1a1fb47a9d5ff9...c70da26add8b557ae9d21db7c3a84ac87d5802ab You're receiving 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 Dec 1 15:16:29 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Dec 2022 10:16:29 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: FastString: SAT bucket_match Message-ID: <6388c54d348b1_17512e526d451851a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9616da33 by doyougnu at 2022-12-01T10:15:39-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 27362acb by Simon Peyton Jones at 2022-12-01T10:15:40-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - edc68f53 by M Farkas-Dyck at 2022-12-01T10:15:40-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - fe588546 by Bryan Richter at 2022-12-01T10:15:40-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - 237dbc37 by Bryan Richter at 2022-12-01T10:15:40-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - 19 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Data/FastString.hs - testsuite/tests/driver/all.T - testsuite/tests/ghci/T13786/all.T - testsuite/tests/ghci/linking/all.T - testsuite/tests/ghci/linking/dyn/all.T - testsuite/tests/ghci/prog001/prog001.T - testsuite/tests/ghci/prog002/prog002.T - testsuite/tests/ghci/prog010/all.T - testsuite/tests/ghci/scripts/all.T - testsuite/tests/package/T20010/all.T - testsuite/tests/plugins/all.T - testsuite/tests/rts/all.T - testsuite/tests/rts/linker/all.T - + testsuite/tests/simplCore/should_compile/T22491.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -101,7 +101,7 @@ data Opsys data LinuxDistro = Debian11 | Debian10 | Debian9 | Fedora33 | Ubuntu2004 | Centos7 | Alpine deriving (Eq) -data Arch = Amd64 | AArch64 | ARMv7 | I386 +data Arch = Amd64 | AArch64 | I386 data BignumBackend = Native | Gmp deriving Eq @@ -230,7 +230,6 @@ runnerTag arch (Linux distro) = case arch of Amd64 -> "x86_64-linux" AArch64 -> "aarch64-linux" - ARMv7 -> "armv7-linux" I386 -> "x86_64-linux" runnerTag AArch64 Darwin = "aarch64-darwin" runnerTag Amd64 Darwin = "x86_64-darwin-m1" @@ -260,7 +259,6 @@ opsysName Windows = "windows" archName :: Arch -> String archName Amd64 = "x86_64" archName AArch64 = "aarch64" -archName ARMv7 = "armv7" archName I386 = "i386" binDistName :: Arch -> Opsys -> BuildConfig -> String @@ -347,18 +345,6 @@ opsysVariables _ FreeBSD13 = mconcat , "GHC_VERSION" =: "9.2.2" , "CABAL_INSTALL_VERSION" =: "3.6.2.0" ] -opsysVariables ARMv7 (Linux distro) = - distroVariables distro <> - mconcat [ "CONFIGURE_ARGS" =: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" - -- N.B. We disable ld.lld explicitly here because it appears to fail - -- non-deterministically on ARMv7. See #18280. - , "LD" =: "ld.gold" - , "GccUseLdOpt" =: "-fuse-ld=gold" - -- Awkwardly, this appears to be necessary to work around a - -- live-lock exhibited by the CPython (at least in 3.9 and 3.8) - -- interpreter on ARMv7 - , "HADRIAN_ARGS" =: "--test-verbose=3" - ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = mconcat [ "NIX_SYSTEM" =: "aarch64-darwin" @@ -525,7 +511,6 @@ data Rule = FastCI -- ^ Run this job when the fast-ci label is set | Nightly -- ^ Only run this job in the nightly pipeline | LLVMBackend -- ^ Only run this job when the "LLVM backend" label is present | FreeBSDLabel -- ^ Only run this job when the "FreeBSD" label is set. - | ARMLabel -- ^ Only run this job when the "ARM" label is set. | Disable -- ^ Don't run this job. deriving (Bounded, Enum, Ord, Eq) @@ -546,8 +531,6 @@ ruleString On LLVMBackend = "$CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/" ruleString Off LLVMBackend = true ruleString On FreeBSDLabel = "$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/" ruleString Off FreeBSDLabel = true -ruleString On ARMLabel = "$CI_MERGE_REQUEST_LABELS =~ /.*ARM.*/" -ruleString Off ARMLabel = true ruleString On ReleaseOnly = "$RELEASE_JOB == \"yes\"" ruleString Off ReleaseOnly = "$RELEASE_JOB != \"yes\"" ruleString On Nightly = "$NIGHTLY" @@ -824,9 +807,8 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , allowFailureGroup (addValidateRule ARMLabel (standardBuilds ARMv7 (Linux Debian10))) , standardBuilds I386 (Linux Debian9) - , allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) static) + , standardBuildsWithConfig Amd64 (Linux Alpine) static , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure") ===================================== .gitlab/jobs.yaml ===================================== @@ -35,7 +35,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -97,7 +97,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -120,67 +120,6 @@ "TEST_ENV": "aarch64-linux-deb10-validate" } }, - "armv7-linux-deb10-validate": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "2 weeks", - "paths": [ - "ghc-armv7-linux-deb10-validate.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*ARM.*/) && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-validate" - } - }, "i386-linux-deb9-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -216,7 +155,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -274,7 +213,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -337,7 +276,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -361,68 +300,6 @@ "XZ_OPT": "-9" } }, - "nightly-armv7-linux-deb10-validate": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "8 weeks", - "paths": [ - "ghc-armv7-linux-deb10-validate.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-validate", - "XZ_OPT": "-9" - } - }, "nightly-i386-linux-deb9-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -458,7 +335,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -517,7 +394,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -582,7 +459,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -643,7 +520,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -676,7 +553,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "8 weeks", "paths": [ @@ -705,7 +582,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -767,7 +644,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -827,7 +704,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -886,7 +763,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -945,7 +822,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1005,7 +882,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1064,7 +941,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1123,7 +1000,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1182,7 +1059,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1241,7 +1118,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1302,7 +1179,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1363,7 +1240,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1424,7 +1301,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1483,7 +1360,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1542,7 +1419,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1603,7 +1480,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1665,7 +1542,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1726,7 +1603,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1781,7 +1658,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1840,7 +1717,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1903,7 +1780,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1967,7 +1844,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1992,69 +1869,6 @@ "XZ_OPT": "-9" } }, - "release-armv7-linux-deb10-release": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "1 year", - "paths": [ - "ghc-armv7-linux-deb10-release.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-release", - "BUILD_FLAVOUR": "release", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "IGNORE_PERF_FAILURES": "all", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-release", - "XZ_OPT": "-9" - } - }, "release-i386-linux-deb9-release": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -2090,7 +1904,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2150,7 +1964,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2216,7 +2030,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2278,7 +2092,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2312,7 +2126,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "1 year", "paths": [ @@ -2341,7 +2155,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2404,7 +2218,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2465,7 +2279,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2525,7 +2339,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2585,7 +2399,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2645,7 +2459,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2705,7 +2519,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2767,7 +2581,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2829,7 +2643,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2892,7 +2706,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2948,7 +2762,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3008,7 +2822,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3072,7 +2886,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3136,7 +2950,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/) && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/) && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3196,7 +3010,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3228,7 +3042,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "2 weeks", "paths": [ @@ -3257,7 +3071,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3318,7 +3132,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3377,7 +3191,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3436,7 +3250,7 @@ "rules": [ { "allow_failure": true, - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "manual" } ], @@ -3494,7 +3308,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3553,7 +3367,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3611,7 +3425,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3669,7 +3483,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3727,7 +3541,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && ($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && ($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/) && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3786,7 +3600,7 @@ "rules": [ { "allow_failure": true, - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "manual" } ], @@ -3846,7 +3660,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3906,7 +3720,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3966,7 +3780,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4024,7 +3838,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4082,7 +3896,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -4142,7 +3956,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4203,7 +4017,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4263,7 +4077,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4317,7 +4131,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4375,7 +4189,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -3103,9 +3103,13 @@ etaBodyForJoinPoint need_args body | Just (tv, res_ty) <- splitForAllTyCoVar_maybe ty , let (subst', tv') = substVarBndr subst tv = go (n-1) res_ty subst' (tv' : rev_bs) (e `App` varToCoreExpr tv') + -- The varToCoreExpr is important: `tv` might be a coercion variable + | Just (_, mult, arg_ty, res_ty) <- splitFunTy_maybe ty , let (subst', b) = freshEtaId n subst (Scaled mult arg_ty) - = go (n-1) res_ty subst' (b : rev_bs) (e `App` Var b) + = go (n-1) res_ty subst' (b : rev_bs) (e `App` varToCoreExpr b) + -- The varToCoreExpr is important: `b` might be a coercion variable + | otherwise = pprPanic "etaBodyForJoinPoint" $ int need_args $$ ppr body $$ ppr (exprType body) ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1227,11 +1227,23 @@ simplExprF1 env (Let (NonRec bndr rhs) body) cont do { ty' <- simplType env ty ; simplExprF (extendTvSubst env bndr ty') body cont } + | Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs env + -- Because of the let-can-float invariant, it's ok to + -- inline freely, or to drop the binding if it is dead. + = do { tick (PreInlineUnconditionally bndr) + ; simplExprF env' body cont } + + -- Now check for a join point. It's better to do the preInlineUnconditionally + -- test first, because joinPointBinding_maybe has to eta-expand, so a trivial + -- binding like { j = j2 |> co } would first be eta-expanded and then inlined + -- Better to test preInlineUnconditionally first. | Just (bndr', rhs') <- joinPointBinding_maybe bndr rhs - = {-#SCC "simplNonRecJoinPoint" #-} simplNonRecJoinPoint env bndr' rhs' body cont + = {-#SCC "simplNonRecJoinPoint" #-} + simplNonRecJoinPoint env bndr' rhs' body cont | otherwise - = {-#SCC "simplNonRecE" #-} simplNonRecE env bndr (rhs, env) body cont + = {-#SCC "simplNonRecE" #-} + simplNonRecE env False bndr (rhs, env) body cont {- Note [Avoiding space leaks in OutType] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1680,12 +1692,12 @@ simpl_lam env bndr body (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_cont = cont, sc_dup = dup }) | isSimplified dup -- Don't re-simplify if we've simplified it once -- See Note [Avoiding exponential behaviour] - = do { tick (BetaReduction bndr) - ; completeBindX env bndr arg body cont } + = do { tick (BetaReduction bndr) + ; completeBindX env bndr arg body cont } | otherwise -- See Note [Avoiding exponential behaviour] - = do { tick (BetaReduction bndr) - ; simplNonRecE env bndr (arg, arg_se) body cont } + = do { tick (BetaReduction bndr) + ; simplNonRecE env True bndr (arg, arg_se) body cont } -- Discard a non-counting tick on a lambda. This may change the -- cost attribution slightly (moving the allocation of the @@ -1717,6 +1729,8 @@ simplLamBndrs env bndrs = mapAccumLM simplLamBndr env bndrs ------------------ simplNonRecE :: SimplEnv + -> Bool -- True <=> from a lambda + -- False <=> from a let -> InId -- The binder, always an Id -- Never a join point -> (InExpr, SimplEnv) -- Rhs of binding (or arg of lambda) @@ -1735,34 +1749,46 @@ simplNonRecE :: SimplEnv -- It deals with strict bindings, via the StrictBind continuation, -- which may abort the whole process. -- --- The RHS may not satisfy the let-can-float invariant yet +-- from_lam=False => the RHS satisfies the let-can-float invariant +-- Otherwise it may or may not satisfy it. -simplNonRecE env bndr (rhs, rhs_se) body cont +simplNonRecE env from_lam bndr (rhs, rhs_se) body cont = assert (isId bndr && not (isJoinId bndr) ) $ do { (env1, bndr1) <- simplNonRecBndr env bndr ; let needs_case_binding = needsCaseBinding (idType bndr1) rhs -- See Note [Dark corner with representation polymorphism] - ; if | not needs_case_binding - , Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs rhs_se -> - do { tick (PreInlineUnconditionally bndr) - ; -- pprTrace "preInlineUncond" (ppr bndr <+> ppr rhs) $ - simplLam env' body cont } - + -- If from_lam=False then needs_case_binding is False, + -- because the binding started as a let, which must + -- satisfy let-can-float + + ; if | from_lam && not needs_case_binding + -- If not from_lam we are coming from a (NonRec bndr rhs) binding + -- and preInlineUnconditionally has been done already; + -- no need to repeat it. But for lambdas we must be careful about + -- preInlineUndonditionally: consider (\(x:Int#). 3) (error "urk") + -- We must not drop the (error "urk"). + , Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs rhs_se + -> do { tick (PreInlineUnconditionally bndr) + ; -- pprTrace "preInlineUncond" (ppr bndr <+> ppr rhs) $ + simplLam env' body cont } -- Deal with strict bindings - -- See Note [Dark corner with representation polymorphism] - | isStrictId bndr1 && seCaseCase env - || needs_case_binding -> - simplExprF (rhs_se `setInScopeFromE` env) rhs - (StrictBind { sc_bndr = bndr, sc_body = body - , sc_env = env, sc_cont = cont, sc_dup = NoDup }) + | isStrictId bndr1 && seCaseCase env + || from_lam && needs_case_binding + -- The important bit here is needs_case_binds; but no need to + -- test it if from_lam is False because then needs_case_binding is False too + -- NB: either way, the RHS may or may not satisfy let-can-float + -- but that's ok for StrictBind. + -> simplExprF (rhs_se `setInScopeFromE` env) rhs + (StrictBind { sc_bndr = bndr, sc_body = body + , sc_env = env, sc_cont = cont, sc_dup = NoDup }) -- Deal with lazy bindings - | otherwise -> - do { (env2, bndr2) <- addBndrRules env1 bndr bndr1 (BC_Let NotTopLevel NonRecursive) - ; (floats1, env3) <- simplLazyBind env2 NotTopLevel NonRecursive bndr bndr2 rhs rhs_se - ; (floats2, expr') <- simplLam env3 body cont - ; return (floats1 `addFloats` floats2, expr') } } + | otherwise + -> do { (env2, bndr2) <- addBndrRules env1 bndr bndr1 (BC_Let NotTopLevel NonRecursive) + ; (floats1, env3) <- simplLazyBind env2 NotTopLevel NonRecursive bndr bndr2 rhs rhs_se + ; (floats2, expr') <- simplLam env3 body cont + ; return (floats1 `addFloats` floats2, expr') } } ------------------ simplRecE :: SimplEnv @@ -1806,7 +1832,7 @@ care here. Note [Avoiding exponential behaviour] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ One way in which we can get exponential behaviour is if we simplify a -big expression, and the re-simplify it -- and then this happens in a +big expression, and then re-simplify it -- and then this happens in a deeply-nested way. So we must be jolly careful about re-simplifying an expression. That is why simplNonRecX does not try preInlineUnconditionally (unlike simplNonRecE). @@ -1864,13 +1890,8 @@ simplNonRecJoinPoint :: SimplEnv -> InId -> InExpr -> InExpr -> SimplCont -> SimplM (SimplFloats, OutExpr) simplNonRecJoinPoint env bndr rhs body cont - | assert (isJoinId bndr ) True - , Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs env - = do { tick (PreInlineUnconditionally bndr) - ; simplExprF env' body cont } - - | otherwise - = wrapJoinCont env cont $ \ env cont -> + = assert (isJoinId bndr ) $ + wrapJoinCont env cont $ \ env cont -> do { -- We push join_cont into the join RHS and the body; -- and wrap wrap_cont around the whole thing ; let mult = contHoleScaling cont ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -465,8 +465,7 @@ mkFastStringWith mk_fs sbs = do FastStringTableSegment lock _ buckets# <- readIORef segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket sbs - case res of + case bucket_match bucket sbs of Just found -> return found Nothing -> do -- The withMVar below is not dupable. It can lead to deadlock if it is @@ -485,8 +484,7 @@ mkFastStringWith mk_fs sbs = do FastStringTableSegment _ counter buckets# <- maybeResizeSegment segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket sbs - case res of + case bucket_match bucket sbs of -- The FastString was added by another thread after previous read and -- before we acquired the write lock. Just found -> return found @@ -497,11 +495,12 @@ mkFastStringWith mk_fs sbs = do _ <- atomicFetchAddFastMut counter 1 return fs -bucket_match :: [FastString] -> ShortByteString -> IO (Maybe FastString) -bucket_match [] _ = return Nothing -bucket_match (fs@(FastString {fs_sbs=fs_sbs}) : ls) sbs - | fs_sbs == sbs = return (Just fs) - | otherwise = bucket_match ls sbs +bucket_match :: [FastString] -> ShortByteString -> Maybe FastString +bucket_match fs sbs = go fs + where go [] = Nothing + go (fs@(FastString {fs_sbs=fs_sbs}) : ls) + | fs_sbs == sbs = Just fs + | otherwise = go ls mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = ===================================== testsuite/tests/driver/all.T ===================================== @@ -126,7 +126,7 @@ test('static001', [extra_files(['Static001.hs']), makefile_test, ['static001']) test('dynHelloWorld', - only_ways(['dyn']), + [only_ways(['dyn']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], compile_and_run, ['']) ===================================== testsuite/tests/ghci/T13786/all.T ===================================== @@ -1,4 +1,4 @@ test('T13786', - [when(unregisterised(), fragile(17018)), js_broken(22359)], + [when(unregisterised(), fragile(17018)), js_broken(22359), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/ghci/linking/all.T ===================================== @@ -32,7 +32,8 @@ test('ghcilink005', when(unregisterised(), fragile(16085)), unless(doing_ghci, skip), req_dynamic_lib_support, - req_interp], + req_interp, + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['ghcilink005']) test('ghcilink006', ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -3,6 +3,7 @@ setTestOpts(req_dynamic_lib_support) test('load_short_name', [ extra_files(['A.c']) , unless(doing_ghci, skip) , req_c + , when(opsys('linux') and not ghc_dynamic(), expect_broken(20706)) ], makefile_test, ['load_short_name']) @@ -11,7 +12,8 @@ test('T1407', unless(doing_ghci, skip), pre_cmd('$MAKE -s --no-print-directory compile_libT1407'), extra_hc_opts('-L"$PWD/T1407dir"'), - js_broken(22359)], + js_broken(22359), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('T3242', ===================================== testsuite/tests/ghci/prog001/prog001.T ===================================== @@ -3,5 +3,6 @@ test('prog001', when(arch('arm'), fragile(17555)), cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), req_interp, - unless(opsys('mingw32') or not config.have_RTS_linker, extra_ways(['ghci-ext']))], + unless(opsys('mingw32') or not config.have_RTS_linker, extra_ways(['ghci-ext'])), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['prog001.script']) ===================================== testsuite/tests/ghci/prog002/prog002.T ===================================== @@ -1,3 +1,4 @@ test('prog002', [extra_files(['../shell.hs', 'A1.hs', 'A2.hs', 'B.hs', 'C.hs', 'D.hs']), - cmd_prefix('ghciWayFlags=' + config.ghci_way_flags)], + cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['prog002.script']) ===================================== testsuite/tests/ghci/prog010/all.T ===================================== @@ -1,4 +1,5 @@ test('ghci.prog010', [cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), - extra_files(['../shell.hs', 'A.hs', 'B.hs'])], + extra_files(['../shell.hs', 'A.hs', 'B.hs']), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['ghci.prog010.script']) ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -159,7 +159,8 @@ test('T6106', [extra_files(['../shell.hs']), test('T6105', normal, ghci_script, ['T6105.script']) test('T7117', normal, ghci_script, ['T7117.script']) test('ghci058', [extra_files(['../shell.hs']), - cmd_prefix('ghciWayFlags=' + config.ghci_way_flags)], + cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['ghci058.script']) test('T7587', normal, ghci_script, ['T7587.script']) test('T7688', normal, ghci_script, ['T7688.script']) ===================================== testsuite/tests/package/T20010/all.T ===================================== @@ -1,4 +1,4 @@ # Test that GHC links to the C++ standard library as expected # when the system-cxx-std-lib package is used. test('T20010', req_c, makefile_test, []) -test('T20010-ghci', [req_c, extra_files(['T20010_c.cpp', 'T20010.hs'])], makefile_test, []) +test('T20010-ghci', [req_c, extra_files(['T20010_c.cpp', 'T20010.hs']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/plugins/all.T ===================================== @@ -115,7 +115,7 @@ test('T10294a', pre_cmd('$MAKE -s --no-print-directory -C annotation-plugin package.T10294a TOP={top}')], makefile_test, []) -test('frontend01', [extra_files(['FrontendPlugin.hs'])], +test('frontend01', [extra_files(['FrontendPlugin.hs']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('T11244', @@ -294,25 +294,30 @@ test('T20803b', test('test-echo-in-turn', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-line', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-turn-many-args', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-line-many-args', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('plugins-external', [extra_files(['shared-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C shared-plugin package.plugins01 TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C shared-plugin package.plugins01 TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/rts/all.T ===================================== @@ -272,7 +272,8 @@ test('T7040_ghci', only_ways(['ghci']), # Fragile when unregisterised; see #16085 when(unregisterised(), skip), - pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup')], + pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], compile_and_run, ['T7040_ghci_c.o']) test('T7227', [extra_run_opts('+RTS -tT7227.stat --machine-readable -RTS')], @@ -497,7 +498,8 @@ test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) test('T13676', [when(opsys('mingw32'), expect_broken(17447)), - extra_files(['T13676.hs'])], + extra_files(['T13676.hs']), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['T13676.script']) test('InitEventLogging', [ only_ways(['normal']) ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -59,7 +59,8 @@ def checkDynAsm(actual_file, normaliser): test('T5435_v_asm_a', [extra_files(['T5435.hs', 'T5435_asm.c']), req_rts_linker, - when(arch('arm'), expect_broken(17559))], + when(arch('arm'), expect_broken(17559)), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_asm_a']) # this one just needs to run on linux, as darwin/mingw32 are covered # by the _a test already. @@ -67,12 +68,14 @@ test('T5435_v_asm_b', [extra_files(['T5435.hs', 'T5435_asm.c']), req_rts_linker, when(arch('arm'), expect_broken(17559)), - when(opsys('darwin') or opsys('mingw32'), skip)], + when(opsys('darwin') or opsys('mingw32'), skip), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_asm_b']) test('T5435_v_gcc', [extra_files(['T5435.hs', 'T5435_gcc.c']), req_rts_linker, - when(arch('arm'), expect_broken(17559))], + when(arch('arm'), expect_broken(17559)), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_gcc']) test('T5435_dyn_asm', [extra_files(['T5435.hs', 'T5435_asm.c']), @@ -126,7 +129,7 @@ test('T7072', req_rts_linker], makefile_test, ['T7072']) -test('T20494', [req_rts_linker], +test('T20494', [req_rts_linker, when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T20494']) test('T20918', ===================================== testsuite/tests/simplCore/should_compile/T22491.hs ===================================== @@ -0,0 +1,319 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +module T22491 (heapster_add_block_hints) where + +import qualified Control.Exception as X +import Control.Applicative +import Control.Monad +import Control.Monad.Catch (MonadThrow(..), MonadCatch(..), catches, Handler(..)) +import Control.Monad.IO.Class +import qualified Control.Monad.Fail as Fail +import Control.Monad.Trans.Class (MonadTrans(..)) +import Control.Monad.Trans.Reader (ReaderT) +import Data.Coerce (Coercible, coerce) +import Data.IORef +import Data.Kind (Type) +import Data.Monoid +import GHC.Exts (build) + +failOnNothing :: Fail.MonadFail m => String -> Maybe a -> m a +failOnNothing err_str Nothing = Fail.fail err_str +failOnNothing _ (Just a) = return a + +lookupLLVMSymbolModAndCFG :: HeapsterEnv -> String -> IO (Maybe (AnyCFG LLVM)) +lookupLLVMSymbolModAndCFG _ _ = pure Nothing + +heapster_add_block_hints :: HeapsterEnv -> String -> [Int] -> + (forall ext blocks ret. + CFG ext blocks ret -> + TopLevel Hint) -> + TopLevel () +heapster_add_block_hints henv nm blks hintF = + do env <- liftIO $ readIORef $ heapsterEnvPermEnvRef henv + AnyCFG cfg <- + failOnNothing ("Could not find symbol definition: " ++ nm) =<< + io (lookupLLVMSymbolModAndCFG henv nm) + let blocks = fmapFC blockInputs $ cfgBlockMap cfg + block_idxs = fmapFC (blockIDIndex . blockID) $ cfgBlockMap cfg + blkIDs <- case blks of + [] -> pure $ toListFC (Some . BlockID) block_idxs + _ -> forM blks $ \blk -> + failOnNothing ("Block ID " ++ show blk ++ + " not found in function " ++ nm) + (fmapF BlockID <$> intIndex blk (size blocks)) + env' <- foldM (\env' _ -> + permEnvAddHint env' <$> + hintF cfg) + env blkIDs + liftIO $ writeIORef (heapsterEnvPermEnvRef henv) env' + +----- + +data Some (f:: k -> Type) = forall x . Some (f x) + +class FunctorF m where + fmapF :: (forall x . f x -> g x) -> m f -> m g + +mapSome :: (forall tp . f tp -> g tp) -> Some f -> Some g +mapSome f (Some x) = Some $! f x + +instance FunctorF Some where fmapF = mapSome + +type SingleCtx x = EmptyCtx ::> x + +data Ctx k + = EmptyCtx + | Ctx k ::> k + +type family (<+>) (x :: Ctx k) (y :: Ctx k) :: Ctx k where + x <+> EmptyCtx = x + x <+> (y ::> e) = (x <+> y) ::> e + +data Height = Zero | Succ Height + +data BalancedTree h (f :: k -> Type) (p :: Ctx k) where + BalLeaf :: !(f x) -> BalancedTree 'Zero f (SingleCtx x) + BalPair :: !(BalancedTree h f x) + -> !(BalancedTree h f y) + -> BalancedTree ('Succ h) f (x <+> y) + +data BinomialTree (h::Height) (f :: k -> Type) :: Ctx k -> Type where + Empty :: BinomialTree h f EmptyCtx + + PlusOne :: !Int + -> !(BinomialTree ('Succ h) f x) + -> !(BalancedTree h f y) + -> BinomialTree h f (x <+> y) + + PlusZero :: !Int + -> !(BinomialTree ('Succ h) f x) + -> BinomialTree h f x + +tsize :: BinomialTree h f a -> Int +tsize Empty = 0 +tsize (PlusOne s _ _) = 2*s+1 +tsize (PlusZero s _) = 2*s + +fmap_bin :: (forall tp . f tp -> g tp) + -> BinomialTree h f c + -> BinomialTree h g c +fmap_bin _ Empty = Empty +fmap_bin f (PlusOne s t x) = PlusOne s (fmap_bin f t) (fmap_bal f x) +fmap_bin f (PlusZero s t) = PlusZero s (fmap_bin f t) +{-# INLINABLE fmap_bin #-} + +fmap_bal :: (forall tp . f tp -> g tp) + -> BalancedTree h f c + -> BalancedTree h g c +fmap_bal = go + where go :: (forall tp . f tp -> g tp) + -> BalancedTree h f c + -> BalancedTree h g c + go f (BalLeaf x) = BalLeaf (f x) + go f (BalPair x y) = BalPair (go f x) (go f y) +{-# INLINABLE fmap_bal #-} + +traverse_bin :: Applicative m + => (forall tp . f tp -> m (g tp)) + -> BinomialTree h f c + -> m (BinomialTree h g c) +traverse_bin _ Empty = pure Empty +traverse_bin f (PlusOne s t x) = PlusOne s <$> traverse_bin f t <*> traverse_bal f x +traverse_bin f (PlusZero s t) = PlusZero s <$> traverse_bin f t +{-# INLINABLE traverse_bin #-} + +traverse_bal :: Applicative m + => (forall tp . f tp -> m (g tp)) + -> BalancedTree h f c + -> m (BalancedTree h g c) +traverse_bal = go + where go :: Applicative m + => (forall tp . f tp -> m (g tp)) + -> BalancedTree h f c + -> m (BalancedTree h g c) + go f (BalLeaf x) = BalLeaf <$> f x + go f (BalPair x y) = BalPair <$> go f x <*> go f y +{-# INLINABLE traverse_bal #-} + +data Assignment (f :: k -> Type) (ctx :: Ctx k) + = Assignment (BinomialTree 'Zero f ctx) + +newtype Index (ctx :: Ctx k) (tp :: k) = Index { indexVal :: Int } + +newtype Size (ctx :: Ctx k) = Size Int + +intIndex :: Int -> Size ctx -> Maybe (Some (Index ctx)) +intIndex i n | 0 <= i && i < sizeInt n = Just (Some (Index i)) + | otherwise = Nothing + +size :: Assignment f ctx -> Size ctx +size (Assignment t) = Size (tsize t) + +sizeInt :: Size ctx -> Int +sizeInt (Size n) = n + +class FunctorFC (t :: (k -> Type) -> l -> Type) where + fmapFC :: forall f g. (forall x. f x -> g x) -> + (forall x. t f x -> t g x) + +(#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c) +(#.) _f = coerce + +class FoldableFC (t :: (k -> Type) -> l -> Type) where + foldMapFC :: forall f m. Monoid m => (forall x. f x -> m) -> (forall x. t f x -> m) + foldMapFC f = foldrFC (mappend . f) mempty + + foldrFC :: forall f b. (forall x. f x -> b -> b) -> (forall x. b -> t f x -> b) + foldrFC f z t = appEndo (foldMapFC (Endo #. f) t) z + + toListFC :: forall f a. (forall x. f x -> a) -> (forall x. t f x -> [a]) + toListFC f t = build (\c n -> foldrFC (\e v -> c (f e) v) n t) + +foldMapFCDefault :: (TraversableFC t, Monoid m) => (forall x. f x -> m) -> (forall x. t f x -> m) +foldMapFCDefault = \f -> getConst . traverseFC (Const . f) +{-# INLINE foldMapFCDefault #-} + +class (FunctorFC t, FoldableFC t) => TraversableFC (t :: (k -> Type) -> l -> Type) where + traverseFC :: forall f g m. Applicative m + => (forall x. f x -> m (g x)) + -> (forall x. t f x -> m (t g x)) + +instance FunctorFC Assignment where + fmapFC = \f (Assignment x) -> Assignment (fmap_bin f x) + {-# INLINE fmapFC #-} + +instance FoldableFC Assignment where + foldMapFC = foldMapFCDefault + {-# INLINE foldMapFC #-} + +instance TraversableFC Assignment where + traverseFC = \f (Assignment x) -> Assignment <$> traverse_bin f x + {-# INLINE traverseFC #-} + +data CrucibleType + +data TypeRepr (tp::CrucibleType) where + +type CtxRepr = Assignment TypeRepr + +data CFG (ext :: Type) + (blocks :: Ctx (Ctx CrucibleType)) + (ret :: CrucibleType) + = CFG { cfgBlockMap :: !(BlockMap ext blocks ret) + } + +type BlockMap ext blocks ret = Assignment (Block ext blocks ret) blocks + +data Block ext (blocks :: Ctx (Ctx CrucibleType)) (ret :: CrucibleType) ctx + = Block { blockID :: !(BlockID blocks ctx) + , blockInputs :: !(CtxRepr ctx) + } + +newtype BlockID (blocks :: Ctx (Ctx CrucibleType)) (tp :: Ctx CrucibleType) + = BlockID { blockIDIndex :: Index blocks tp } + +data LLVM + +data AnyCFG ext where + AnyCFG :: CFG ext blocks ret + -> AnyCFG ext + +newtype StateContT s r m a + = StateContT { runStateContT :: (a -> s -> m r) + -> s + -> m r + } + +fmapStateContT :: (a -> b) -> StateContT s r m a -> StateContT s r m b +fmapStateContT = \f m -> StateContT $ \c -> runStateContT m (\v s -> (c $! f v) s) +{-# INLINE fmapStateContT #-} + +applyStateContT :: StateContT s r m (a -> b) -> StateContT s r m a -> StateContT s r m b +applyStateContT = \mf mv -> + StateContT $ \c -> + runStateContT mf (\f -> runStateContT mv (\v s -> (c $! f v) s)) +{-# INLINE applyStateContT #-} + +returnStateContT :: a -> StateContT s r m a +returnStateContT = \v -> seq v $ StateContT $ \c -> c v +{-# INLINE returnStateContT #-} + +bindStateContT :: StateContT s r m a -> (a -> StateContT s r m b) -> StateContT s r m b +bindStateContT = \m n -> StateContT $ \c -> runStateContT m (\a -> runStateContT (n a) c) +{-# INLINE bindStateContT #-} + +instance Functor (StateContT s r m) where + fmap = fmapStateContT + +instance Applicative (StateContT s r m) where + pure = returnStateContT + (<*>) = applyStateContT + +instance Monad (StateContT s r m) where + (>>=) = bindStateContT + +instance MonadFail m => MonadFail (StateContT s r m) where + fail = \msg -> StateContT $ \_ _ -> fail msg + +instance MonadTrans (StateContT s r) where + lift = \m -> StateContT $ \c s -> m >>= \v -> seq v (c v s) + +instance MonadIO m => MonadIO (StateContT s r m) where + liftIO = lift . liftIO + +instance MonadThrow m => MonadThrow (StateContT s r m) where + throwM e = StateContT (\_k _s -> throwM e) + +instance MonadCatch m => MonadCatch (StateContT s r m) where + catch m hdl = + StateContT $ \k s -> + catch + (runStateContT m k s) + (\e -> runStateContT (hdl e) k s) + +data TopLevelRO +data TopLevelRW +data Value + +newtype TopLevel a = + TopLevel_ (ReaderT TopLevelRO (StateContT TopLevelRW (Value, TopLevelRW) IO) a) + deriving (Applicative, Functor, Monad, MonadFail, MonadThrow, MonadCatch) + +instance MonadIO TopLevel where + liftIO = io + +io :: IO a -> TopLevel a +io f = TopLevel_ (liftIO f) `catches` [Handler handleIO] + where + rethrow :: X.Exception ex => ex -> TopLevel a + rethrow ex = throwM (X.SomeException ex) + + handleIO :: X.IOException -> TopLevel a + handleIO = rethrow + +data HeapsterEnv = HeapsterEnv { + heapsterEnvPermEnvRef :: IORef PermEnv + } + +data Hint where + +data PermEnv = PermEnv { + permEnvHints :: [Hint] + } + +permEnvAddHint :: PermEnv -> Hint -> PermEnv +permEnvAddHint env hint = env { permEnvHints = hint : permEnvHints env } + +type family CtxToRList (ctx :: Ctx k) :: RList k where + CtxToRList EmptyCtx = RNil + CtxToRList (ctx' ::> x) = CtxToRList ctx' :> x + +data RList a + = RNil + | (RList a) :> a ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -455,3 +455,4 @@ test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m -ddebug-output']) test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('T22491', normal, compile, ['-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c70da26add8b557ae9d21db7c3a84ac87d5802ab...237dbc37cebdf1552e7cec1c025b31e17241cad6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c70da26add8b557ae9d21db7c3a84ac87d5802ab...237dbc37cebdf1552e7cec1c025b31e17241cad6 You're receiving 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 Dec 1 17:01:22 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 01 Dec 2022 12:01:22 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/t25510 Message-ID: <6388dde285988_17512e1e46a9d8553758@gitlab.mail> Matthew Pickering pushed new branch wip/t25510 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t25510 You're receiving 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 Dec 1 17:36:07 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Dec 2022 12:36:07 -0500 Subject: [Git][ghc/ghc][master] Make Functor a quantified superclass of Bifunctor. Message-ID: <6388e607412ea_17512e526ac564111@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 8 changed files: - compiler/GHC/Data/Graph/Inductive/PatriciaTree.hs - libraries/base/Data/Bifunctor.hs - libraries/base/GHC/Base.hs - libraries/base/changelog.md - testsuite/tests/deriving/should_compile/T9968a.hs - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-via-compile.hs - testsuite/tests/ghci/scripts/T12550.stdout Changes: ===================================== compiler/GHC/Data/Graph/Inductive/PatriciaTree.hs ===================================== @@ -116,6 +116,9 @@ instance DynGraph Gr where in Gr g3 +instance Functor (Gr a) where + fmap = fastEMap + instance Bifunctor Gr where bimap = fastNEMap ===================================== libraries/base/Data/Bifunctor.hs ===================================== @@ -1,5 +1,6 @@ -{-# LANGUAGE Safe #-} {-# LANGUAGE CPP #-} +{-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE Safe #-} ----------------------------------------------------------------------------- -- | @@ -39,7 +40,11 @@ import GHC.Generics ( K1(..) ) -- arguments are covariant. -- -- You can define a 'Bifunctor' by either defining 'bimap' or by --- defining both 'first' and 'second'. +-- defining both 'first' and 'second'. A partially applied 'Bifunctor' +-- must be a 'Functor' and the 'second' method must agree with 'fmap'. +-- From this it follows that: +-- +-- @'second' 'id' = 'id'@ -- -- If you supply 'bimap', you should ensure that: -- @@ -64,8 +69,10 @@ import GHC.Generics ( K1(..) ) -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g -- @ -- +-- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor. +-- -- @since 4.8.0.0 -class Bifunctor p where +class (forall a. Functor (p a)) => Bifunctor p where {-# MINIMAL bimap | first, second #-} -- | Map over both arguments at the same time. ===================================== libraries/base/GHC/Base.hs ===================================== @@ -559,6 +559,18 @@ instance (Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) where instance (Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c) where (u, v, w, a) >>= k = case k a of (u', v', w', b) -> (u <> u', v <> v', w <> w', b) +-- | @since 4.18.0.0 +instance Functor ((,,,,) a b c d) where + fmap f (a, b, c, d, e) = (a, b, c, d, f e) + +-- | @since 4.18.0.0 +instance Functor ((,,,,,) a b c d e) where + fmap fun (a, b, c, d, e, f) = (a, b, c, d, e, fun f) + +-- | @since 4.18.0.0 +instance Functor ((,,,,,,) a b c d e f) where + fmap fun (a, b, c, d, e, f, g) = (a, b, c, d, e, f, fun g) + -- | @since 4.10.0.0 instance Semigroup a => Semigroup (IO a) where (<>) = liftA2 (<>) ===================================== libraries/base/changelog.md ===================================== @@ -1,7 +1,9 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) ## 4.18.0.0 *TBA* - + * Add `forall a. Functor (p a)` superclass for `Bifunctor p`. + * Add Functor instances for `(,,,,) a b c d`, `(,,,,,) a b c d e` and + `(,,,,,) a b c d e f`. * Exceptions thrown by weak pointer finalizers are now reported via a global exception handler. * Add `GHC.Weak.Finalize.{get,set}FinalizerExceptionHandler` which the user to ===================================== testsuite/tests/deriving/should_compile/T9968a.hs ===================================== @@ -5,4 +5,4 @@ module T9968 where import Data.Bifunctor data Blah a b = A a | B b - deriving (Bifunctor) + deriving (Functor, Bifunctor) ===================================== testsuite/tests/deriving/should_compile/T9968a.stderr ===================================== @@ -1,5 +1,5 @@ -T9968a.hs:8:13: warning: [GHC-06201] [-Wmissing-methods (in -Wdefault)] +T9968a.hs:8:22: warning: [GHC-06201] [-Wmissing-methods (in -Wdefault)] • No explicit implementation for either ‘bimap’ or (‘first’ and ‘second’) • In the instance declaration for ‘Bifunctor Blah’ ===================================== testsuite/tests/deriving/should_compile/deriving-via-compile.hs ===================================== @@ -308,7 +308,7 @@ instance Biapplicative (,) where (f a b, f' a' b') newtype WrapBiapp p a b = WrapBiap (p a b) - deriving newtype (Bifunctor, Biapplicative, Eq) + deriving newtype (Functor, Bifunctor, Biapplicative, Eq) instance (Biapplicative p, Num a, Num b) => Num (WrapBiapp p a b) where (+) = biliftA2 (+) (+) ===================================== testsuite/tests/ghci/scripts/T12550.stdout ===================================== @@ -26,6 +26,12 @@ class Functor f where instance ∀ a. Functor ((,) a) -- Defined in ‘GHC.Base’ instance ∀ a b. Functor ((,,) a b) -- Defined in ‘GHC.Base’ instance ∀ a b c. Functor ((,,,) a b c) -- Defined in ‘GHC.Base’ +instance ∀ a b c d. Functor ((,,,,) a b c d) + -- Defined in ‘GHC.Base’ +instance ∀ a b c d e. Functor ((,,,,,) a b c d e) + -- Defined in ‘GHC.Base’ +instance ∀ a b c d e f. Functor ((,,,,,,) a b c d e f) + -- Defined in ‘GHC.Base’ instance ∀ r. Functor ((->) r) -- Defined in ‘GHC.Base’ instance Functor IO -- Defined in ‘GHC.Base’ instance Functor [] -- Defined in ‘GHC.Base’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d87f28d810b9c536ca4db7f363163e6d0dd6c93c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d87f28d810b9c536ca4db7f363163e6d0dd6c93c You're receiving 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 Dec 1 17:37:18 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Dec 2022 12:37:18 -0500 Subject: [Git][ghc/ghc][master] FastString: SAT bucket_match Message-ID: <6388e64edfedd_17512e526d45695e3@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - 1 changed file: - compiler/GHC/Data/FastString.hs Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -465,8 +465,7 @@ mkFastStringWith mk_fs sbs = do FastStringTableSegment lock _ buckets# <- readIORef segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket sbs - case res of + case bucket_match bucket sbs of Just found -> return found Nothing -> do -- The withMVar below is not dupable. It can lead to deadlock if it is @@ -485,8 +484,7 @@ mkFastStringWith mk_fs sbs = do FastStringTableSegment _ counter buckets# <- maybeResizeSegment segmentRef let idx# = hashToIndex# buckets# hash# bucket <- IO $ readArray# buckets# idx# - res <- bucket_match bucket sbs - case res of + case bucket_match bucket sbs of -- The FastString was added by another thread after previous read and -- before we acquired the write lock. Just found -> return found @@ -497,11 +495,12 @@ mkFastStringWith mk_fs sbs = do _ <- atomicFetchAddFastMut counter 1 return fs -bucket_match :: [FastString] -> ShortByteString -> IO (Maybe FastString) -bucket_match [] _ = return Nothing -bucket_match (fs@(FastString {fs_sbs=fs_sbs}) : ls) sbs - | fs_sbs == sbs = return (Just fs) - | otherwise = bucket_match ls sbs +bucket_match :: [FastString] -> ShortByteString -> Maybe FastString +bucket_match fs sbs = go fs + where go [] = Nothing + go (fs@(FastString {fs_sbs=fs_sbs}) : ls) + | fs_sbs == sbs = Just fs + | otherwise = go ls mkFastStringBytes :: Ptr Word8 -> Int -> FastString mkFastStringBytes !ptr !len = View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72cf4c5d74923d267dab2dc260af090609066b04 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72cf4c5d74923d267dab2dc260af090609066b04 You're receiving 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 Dec 1 17:37:43 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Dec 2022 12:37:43 -0500 Subject: [Git][ghc/ghc][master] Add a missing varToCoreExpr in etaBodyForJoinPoint Message-ID: <6388e6675a304_17512e13299fec5736a8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 4 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - + testsuite/tests/simplCore/should_compile/T22491.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -3103,9 +3103,13 @@ etaBodyForJoinPoint need_args body | Just (tv, res_ty) <- splitForAllTyCoVar_maybe ty , let (subst', tv') = substVarBndr subst tv = go (n-1) res_ty subst' (tv' : rev_bs) (e `App` varToCoreExpr tv') + -- The varToCoreExpr is important: `tv` might be a coercion variable + | Just (_, mult, arg_ty, res_ty) <- splitFunTy_maybe ty , let (subst', b) = freshEtaId n subst (Scaled mult arg_ty) - = go (n-1) res_ty subst' (b : rev_bs) (e `App` Var b) + = go (n-1) res_ty subst' (b : rev_bs) (e `App` varToCoreExpr b) + -- The varToCoreExpr is important: `b` might be a coercion variable + | otherwise = pprPanic "etaBodyForJoinPoint" $ int need_args $$ ppr body $$ ppr (exprType body) ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1227,11 +1227,23 @@ simplExprF1 env (Let (NonRec bndr rhs) body) cont do { ty' <- simplType env ty ; simplExprF (extendTvSubst env bndr ty') body cont } + | Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs env + -- Because of the let-can-float invariant, it's ok to + -- inline freely, or to drop the binding if it is dead. + = do { tick (PreInlineUnconditionally bndr) + ; simplExprF env' body cont } + + -- Now check for a join point. It's better to do the preInlineUnconditionally + -- test first, because joinPointBinding_maybe has to eta-expand, so a trivial + -- binding like { j = j2 |> co } would first be eta-expanded and then inlined + -- Better to test preInlineUnconditionally first. | Just (bndr', rhs') <- joinPointBinding_maybe bndr rhs - = {-#SCC "simplNonRecJoinPoint" #-} simplNonRecJoinPoint env bndr' rhs' body cont + = {-#SCC "simplNonRecJoinPoint" #-} + simplNonRecJoinPoint env bndr' rhs' body cont | otherwise - = {-#SCC "simplNonRecE" #-} simplNonRecE env bndr (rhs, env) body cont + = {-#SCC "simplNonRecE" #-} + simplNonRecE env False bndr (rhs, env) body cont {- Note [Avoiding space leaks in OutType] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1680,12 +1692,12 @@ simpl_lam env bndr body (ApplyToVal { sc_arg = arg, sc_env = arg_se , sc_cont = cont, sc_dup = dup }) | isSimplified dup -- Don't re-simplify if we've simplified it once -- See Note [Avoiding exponential behaviour] - = do { tick (BetaReduction bndr) - ; completeBindX env bndr arg body cont } + = do { tick (BetaReduction bndr) + ; completeBindX env bndr arg body cont } | otherwise -- See Note [Avoiding exponential behaviour] - = do { tick (BetaReduction bndr) - ; simplNonRecE env bndr (arg, arg_se) body cont } + = do { tick (BetaReduction bndr) + ; simplNonRecE env True bndr (arg, arg_se) body cont } -- Discard a non-counting tick on a lambda. This may change the -- cost attribution slightly (moving the allocation of the @@ -1717,6 +1729,8 @@ simplLamBndrs env bndrs = mapAccumLM simplLamBndr env bndrs ------------------ simplNonRecE :: SimplEnv + -> Bool -- True <=> from a lambda + -- False <=> from a let -> InId -- The binder, always an Id -- Never a join point -> (InExpr, SimplEnv) -- Rhs of binding (or arg of lambda) @@ -1735,34 +1749,46 @@ simplNonRecE :: SimplEnv -- It deals with strict bindings, via the StrictBind continuation, -- which may abort the whole process. -- --- The RHS may not satisfy the let-can-float invariant yet +-- from_lam=False => the RHS satisfies the let-can-float invariant +-- Otherwise it may or may not satisfy it. -simplNonRecE env bndr (rhs, rhs_se) body cont +simplNonRecE env from_lam bndr (rhs, rhs_se) body cont = assert (isId bndr && not (isJoinId bndr) ) $ do { (env1, bndr1) <- simplNonRecBndr env bndr ; let needs_case_binding = needsCaseBinding (idType bndr1) rhs -- See Note [Dark corner with representation polymorphism] - ; if | not needs_case_binding - , Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs rhs_se -> - do { tick (PreInlineUnconditionally bndr) - ; -- pprTrace "preInlineUncond" (ppr bndr <+> ppr rhs) $ - simplLam env' body cont } - + -- If from_lam=False then needs_case_binding is False, + -- because the binding started as a let, which must + -- satisfy let-can-float + + ; if | from_lam && not needs_case_binding + -- If not from_lam we are coming from a (NonRec bndr rhs) binding + -- and preInlineUnconditionally has been done already; + -- no need to repeat it. But for lambdas we must be careful about + -- preInlineUndonditionally: consider (\(x:Int#). 3) (error "urk") + -- We must not drop the (error "urk"). + , Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs rhs_se + -> do { tick (PreInlineUnconditionally bndr) + ; -- pprTrace "preInlineUncond" (ppr bndr <+> ppr rhs) $ + simplLam env' body cont } -- Deal with strict bindings - -- See Note [Dark corner with representation polymorphism] - | isStrictId bndr1 && seCaseCase env - || needs_case_binding -> - simplExprF (rhs_se `setInScopeFromE` env) rhs - (StrictBind { sc_bndr = bndr, sc_body = body - , sc_env = env, sc_cont = cont, sc_dup = NoDup }) + | isStrictId bndr1 && seCaseCase env + || from_lam && needs_case_binding + -- The important bit here is needs_case_binds; but no need to + -- test it if from_lam is False because then needs_case_binding is False too + -- NB: either way, the RHS may or may not satisfy let-can-float + -- but that's ok for StrictBind. + -> simplExprF (rhs_se `setInScopeFromE` env) rhs + (StrictBind { sc_bndr = bndr, sc_body = body + , sc_env = env, sc_cont = cont, sc_dup = NoDup }) -- Deal with lazy bindings - | otherwise -> - do { (env2, bndr2) <- addBndrRules env1 bndr bndr1 (BC_Let NotTopLevel NonRecursive) - ; (floats1, env3) <- simplLazyBind env2 NotTopLevel NonRecursive bndr bndr2 rhs rhs_se - ; (floats2, expr') <- simplLam env3 body cont - ; return (floats1 `addFloats` floats2, expr') } } + | otherwise + -> do { (env2, bndr2) <- addBndrRules env1 bndr bndr1 (BC_Let NotTopLevel NonRecursive) + ; (floats1, env3) <- simplLazyBind env2 NotTopLevel NonRecursive bndr bndr2 rhs rhs_se + ; (floats2, expr') <- simplLam env3 body cont + ; return (floats1 `addFloats` floats2, expr') } } ------------------ simplRecE :: SimplEnv @@ -1806,7 +1832,7 @@ care here. Note [Avoiding exponential behaviour] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ One way in which we can get exponential behaviour is if we simplify a -big expression, and the re-simplify it -- and then this happens in a +big expression, and then re-simplify it -- and then this happens in a deeply-nested way. So we must be jolly careful about re-simplifying an expression. That is why simplNonRecX does not try preInlineUnconditionally (unlike simplNonRecE). @@ -1864,13 +1890,8 @@ simplNonRecJoinPoint :: SimplEnv -> InId -> InExpr -> InExpr -> SimplCont -> SimplM (SimplFloats, OutExpr) simplNonRecJoinPoint env bndr rhs body cont - | assert (isJoinId bndr ) True - , Just env' <- preInlineUnconditionally env NotTopLevel bndr rhs env - = do { tick (PreInlineUnconditionally bndr) - ; simplExprF env' body cont } - - | otherwise - = wrapJoinCont env cont $ \ env cont -> + = assert (isJoinId bndr ) $ + wrapJoinCont env cont $ \ env cont -> do { -- We push join_cont into the join RHS and the body; -- and wrap wrap_cont around the whole thing ; let mult = contHoleScaling cont ===================================== testsuite/tests/simplCore/should_compile/T22491.hs ===================================== @@ -0,0 +1,319 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +module T22491 (heapster_add_block_hints) where + +import qualified Control.Exception as X +import Control.Applicative +import Control.Monad +import Control.Monad.Catch (MonadThrow(..), MonadCatch(..), catches, Handler(..)) +import Control.Monad.IO.Class +import qualified Control.Monad.Fail as Fail +import Control.Monad.Trans.Class (MonadTrans(..)) +import Control.Monad.Trans.Reader (ReaderT) +import Data.Coerce (Coercible, coerce) +import Data.IORef +import Data.Kind (Type) +import Data.Monoid +import GHC.Exts (build) + +failOnNothing :: Fail.MonadFail m => String -> Maybe a -> m a +failOnNothing err_str Nothing = Fail.fail err_str +failOnNothing _ (Just a) = return a + +lookupLLVMSymbolModAndCFG :: HeapsterEnv -> String -> IO (Maybe (AnyCFG LLVM)) +lookupLLVMSymbolModAndCFG _ _ = pure Nothing + +heapster_add_block_hints :: HeapsterEnv -> String -> [Int] -> + (forall ext blocks ret. + CFG ext blocks ret -> + TopLevel Hint) -> + TopLevel () +heapster_add_block_hints henv nm blks hintF = + do env <- liftIO $ readIORef $ heapsterEnvPermEnvRef henv + AnyCFG cfg <- + failOnNothing ("Could not find symbol definition: " ++ nm) =<< + io (lookupLLVMSymbolModAndCFG henv nm) + let blocks = fmapFC blockInputs $ cfgBlockMap cfg + block_idxs = fmapFC (blockIDIndex . blockID) $ cfgBlockMap cfg + blkIDs <- case blks of + [] -> pure $ toListFC (Some . BlockID) block_idxs + _ -> forM blks $ \blk -> + failOnNothing ("Block ID " ++ show blk ++ + " not found in function " ++ nm) + (fmapF BlockID <$> intIndex blk (size blocks)) + env' <- foldM (\env' _ -> + permEnvAddHint env' <$> + hintF cfg) + env blkIDs + liftIO $ writeIORef (heapsterEnvPermEnvRef henv) env' + +----- + +data Some (f:: k -> Type) = forall x . Some (f x) + +class FunctorF m where + fmapF :: (forall x . f x -> g x) -> m f -> m g + +mapSome :: (forall tp . f tp -> g tp) -> Some f -> Some g +mapSome f (Some x) = Some $! f x + +instance FunctorF Some where fmapF = mapSome + +type SingleCtx x = EmptyCtx ::> x + +data Ctx k + = EmptyCtx + | Ctx k ::> k + +type family (<+>) (x :: Ctx k) (y :: Ctx k) :: Ctx k where + x <+> EmptyCtx = x + x <+> (y ::> e) = (x <+> y) ::> e + +data Height = Zero | Succ Height + +data BalancedTree h (f :: k -> Type) (p :: Ctx k) where + BalLeaf :: !(f x) -> BalancedTree 'Zero f (SingleCtx x) + BalPair :: !(BalancedTree h f x) + -> !(BalancedTree h f y) + -> BalancedTree ('Succ h) f (x <+> y) + +data BinomialTree (h::Height) (f :: k -> Type) :: Ctx k -> Type where + Empty :: BinomialTree h f EmptyCtx + + PlusOne :: !Int + -> !(BinomialTree ('Succ h) f x) + -> !(BalancedTree h f y) + -> BinomialTree h f (x <+> y) + + PlusZero :: !Int + -> !(BinomialTree ('Succ h) f x) + -> BinomialTree h f x + +tsize :: BinomialTree h f a -> Int +tsize Empty = 0 +tsize (PlusOne s _ _) = 2*s+1 +tsize (PlusZero s _) = 2*s + +fmap_bin :: (forall tp . f tp -> g tp) + -> BinomialTree h f c + -> BinomialTree h g c +fmap_bin _ Empty = Empty +fmap_bin f (PlusOne s t x) = PlusOne s (fmap_bin f t) (fmap_bal f x) +fmap_bin f (PlusZero s t) = PlusZero s (fmap_bin f t) +{-# INLINABLE fmap_bin #-} + +fmap_bal :: (forall tp . f tp -> g tp) + -> BalancedTree h f c + -> BalancedTree h g c +fmap_bal = go + where go :: (forall tp . f tp -> g tp) + -> BalancedTree h f c + -> BalancedTree h g c + go f (BalLeaf x) = BalLeaf (f x) + go f (BalPair x y) = BalPair (go f x) (go f y) +{-# INLINABLE fmap_bal #-} + +traverse_bin :: Applicative m + => (forall tp . f tp -> m (g tp)) + -> BinomialTree h f c + -> m (BinomialTree h g c) +traverse_bin _ Empty = pure Empty +traverse_bin f (PlusOne s t x) = PlusOne s <$> traverse_bin f t <*> traverse_bal f x +traverse_bin f (PlusZero s t) = PlusZero s <$> traverse_bin f t +{-# INLINABLE traverse_bin #-} + +traverse_bal :: Applicative m + => (forall tp . f tp -> m (g tp)) + -> BalancedTree h f c + -> m (BalancedTree h g c) +traverse_bal = go + where go :: Applicative m + => (forall tp . f tp -> m (g tp)) + -> BalancedTree h f c + -> m (BalancedTree h g c) + go f (BalLeaf x) = BalLeaf <$> f x + go f (BalPair x y) = BalPair <$> go f x <*> go f y +{-# INLINABLE traverse_bal #-} + +data Assignment (f :: k -> Type) (ctx :: Ctx k) + = Assignment (BinomialTree 'Zero f ctx) + +newtype Index (ctx :: Ctx k) (tp :: k) = Index { indexVal :: Int } + +newtype Size (ctx :: Ctx k) = Size Int + +intIndex :: Int -> Size ctx -> Maybe (Some (Index ctx)) +intIndex i n | 0 <= i && i < sizeInt n = Just (Some (Index i)) + | otherwise = Nothing + +size :: Assignment f ctx -> Size ctx +size (Assignment t) = Size (tsize t) + +sizeInt :: Size ctx -> Int +sizeInt (Size n) = n + +class FunctorFC (t :: (k -> Type) -> l -> Type) where + fmapFC :: forall f g. (forall x. f x -> g x) -> + (forall x. t f x -> t g x) + +(#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c) +(#.) _f = coerce + +class FoldableFC (t :: (k -> Type) -> l -> Type) where + foldMapFC :: forall f m. Monoid m => (forall x. f x -> m) -> (forall x. t f x -> m) + foldMapFC f = foldrFC (mappend . f) mempty + + foldrFC :: forall f b. (forall x. f x -> b -> b) -> (forall x. b -> t f x -> b) + foldrFC f z t = appEndo (foldMapFC (Endo #. f) t) z + + toListFC :: forall f a. (forall x. f x -> a) -> (forall x. t f x -> [a]) + toListFC f t = build (\c n -> foldrFC (\e v -> c (f e) v) n t) + +foldMapFCDefault :: (TraversableFC t, Monoid m) => (forall x. f x -> m) -> (forall x. t f x -> m) +foldMapFCDefault = \f -> getConst . traverseFC (Const . f) +{-# INLINE foldMapFCDefault #-} + +class (FunctorFC t, FoldableFC t) => TraversableFC (t :: (k -> Type) -> l -> Type) where + traverseFC :: forall f g m. Applicative m + => (forall x. f x -> m (g x)) + -> (forall x. t f x -> m (t g x)) + +instance FunctorFC Assignment where + fmapFC = \f (Assignment x) -> Assignment (fmap_bin f x) + {-# INLINE fmapFC #-} + +instance FoldableFC Assignment where + foldMapFC = foldMapFCDefault + {-# INLINE foldMapFC #-} + +instance TraversableFC Assignment where + traverseFC = \f (Assignment x) -> Assignment <$> traverse_bin f x + {-# INLINE traverseFC #-} + +data CrucibleType + +data TypeRepr (tp::CrucibleType) where + +type CtxRepr = Assignment TypeRepr + +data CFG (ext :: Type) + (blocks :: Ctx (Ctx CrucibleType)) + (ret :: CrucibleType) + = CFG { cfgBlockMap :: !(BlockMap ext blocks ret) + } + +type BlockMap ext blocks ret = Assignment (Block ext blocks ret) blocks + +data Block ext (blocks :: Ctx (Ctx CrucibleType)) (ret :: CrucibleType) ctx + = Block { blockID :: !(BlockID blocks ctx) + , blockInputs :: !(CtxRepr ctx) + } + +newtype BlockID (blocks :: Ctx (Ctx CrucibleType)) (tp :: Ctx CrucibleType) + = BlockID { blockIDIndex :: Index blocks tp } + +data LLVM + +data AnyCFG ext where + AnyCFG :: CFG ext blocks ret + -> AnyCFG ext + +newtype StateContT s r m a + = StateContT { runStateContT :: (a -> s -> m r) + -> s + -> m r + } + +fmapStateContT :: (a -> b) -> StateContT s r m a -> StateContT s r m b +fmapStateContT = \f m -> StateContT $ \c -> runStateContT m (\v s -> (c $! f v) s) +{-# INLINE fmapStateContT #-} + +applyStateContT :: StateContT s r m (a -> b) -> StateContT s r m a -> StateContT s r m b +applyStateContT = \mf mv -> + StateContT $ \c -> + runStateContT mf (\f -> runStateContT mv (\v s -> (c $! f v) s)) +{-# INLINE applyStateContT #-} + +returnStateContT :: a -> StateContT s r m a +returnStateContT = \v -> seq v $ StateContT $ \c -> c v +{-# INLINE returnStateContT #-} + +bindStateContT :: StateContT s r m a -> (a -> StateContT s r m b) -> StateContT s r m b +bindStateContT = \m n -> StateContT $ \c -> runStateContT m (\a -> runStateContT (n a) c) +{-# INLINE bindStateContT #-} + +instance Functor (StateContT s r m) where + fmap = fmapStateContT + +instance Applicative (StateContT s r m) where + pure = returnStateContT + (<*>) = applyStateContT + +instance Monad (StateContT s r m) where + (>>=) = bindStateContT + +instance MonadFail m => MonadFail (StateContT s r m) where + fail = \msg -> StateContT $ \_ _ -> fail msg + +instance MonadTrans (StateContT s r) where + lift = \m -> StateContT $ \c s -> m >>= \v -> seq v (c v s) + +instance MonadIO m => MonadIO (StateContT s r m) where + liftIO = lift . liftIO + +instance MonadThrow m => MonadThrow (StateContT s r m) where + throwM e = StateContT (\_k _s -> throwM e) + +instance MonadCatch m => MonadCatch (StateContT s r m) where + catch m hdl = + StateContT $ \k s -> + catch + (runStateContT m k s) + (\e -> runStateContT (hdl e) k s) + +data TopLevelRO +data TopLevelRW +data Value + +newtype TopLevel a = + TopLevel_ (ReaderT TopLevelRO (StateContT TopLevelRW (Value, TopLevelRW) IO) a) + deriving (Applicative, Functor, Monad, MonadFail, MonadThrow, MonadCatch) + +instance MonadIO TopLevel where + liftIO = io + +io :: IO a -> TopLevel a +io f = TopLevel_ (liftIO f) `catches` [Handler handleIO] + where + rethrow :: X.Exception ex => ex -> TopLevel a + rethrow ex = throwM (X.SomeException ex) + + handleIO :: X.IOException -> TopLevel a + handleIO = rethrow + +data HeapsterEnv = HeapsterEnv { + heapsterEnvPermEnvRef :: IORef PermEnv + } + +data Hint where + +data PermEnv = PermEnv { + permEnvHints :: [Hint] + } + +permEnvAddHint :: PermEnv -> Hint -> PermEnv +permEnvAddHint env hint = env { permEnvHints = hint : permEnvHints env } + +type family CtxToRList (ctx :: Ctx k) :: RList k where + CtxToRList EmptyCtx = RNil + CtxToRList (ctx' ::> x) = CtxToRList ctx' :> x + +data RList a + = RNil + | (RList a) :> a ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -455,3 +455,4 @@ test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m -ddebug-output']) test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('T22491', normal, compile, ['-O2']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/afc2540daf6ca6baa09ab147b792da08d66d878c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/afc2540daf6ca6baa09ab147b792da08d66d878c You're receiving 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 Dec 1 17:38:24 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Dec 2022 12:38:24 -0500 Subject: [Git][ghc/ghc][master] 3 commits: CI: Forbid the fully static build on Alpine to fail. Message-ID: <6388e69026192_17512e1e46a9d85770d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - 14 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - testsuite/tests/driver/all.T - testsuite/tests/ghci/T13786/all.T - testsuite/tests/ghci/linking/all.T - testsuite/tests/ghci/linking/dyn/all.T - testsuite/tests/ghci/prog001/prog001.T - testsuite/tests/ghci/prog002/prog002.T - testsuite/tests/ghci/prog010/all.T - testsuite/tests/ghci/scripts/all.T - testsuite/tests/package/T20010/all.T - testsuite/tests/plugins/all.T - testsuite/tests/rts/all.T - testsuite/tests/rts/linker/all.T Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -101,7 +101,7 @@ data Opsys data LinuxDistro = Debian11 | Debian10 | Debian9 | Fedora33 | Ubuntu2004 | Centos7 | Alpine deriving (Eq) -data Arch = Amd64 | AArch64 | ARMv7 | I386 +data Arch = Amd64 | AArch64 | I386 data BignumBackend = Native | Gmp deriving Eq @@ -230,7 +230,6 @@ runnerTag arch (Linux distro) = case arch of Amd64 -> "x86_64-linux" AArch64 -> "aarch64-linux" - ARMv7 -> "armv7-linux" I386 -> "x86_64-linux" runnerTag AArch64 Darwin = "aarch64-darwin" runnerTag Amd64 Darwin = "x86_64-darwin-m1" @@ -260,7 +259,6 @@ opsysName Windows = "windows" archName :: Arch -> String archName Amd64 = "x86_64" archName AArch64 = "aarch64" -archName ARMv7 = "armv7" archName I386 = "i386" binDistName :: Arch -> Opsys -> BuildConfig -> String @@ -347,18 +345,6 @@ opsysVariables _ FreeBSD13 = mconcat , "GHC_VERSION" =: "9.2.2" , "CABAL_INSTALL_VERSION" =: "3.6.2.0" ] -opsysVariables ARMv7 (Linux distro) = - distroVariables distro <> - mconcat [ "CONFIGURE_ARGS" =: "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf" - -- N.B. We disable ld.lld explicitly here because it appears to fail - -- non-deterministically on ARMv7. See #18280. - , "LD" =: "ld.gold" - , "GccUseLdOpt" =: "-fuse-ld=gold" - -- Awkwardly, this appears to be necessary to work around a - -- live-lock exhibited by the CPython (at least in 3.9 and 3.8) - -- interpreter on ARMv7 - , "HADRIAN_ARGS" =: "--test-verbose=3" - ] opsysVariables _ (Linux distro) = distroVariables distro opsysVariables AArch64 (Darwin {}) = mconcat [ "NIX_SYSTEM" =: "aarch64-darwin" @@ -525,7 +511,6 @@ data Rule = FastCI -- ^ Run this job when the fast-ci label is set | Nightly -- ^ Only run this job in the nightly pipeline | LLVMBackend -- ^ Only run this job when the "LLVM backend" label is present | FreeBSDLabel -- ^ Only run this job when the "FreeBSD" label is set. - | ARMLabel -- ^ Only run this job when the "ARM" label is set. | Disable -- ^ Don't run this job. deriving (Bounded, Enum, Ord, Eq) @@ -546,8 +531,6 @@ ruleString On LLVMBackend = "$CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/" ruleString Off LLVMBackend = true ruleString On FreeBSDLabel = "$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/" ruleString Off FreeBSDLabel = true -ruleString On ARMLabel = "$CI_MERGE_REQUEST_LABELS =~ /.*ARM.*/" -ruleString Off ARMLabel = true ruleString On ReleaseOnly = "$RELEASE_JOB == \"yes\"" ruleString Off ReleaseOnly = "$RELEASE_JOB != \"yes\"" ruleString On Nightly = "$NIGHTLY" @@ -824,9 +807,8 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , allowFailureGroup (addValidateRule ARMLabel (standardBuilds ARMv7 (Linux Debian10))) , standardBuilds I386 (Linux Debian9) - , allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) static) + , standardBuildsWithConfig Amd64 (Linux Alpine) static , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure") ===================================== .gitlab/jobs.yaml ===================================== @@ -35,7 +35,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -97,7 +97,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -120,67 +120,6 @@ "TEST_ENV": "aarch64-linux-deb10-validate" } }, - "armv7-linux-deb10-validate": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "2 weeks", - "paths": [ - "ghc-armv7-linux-deb10-validate.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*ARM.*/) && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-validate" - } - }, "i386-linux-deb9-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -216,7 +155,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -274,7 +213,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -337,7 +276,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -361,68 +300,6 @@ "XZ_OPT": "-9" } }, - "nightly-armv7-linux-deb10-validate": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "8 weeks", - "paths": [ - "ghc-armv7-linux-deb10-validate.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-validate", - "BUILD_FLAVOUR": "validate", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-validate", - "XZ_OPT": "-9" - } - }, "nightly-i386-linux-deb9-validate": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -458,7 +335,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -517,7 +394,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -582,7 +459,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -643,7 +520,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -676,7 +553,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "8 weeks", "paths": [ @@ -705,7 +582,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -767,7 +644,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -827,7 +704,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -886,7 +763,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -945,7 +822,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1005,7 +882,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1064,7 +941,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1123,7 +1000,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1182,7 +1059,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1241,7 +1118,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1302,7 +1179,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1363,7 +1240,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1424,7 +1301,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1483,7 +1360,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1542,7 +1419,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1603,7 +1480,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1665,7 +1542,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1726,7 +1603,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1781,7 +1658,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1840,7 +1717,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1903,7 +1780,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1967,7 +1844,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -1992,69 +1869,6 @@ "XZ_OPT": "-9" } }, - "release-armv7-linux-deb10-release": { - "after_script": [ - ".gitlab/ci.sh save_cache", - ".gitlab/ci.sh clean", - "cat ci_timings" - ], - "allow_failure": true, - "artifacts": { - "expire_in": "1 year", - "paths": [ - "ghc-armv7-linux-deb10-release.tar.xz", - "junit.xml" - ], - "reports": { - "junit": "junit.xml" - }, - "when": "always" - }, - "cache": { - "key": "armv7-linux-deb10-$CACHE_REV", - "paths": [ - "cabal-cache", - "toolchain" - ] - }, - "dependencies": [], - "image": "registry.gitlab.haskell.org/ghc/ci-images/armv7-linux-deb10:$DOCKER_REV", - "needs": [ - { - "artifacts": false, - "job": "hadrian-ghc-in-ghci" - } - ], - "rules": [ - { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", - "when": "on_success" - } - ], - "script": [ - "sudo chown ghc:ghc -R .", - ".gitlab/ci.sh setup", - ".gitlab/ci.sh configure", - ".gitlab/ci.sh build_hadrian", - ".gitlab/ci.sh test_hadrian" - ], - "stage": "full-build", - "tags": [ - "armv7-linux" - ], - "variables": { - "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-armv7-linux-deb10-release", - "BUILD_FLAVOUR": "release", - "CONFIGURE_ARGS": "--host=armv7-linux-gnueabihf --build=armv7-linux-gnueabihf --target=armv7-linux-gnueabihf ", - "GccUseLdOpt": "-fuse-ld=gold", - "HADRIAN_ARGS": "--test-verbose=3", - "IGNORE_PERF_FAILURES": "all", - "LD": "ld.gold", - "TEST_ENV": "armv7-linux-deb10-release", - "XZ_OPT": "-9" - } - }, "release-i386-linux-deb9-release": { "after_script": [ ".gitlab/ci.sh save_cache", @@ -2090,7 +1904,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2150,7 +1964,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2216,7 +2030,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2278,7 +2092,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2312,7 +2126,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "1 year", "paths": [ @@ -2341,7 +2155,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2404,7 +2218,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2465,7 +2279,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2525,7 +2339,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2585,7 +2399,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2645,7 +2459,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2705,7 +2519,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2767,7 +2581,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2829,7 +2643,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2892,7 +2706,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -2948,7 +2762,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3008,7 +2822,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3072,7 +2886,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3136,7 +2950,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/) && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/) && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3196,7 +3010,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3228,7 +3042,7 @@ ".gitlab/ci.sh clean", "cat ci_timings" ], - "allow_failure": true, + "allow_failure": false, "artifacts": { "expire_in": "2 weeks", "paths": [ @@ -3257,7 +3071,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3318,7 +3132,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3377,7 +3191,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3436,7 +3250,7 @@ "rules": [ { "allow_failure": true, - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "manual" } ], @@ -3494,7 +3308,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3553,7 +3367,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3611,7 +3425,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -3669,7 +3483,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3727,7 +3541,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && ($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && ($CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/) && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3786,7 +3600,7 @@ "rules": [ { "allow_failure": true, - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "manual" } ], @@ -3846,7 +3660,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3906,7 +3720,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -3966,7 +3780,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4024,7 +3838,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4082,7 +3896,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], @@ -4142,7 +3956,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4203,7 +4017,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4263,7 +4077,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4317,7 +4131,7 @@ ], "rules": [ { - "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", + "if": "($CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"disabled\" != \"disabled\")", "when": "on_success" } ], @@ -4375,7 +4189,7 @@ ], "rules": [ { - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null) && (\"true\" == \"true\") && (\"true\" == \"true\") && (\"true\" == \"true\")", "when": "on_success" } ], ===================================== testsuite/tests/driver/all.T ===================================== @@ -126,7 +126,7 @@ test('static001', [extra_files(['Static001.hs']), makefile_test, ['static001']) test('dynHelloWorld', - only_ways(['dyn']), + [only_ways(['dyn']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], compile_and_run, ['']) ===================================== testsuite/tests/ghci/T13786/all.T ===================================== @@ -1,4 +1,4 @@ test('T13786', - [when(unregisterised(), fragile(17018)), js_broken(22359)], + [when(unregisterised(), fragile(17018)), js_broken(22359), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/ghci/linking/all.T ===================================== @@ -32,7 +32,8 @@ test('ghcilink005', when(unregisterised(), fragile(16085)), unless(doing_ghci, skip), req_dynamic_lib_support, - req_interp], + req_interp, + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['ghcilink005']) test('ghcilink006', ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -3,6 +3,7 @@ setTestOpts(req_dynamic_lib_support) test('load_short_name', [ extra_files(['A.c']) , unless(doing_ghci, skip) , req_c + , when(opsys('linux') and not ghc_dynamic(), expect_broken(20706)) ], makefile_test, ['load_short_name']) @@ -11,7 +12,8 @@ test('T1407', unless(doing_ghci, skip), pre_cmd('$MAKE -s --no-print-directory compile_libT1407'), extra_hc_opts('-L"$PWD/T1407dir"'), - js_broken(22359)], + js_broken(22359), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('T3242', ===================================== testsuite/tests/ghci/prog001/prog001.T ===================================== @@ -3,5 +3,6 @@ test('prog001', when(arch('arm'), fragile(17555)), cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), req_interp, - unless(opsys('mingw32') or not config.have_RTS_linker, extra_ways(['ghci-ext']))], + unless(opsys('mingw32') or not config.have_RTS_linker, extra_ways(['ghci-ext'])), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['prog001.script']) ===================================== testsuite/tests/ghci/prog002/prog002.T ===================================== @@ -1,3 +1,4 @@ test('prog002', [extra_files(['../shell.hs', 'A1.hs', 'A2.hs', 'B.hs', 'C.hs', 'D.hs']), - cmd_prefix('ghciWayFlags=' + config.ghci_way_flags)], + cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['prog002.script']) ===================================== testsuite/tests/ghci/prog010/all.T ===================================== @@ -1,4 +1,5 @@ test('ghci.prog010', [cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), - extra_files(['../shell.hs', 'A.hs', 'B.hs'])], + extra_files(['../shell.hs', 'A.hs', 'B.hs']), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['ghci.prog010.script']) ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -159,7 +159,8 @@ test('T6106', [extra_files(['../shell.hs']), test('T6105', normal, ghci_script, ['T6105.script']) test('T7117', normal, ghci_script, ['T7117.script']) test('ghci058', [extra_files(['../shell.hs']), - cmd_prefix('ghciWayFlags=' + config.ghci_way_flags)], + cmd_prefix('ghciWayFlags=' + config.ghci_way_flags), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['ghci058.script']) test('T7587', normal, ghci_script, ['T7587.script']) test('T7688', normal, ghci_script, ['T7688.script']) ===================================== testsuite/tests/package/T20010/all.T ===================================== @@ -1,4 +1,4 @@ # Test that GHC links to the C++ standard library as expected # when the system-cxx-std-lib package is used. test('T20010', req_c, makefile_test, []) -test('T20010-ghci', [req_c, extra_files(['T20010_c.cpp', 'T20010.hs'])], makefile_test, []) +test('T20010-ghci', [req_c, extra_files(['T20010_c.cpp', 'T20010.hs']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/plugins/all.T ===================================== @@ -115,7 +115,7 @@ test('T10294a', pre_cmd('$MAKE -s --no-print-directory -C annotation-plugin package.T10294a TOP={top}')], makefile_test, []) -test('frontend01', [extra_files(['FrontendPlugin.hs'])], +test('frontend01', [extra_files(['FrontendPlugin.hs']), when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('T11244', @@ -294,25 +294,30 @@ test('T20803b', test('test-echo-in-turn', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-line', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-turn-many-args', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('test-echo-in-line-many-args', [extra_files(['echo-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) test('plugins-external', [extra_files(['shared-plugin/']), - pre_cmd('$MAKE -s --no-print-directory -C shared-plugin package.plugins01 TOP={top}')], + pre_cmd('$MAKE -s --no-print-directory -C shared-plugin package.plugins01 TOP={top}'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, []) ===================================== testsuite/tests/rts/all.T ===================================== @@ -272,7 +272,8 @@ test('T7040_ghci', only_ways(['ghci']), # Fragile when unregisterised; see #16085 when(unregisterised(), skip), - pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup')], + pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup'), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], compile_and_run, ['T7040_ghci_c.o']) test('T7227', [extra_run_opts('+RTS -tT7227.stat --machine-readable -RTS')], @@ -497,7 +498,8 @@ test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) test('T13676', [when(opsys('mingw32'), expect_broken(17447)), - extra_files(['T13676.hs'])], + extra_files(['T13676.hs']), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], ghci_script, ['T13676.script']) test('InitEventLogging', [ only_ways(['normal']) ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -59,7 +59,8 @@ def checkDynAsm(actual_file, normaliser): test('T5435_v_asm_a', [extra_files(['T5435.hs', 'T5435_asm.c']), req_rts_linker, - when(arch('arm'), expect_broken(17559))], + when(arch('arm'), expect_broken(17559)), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_asm_a']) # this one just needs to run on linux, as darwin/mingw32 are covered # by the _a test already. @@ -67,12 +68,14 @@ test('T5435_v_asm_b', [extra_files(['T5435.hs', 'T5435_asm.c']), req_rts_linker, when(arch('arm'), expect_broken(17559)), - when(opsys('darwin') or opsys('mingw32'), skip)], + when(opsys('darwin') or opsys('mingw32'), skip), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_asm_b']) test('T5435_v_gcc', [extra_files(['T5435.hs', 'T5435_gcc.c']), req_rts_linker, - when(arch('arm'), expect_broken(17559))], + when(arch('arm'), expect_broken(17559)), + when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T5435_v_gcc']) test('T5435_dyn_asm', [extra_files(['T5435.hs', 'T5435_asm.c']), @@ -126,7 +129,7 @@ test('T7072', req_rts_linker], makefile_test, ['T7072']) -test('T20494', [req_rts_linker], +test('T20494', [req_rts_linker, when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))], makefile_test, ['T20494']) test('T20918', View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/afc2540daf6ca6baa09ab147b792da08d66d878c...d82992fd4b62a81607af1667e4ff755d58af291f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/afc2540daf6ca6baa09ab147b792da08d66d878c...d82992fd4b62a81607af1667e4ff755d58af291f You're receiving 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 Dec 1 17:49:14 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 01 Dec 2022 12:49:14 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/t22483 Message-ID: <6388e91a8b73a_17512eecff5e05809ad@gitlab.mail> Matthew Pickering pushed new branch wip/t22483 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t22483 You're receiving 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 Dec 1 18:04:08 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Thu, 01 Dec 2022 13:04:08 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22546 Message-ID: <6388ec98a663c_17512e64b9d705918d5@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/T22546 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22546 You're receiving 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 Dec 2 04:12:15 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 01 Dec 2022 23:12:15 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: FastString: SAT bucket_match Message-ID: <63897b1f3bd6e_17512e1e46a9d864256@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - 7987dacf by Simon Peyton Jones at 2022-12-01T23:12:07-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 561e9f18 by Matthew Pickering at 2022-12-01T23:12:08-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 30 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + compiler/GHC/Core/TyCo/FVs.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - + testsuite/tests/ado/T22483.hs - + testsuite/tests/ado/T22483.stderr - testsuite/tests/ado/all.T - testsuite/tests/driver/all.T - testsuite/tests/ghci/T13786/all.T - testsuite/tests/ghci/linking/all.T - testsuite/tests/ghci/linking/dyn/all.T - testsuite/tests/ghci/prog001/prog001.T - testsuite/tests/ghci/prog002/prog002.T - testsuite/tests/ghci/prog010/all.T - testsuite/tests/ghci/scripts/all.T - testsuite/tests/package/T20010/all.T - testsuite/tests/plugins/all.T - testsuite/tests/rts/all.T - testsuite/tests/rts/linker/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/237dbc37cebdf1552e7cec1c025b31e17241cad6...561e9f181cf6f6011de25eaabe210686099b9aeb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/237dbc37cebdf1552e7cec1c025b31e17241cad6...561e9f181cf6f6011de25eaabe210686099b9aeb You're receiving 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 Dec 2 06:22:47 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 02 Dec 2022 01:22:47 -0500 Subject: [Git][ghc/ghc][master] Refactor TyCon to have a top-level product Message-ID: <638999b7b40c2_17512e240afea0661149@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 10 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + compiler/GHC/Core/TyCo/FVs.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - utils/haddock Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -1038,12 +1038,11 @@ unboxedTupleKind = unboxedTupleSumKind tupleRepDataConTyCon mk_tuple :: Boxity -> Int -> (TyCon,DataCon) mk_tuple Boxed arity = (tycon, tuple_con) where - tycon = mkTupleTyCon tc_name tc_binders tc_res_kind tc_arity tuple_con + tycon = mkTupleTyCon tc_name tc_binders tc_res_kind tuple_con BoxedTuple flavour tc_binders = mkTemplateAnonTyConBinders (replicate arity liftedTypeKind) tc_res_kind = liftedTypeKind - tc_arity = arity flavour = VanillaAlgTyCon (mkPrelTyConRepName tc_name) dc_tvs = binderVars tc_binders @@ -1061,7 +1060,7 @@ mk_tuple Boxed arity = (tycon, tuple_con) mk_tuple Unboxed arity = (tycon, tuple_con) where - tycon = mkTupleTyCon tc_name tc_binders tc_res_kind tc_arity tuple_con + tycon = mkTupleTyCon tc_name tc_binders tc_res_kind tuple_con UnboxedTuple flavour -- See Note [Unboxed tuple RuntimeRep vars] in GHC.Core.TyCon @@ -1070,8 +1069,6 @@ mk_tuple Unboxed arity = (tycon, tuple_con) (\ks -> map mkTYPEapp ks) tc_res_kind = unboxedTupleKind rr_tys - - tc_arity = arity * 2 flavour = VanillaAlgTyCon (mkPrelTyConRepName tc_name) dc_tvs = binderVars tc_binders @@ -1224,7 +1221,7 @@ unboxedSumKind = unboxedTupleSumKind sumRepDataConTyCon mk_sum :: Arity -> (TyCon, Array ConTagZ DataCon) mk_sum arity = (tycon, sum_cons) where - tycon = mkSumTyCon tc_name tc_binders tc_res_kind (arity * 2) tyvars (elems sum_cons) + tycon = mkSumTyCon tc_name tc_binders tc_res_kind (elems sum_cons) UnboxedSumTyCon tc_binders = mkTemplateTyConBinders (replicate arity runtimeRepTy) ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -271,7 +271,10 @@ eqDeBruijnType env_t1@(D env1 t1) env_t2@(D env2 t2) = -> TEQ _ -> TNEQ - gos _ _ [] [] = TEQ + -- These bangs make 'gos' strict in the CMEnv, which in turn + -- keeps the CMEnv unboxed across the go/gos mutual recursion + -- (If you want a test case, T9872c really exercises this code.) + gos !_ !_ [] [] = TEQ gos e1 e2 (ty1:tys1) (ty2:tys2) = go (D e1 ty1) (D e2 ty2) `andEq` gos e1 e2 tys1 tys2 gos _ _ _ _ = TNEQ ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -571,6 +571,11 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. +instance Outputable i => Outputable (UnboxingDecision i) where + ppr DontUnbox = text "DontUnbox" + ppr DropAbsent = text "DropAbsent" + ppr (DoUnbox i) = text "DoUnbox" <> braces (ppr i) + -- | Do we want to create workers just for unlifting? wwUseForUnlifting :: WwOpts -> WwUse wwUseForUnlifting !opts ===================================== compiler/GHC/Core/TyCo/FVs.hs-boot ===================================== @@ -0,0 +1,6 @@ +module GHC.Core.TyCo.FVs where + +import GHC.Prelude ( Bool ) +import {-# SOURCE #-} GHC.Core.TyCo.Rep ( Type ) + +noFreeVarsOfType :: Type -> Bool ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -81,7 +81,7 @@ module GHC.Core.TyCon( tyConKind, tyConUnique, tyConTyVars, tyConVisibleTyVars, - tyConCType, tyConCType_maybe, + tyConCType_maybe, tyConDataCons, tyConDataCons_maybe, tyConSingleDataCon_maybe, tyConSingleDataCon, tyConAlgDataCons_maybe, @@ -96,7 +96,7 @@ module GHC.Core.TyCon( tyConFamInst_maybe, tyConFamInstSig_maybe, tyConFamilyCoercion_maybe, tyConFamilyResVar_maybe, synTyConDefn_maybe, synTyConRhs_maybe, - famTyConFlav_maybe, famTcResVar, + famTyConFlav_maybe, algTyConRhs, newTyConRhs, newTyConEtadArity, newTyConEtadRhs, unwrapNewTyCon_maybe, unwrapNewTyConEtad_maybe, @@ -104,7 +104,8 @@ module GHC.Core.TyCon( algTcFields, tyConPromDataConInfo, tyConBinders, tyConResKind, tyConInvisTVBinders, - tcTyConScopedTyVars, tcTyConIsPoly, + tcTyConScopedTyVars, isMonoTcTyCon, + tyConHasClosedResKind, mkTyConTagMap, -- ** Manipulating TyCons @@ -140,6 +141,8 @@ import GHC.Platform import {-# SOURCE #-} GHC.Core.TyCo.Rep ( Kind, Type, PredType, mkForAllTy, mkNakedFunTy, mkNakedTyConTy ) +import {-# SOURCE #-} GHC.Core.TyCo.FVs + ( noFreeVarsOfType ) import {-# SOURCE #-} GHC.Core.TyCo.Ppr ( pprType ) import {-# SOURCE #-} GHC.Builtin.Types @@ -775,10 +778,34 @@ instance Binary TyConBndrVis where -- -- This data type also encodes a number of primitive, built in type constructors -- such as those for function and tuple types. - +-- -- If you edit this type, you may need to update the GHC formalism -- See Note [GHC Formalism] in GHC.Core.Lint -data TyCon = +data TyCon = TyCon { + tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: + -- identical to Unique of Name stored in + -- tyConName field. + + tyConName :: !Name, -- ^ Name of the constructor + + -- See Note [The binders/kind/arity fields of a TyCon] + tyConBinders :: [TyConBinder], -- ^ Full binders + tyConResKind :: Kind, -- ^ Result kind + tyConHasClosedResKind :: Bool, + + -- Cached values + tyConTyVars :: [TyVar], -- ^ TyVar binders + tyConKind :: Kind, -- ^ Kind of this TyCon + tyConArity :: Arity, -- ^ Arity + tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ + + tyConRoles :: [Role], -- ^ The role for each type variable + -- This list has length = tyConArity + -- See also Note [TyCon Role signatures] + + tyConDetails :: !TyConDetails } + +data TyConDetails = -- | Algebraic data types, from -- - @data@ declarations -- - @newtype@ declarations @@ -792,20 +819,6 @@ data TyCon = -- Data/newtype/type /families/ are handled by 'FamilyTyCon'. -- See 'AlgTyConRhs' for more information. AlgTyCon { - tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: - -- identical to Unique of Name stored in - -- tyConName field. - - tyConName :: Name, -- ^ Name of the constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConTyVars :: [TyVar], -- ^ TyVar binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ - -- The tyConTyVars scope over: -- -- 1. The 'algTcStupidTheta' @@ -815,10 +828,6 @@ data TyCon = -- Note that it does /not/ scope over the data -- constructors. - tcRoles :: [Role], -- ^ The role for each type variable - -- This list has length = tyConArity - -- See also Note [TyCon Role signatures] - tyConCType :: Maybe CType,-- ^ The C type that should be used -- for this type when using the FFI -- and CAPI @@ -853,25 +862,8 @@ data TyCon = -- | Represents type synonyms | SynonymTyCon { - tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: - -- identical to Unique of Name stored in - -- tyConName field. - - tyConName :: Name, -- ^ Name of the constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConTyVars :: [TyVar], -- ^ TyVar binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ -- tyConTyVars scope over: synTcRhs - tcRoles :: [Role], -- ^ The role for each type variable - -- This list has length = tyConArity - -- See also Note [TyCon Role signatures] - synTcRhs :: Type, -- ^ Contains information about the expansion -- of the synonym @@ -892,19 +884,6 @@ data TyCon = -- | Represents families (both type and data) -- Argument roles are all Nominal | FamilyTyCon { - tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: - -- identical to Unique of Name stored in - -- tyConName field. - - tyConName :: Name, -- ^ Name of the constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConTyVars :: [TyVar], -- ^ TyVar binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ -- tyConTyVars connect an associated family TyCon -- with its parent class; see GHC.Tc.Validity.checkConsistentFamInst @@ -930,23 +909,6 @@ data TyCon = -- the usual suspects (such as @Int#@) as well as foreign-imported -- types and kinds (@*@, @#@, and @?@) | PrimTyCon { - tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: - -- identical to Unique of Name stored in - -- tyConName field. - - tyConName :: Name, -- ^ Name of the constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ - - tcRoles :: [Role], -- ^ The role for each type variable - -- This list has length = tyConArity - -- See also Note [TyCon Role signatures] - primRepName :: TyConRepName -- ^ The 'Typeable' representation. -- A cached version of -- @'mkPrelTyConRepName' ('tyConName' tc)@. @@ -954,18 +916,6 @@ data TyCon = -- | Represents promoted data constructor. | PromotedDataCon { -- See Note [Promoted data constructors] - tyConUnique :: !Unique, -- ^ Same Unique as the data constructor - tyConName :: Name, -- ^ Same Name as the data constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConPiTyBinder], -- ^ Full binders - -- TyConPiTyBinder: see Note [Promoted GADT data constructors] - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ - - tcRoles :: [Role], -- ^ Roles: N for kind vars, R for type vars dataCon :: DataCon, -- ^ Corresponding data constructor tcRepName :: TyConRepName, promDcInfo :: PromDataConInfo -- ^ See comments with 'PromDataConInfo' @@ -974,31 +924,20 @@ data TyCon = -- | These exist only during type-checking. See Note [How TcTyCons work] -- in "GHC.Tc.TyCl" | TcTyCon { - tyConUnique :: !Unique, - tyConName :: Name, - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConTyVars :: [TyVar], -- ^ TyVar binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ - -- NB: the tyConArity of a TcTyCon must match -- the number of Required (positional, user-specified) -- arguments to the type constructor; see the use -- of tyConArity in generaliseTcTyCon - tcTyConScopedTyVars :: [(Name,TcTyVar)], + tctc_scoped_tvs :: [(Name,TcTyVar)], -- ^ Scoped tyvars over the tycon's body -- The range is always a skolem or TcTyVar, be -- MonoTcTyCon only: see Note [Scoped tyvars in a TcTyCon] - tcTyConIsPoly :: Bool, -- ^ Is this TcTyCon already generalized? - -- Used only to make zonking more efficient + tctc_is_poly :: Bool, -- ^ Is this TcTyCon already generalized? + -- Used only to make zonking more efficient - tcTyConFlavour :: TyConFlavour + tctc_flavour :: TyConFlavour -- ^ What sort of 'TyCon' this represents. } @@ -1517,21 +1456,24 @@ type TyConRepName = Name -- $tcMaybe = TyCon { tyConName = "Maybe", ... } tyConRepName_maybe :: TyCon -> Maybe TyConRepName -tyConRepName_maybe (PrimTyCon { primRepName = rep_nm }) - = Just rep_nm -tyConRepName_maybe (AlgTyCon { algTcFlavour = parent }) = case parent of - VanillaAlgTyCon rep_nm -> Just rep_nm - UnboxedSumTyCon -> Nothing - ClassTyCon _ rep_nm -> Just rep_nm - DataFamInstTyCon {} -> Nothing -tyConRepName_maybe (FamilyTyCon { famTcFlav = DataFamilyTyCon rep_nm }) - = Just rep_nm -tyConRepName_maybe (PromotedDataCon { dataCon = dc, tcRepName = rep_nm }) - | isUnboxedSumDataCon dc -- see #13276 - = Nothing - | otherwise - = Just rep_nm -tyConRepName_maybe _ = Nothing +tyConRepName_maybe (TyCon { tyConDetails = details }) = get_rep_nm details + where + get_rep_nm (PrimTyCon { primRepName = rep_nm }) + = Just rep_nm + get_rep_nm (AlgTyCon { algTcFlavour = parent }) + = case parent of + VanillaAlgTyCon rep_nm -> Just rep_nm + UnboxedSumTyCon -> Nothing + ClassTyCon _ rep_nm -> Just rep_nm + DataFamInstTyCon {} -> Nothing + get_rep_nm (FamilyTyCon { famTcFlav = DataFamilyTyCon rep_nm }) + = Just rep_nm + get_rep_nm (PromotedDataCon { dataCon = dc, tcRepName = rep_nm }) + | isUnboxedSumDataCon dc -- see #13276 + = Nothing + | otherwise + = Just rep_nm + get_rep_nm _ = Nothing -- | Make a 'Name' for the 'Typeable' representation of the given wired-in type mkPrelTyConRepName :: Name -> TyConRepName @@ -1821,9 +1763,9 @@ tyConFieldLabels tc = dFsEnvElts $ tyConFieldLabelEnv tc -- | The labels for the fields of this particular 'TyCon' tyConFieldLabelEnv :: TyCon -> FieldLabelEnv -tyConFieldLabelEnv tc - | isAlgTyCon tc = algTcFields tc - | otherwise = emptyDFsEnv +tyConFieldLabelEnv (TyCon { tyConDetails = details }) + | AlgTyCon { algTcFields = fields } <- details = fields + | otherwise = emptyDFsEnv -- | Look up a field label belonging to this 'TyCon' lookupTyConFieldLabel :: FieldLabelString -> TyCon -> Maybe FieldLabel @@ -1853,6 +1795,25 @@ module mutual-recursion. And they aren't called from many places. So we compromise, and move their Kind calculation to the call site. -} +mkTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> TyConDetails -> TyCon +mkTyCon name binders res_kind roles details + = tc + where + -- Recurisve binding because of tcNullaryTy + tc = TyCon { tyConName = name + , tyConUnique = nameUnique name + , tyConBinders = binders + , tyConResKind = res_kind + , tyConRoles = roles + , tyConDetails = details + + -- Cached things + , tyConKind = mkTyConKind binders res_kind + , tyConArity = length binders + , tyConNullaryTy = mkNakedTyConTy tc + , tyConHasClosedResKind = noFreeVarsOfType res_kind + , tyConTyVars = binderVars binders } + -- | This is the making of an algebraic 'TyCon'. mkAlgTyCon :: Name -> [TyConBinder] -- ^ Binders of the 'TyCon' @@ -1867,25 +1828,14 @@ mkAlgTyCon :: Name -> Bool -- ^ Was the 'TyCon' declared with GADT syntax? -> TyCon mkAlgTyCon name binders res_kind roles cType stupid rhs parent gadt_syn - = let tc = - AlgTyCon { - tyConName = name, - tyConUnique = nameUnique name, - tyConBinders = binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = length binders, - tyConNullaryTy = mkNakedTyConTy tc, - tyConTyVars = binderVars binders, - tcRoles = roles, - tyConCType = cType, - algTcStupidTheta = stupid, - algTcRhs = rhs, - algTcFields = fieldsOfAlgTcRhs rhs, - algTcFlavour = assertPpr (okParent name parent) (ppr name $$ ppr parent) parent, - algTcGadtSyntax = gadt_syn - } - in tc + = mkTyCon name binders res_kind roles $ + AlgTyCon { tyConCType = cType + , algTcStupidTheta = stupid + , algTcRhs = rhs + , algTcFields = fieldsOfAlgTcRhs rhs + , algTcFlavour = assertPpr (okParent name parent) + (ppr name $$ ppr parent) parent + , algTcGadtSyntax = gadt_syn } -- | Simpler specialization of 'mkAlgTyCon' for classes mkClassTyCon :: Name -> [TyConBinder] @@ -1899,61 +1849,37 @@ mkClassTyCon name binders roles rhs clas tc_rep_name mkTupleTyCon :: Name -> [TyConBinder] -> Kind -- ^ Result kind of the 'TyCon' - -> Arity -- ^ Arity of the tuple 'TyCon' -> DataCon -> TupleSort -- ^ Whether the tuple is boxed or unboxed -> AlgTyConFlav -> TyCon -mkTupleTyCon name binders res_kind arity con sort parent - = let tc = - AlgTyCon { - tyConUnique = nameUnique name, - tyConName = name, - tyConBinders = binders, - tyConTyVars = binderVars binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = arity, - tyConNullaryTy = mkNakedTyConTy tc, - tcRoles = replicate arity Representational, - tyConCType = Nothing, - algTcGadtSyntax = False, - algTcStupidTheta = [], - algTcRhs = TupleTyCon { data_con = con, - tup_sort = sort }, - algTcFields = emptyDFsEnv, - algTcFlavour = parent - } - in tc +mkTupleTyCon name binders res_kind con sort parent + = mkTyCon name binders res_kind (constRoles binders Representational) $ + AlgTyCon { tyConCType = Nothing + , algTcGadtSyntax = False + , algTcStupidTheta = [] + , algTcRhs = TupleTyCon { data_con = con + , tup_sort = sort } + , algTcFields = emptyDFsEnv + , algTcFlavour = parent } + +constRoles :: [TyConBinder] -> Role -> [Role] +constRoles bndrs role = [role | _ <- bndrs] mkSumTyCon :: Name - -> [TyConBinder] - -> Kind -- ^ Kind of the resulting 'TyCon' - -> Arity -- ^ Arity of the sum - -> [TyVar] -- ^ 'TyVar's scoped over: see 'tyConTyVars' - -> [DataCon] - -> AlgTyConFlav - -> TyCon -mkSumTyCon name binders res_kind arity tyvars cons parent - = let tc = - AlgTyCon { - tyConUnique = nameUnique name, - tyConName = name, - tyConBinders = binders, - tyConTyVars = tyvars, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = arity, - tyConNullaryTy = mkNakedTyConTy tc, - tcRoles = replicate arity Representational, - tyConCType = Nothing, - algTcGadtSyntax = False, - algTcStupidTheta = [], - algTcRhs = mkSumTyConRhs cons, - algTcFields = emptyDFsEnv, - algTcFlavour = parent - } - in tc + -> [TyConBinder] + -> Kind -- ^ Kind of the resulting 'TyCon' + -> [DataCon] + -> AlgTyConFlav + -> TyCon +mkSumTyCon name binders res_kind cons parent + = mkTyCon name binders res_kind (constRoles binders Representational) $ + AlgTyCon { tyConCType = Nothing + , algTcGadtSyntax = False + , algTcStupidTheta = [] + , algTcRhs = mkSumTyConRhs cons + , algTcFields = emptyDFsEnv + , algTcFlavour = parent } -- | Makes a tycon suitable for use during type-checking. It stores -- a variety of details about the definition of the TyCon, but no @@ -1971,19 +1897,10 @@ mkTcTyCon :: Name -> TyConFlavour -- ^ What sort of 'TyCon' this represents -> TyCon mkTcTyCon name binders res_kind scoped_tvs poly flav - = let tc = - TcTyCon { tyConUnique = getUnique name - , tyConName = name - , tyConTyVars = binderVars binders - , tyConBinders = binders - , tyConResKind = res_kind - , tyConKind = mkTyConKind binders res_kind - , tyConArity = length binders - , tyConNullaryTy = mkNakedTyConTy tc - , tcTyConScopedTyVars = scoped_tvs - , tcTyConIsPoly = poly - , tcTyConFlavour = flav } - in tc + = mkTyCon name binders res_kind (constRoles binders Nominal) $ + TcTyCon { tctc_scoped_tvs = scoped_tvs + , tctc_is_poly = poly + , tctc_flavour = flav } -- | No scoped type variables (to be used with mkTcTyCon). noTcTyConScopedTyVars :: [(Name, TcTyVar)] @@ -2000,64 +1917,29 @@ mkPrimTyCon :: Name -> [TyConBinder] -> [Role] -> TyCon mkPrimTyCon name binders res_kind roles - = let tc = - PrimTyCon { - tyConName = name, - tyConUnique = nameUnique name, - tyConBinders = binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = length roles, - tyConNullaryTy = mkNakedTyConTy tc, - tcRoles = roles, - primRepName = mkPrelTyConRepName name - } - in tc + = mkTyCon name binders res_kind roles $ + PrimTyCon { primRepName = mkPrelTyConRepName name } -- | Create a type synonym 'TyCon' mkSynonymTyCon :: Name -> [TyConBinder] -> Kind -- ^ /result/ kind -> [Role] -> Type -> Bool -> Bool -> Bool -> TyCon mkSynonymTyCon name binders res_kind roles rhs is_tau is_fam_free is_forgetful - = let tc = - SynonymTyCon { - tyConName = name, - tyConUnique = nameUnique name, - tyConBinders = binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = length binders, - tyConNullaryTy = mkNakedTyConTy tc, - tyConTyVars = binderVars binders, - tcRoles = roles, - synTcRhs = rhs, - synIsTau = is_tau, - synIsFamFree = is_fam_free, - synIsForgetful = is_forgetful - } - in tc + = mkTyCon name binders res_kind roles $ + SynonymTyCon { synTcRhs = rhs + , synIsTau = is_tau + , synIsFamFree = is_fam_free + , synIsForgetful = is_forgetful } -- | Create a type family 'TyCon' mkFamilyTyCon :: Name -> [TyConBinder] -> Kind -- ^ /result/ kind -> Maybe Name -> FamTyConFlav -> Maybe Class -> Injectivity -> TyCon mkFamilyTyCon name binders res_kind resVar flav parent inj - = let tc = - FamilyTyCon - { tyConUnique = nameUnique name - , tyConName = name - , tyConBinders = binders - , tyConResKind = res_kind - , tyConKind = mkTyConKind binders res_kind - , tyConArity = length binders - , tyConNullaryTy = mkNakedTyConTy tc - , tyConTyVars = binderVars binders - , famTcResVar = resVar - , famTcFlav = flav - , famTcParent = classTyCon <$> parent - , famTcInj = inj - } - in tc - + = mkTyCon name binders res_kind (constRoles binders Nominal) $ + FamilyTyCon { famTcResVar = resVar + , famTcFlav = flav + , famTcParent = classTyCon <$> parent + , famTcInj = inj } -- | Create a promoted data constructor 'TyCon' -- Somewhat dodgily, we give it the same Name @@ -2067,43 +1949,36 @@ mkPromotedDataCon :: DataCon -> Name -> TyConRepName -> [TyConPiTyBinder] -> Kind -> [Role] -> PromDataConInfo -> TyCon mkPromotedDataCon con name rep_name binders res_kind roles rep_info - = let tc = - PromotedDataCon { - tyConUnique = nameUnique name, - tyConName = name, - tyConArity = length roles, - tyConNullaryTy = mkNakedTyConTy tc, - tcRoles = roles, - tyConBinders = binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - dataCon = con, - tcRepName = rep_name, - promDcInfo = rep_info - } - in tc + = mkTyCon name binders res_kind roles $ + PromotedDataCon { dataCon = con + , tcRepName = rep_name + , promDcInfo = rep_info } -- | Test if the 'TyCon' is algebraic but abstract (invisible data constructors) isAbstractTyCon :: TyCon -> Bool -isAbstractTyCon (AlgTyCon { algTcRhs = AbstractTyCon {} }) = True -isAbstractTyCon _ = False +isAbstractTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = AbstractTyCon {} } <- details = True + | otherwise = False -- | Does this 'TyCon' represent something that cannot be defined in Haskell? isPrimTyCon :: TyCon -> Bool -isPrimTyCon (PrimTyCon {}) = True -isPrimTyCon _ = False +isPrimTyCon (TyCon { tyConDetails = details }) + | PrimTyCon {} <- details = True + | otherwise = False -- | Returns @True@ if the supplied 'TyCon' resulted from either a -- @data@ or @newtype@ declaration isAlgTyCon :: TyCon -> Bool -isAlgTyCon (AlgTyCon {}) = True -isAlgTyCon _ = False +isAlgTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {} <- details = True + | otherwise = False -- | Returns @True@ for vanilla AlgTyCons -- that is, those created -- with a @data@ or @newtype@ declaration. isVanillaAlgTyCon :: TyCon -> Bool -isVanillaAlgTyCon (AlgTyCon { algTcFlavour = VanillaAlgTyCon _ }) = True -isVanillaAlgTyCon _ = False +isVanillaAlgTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcFlavour = VanillaAlgTyCon _ } <- details = True + | otherwise = False isDataTyCon :: TyCon -> Bool -- ^ Returns @True@ for data types that are /definitely/ represented by @@ -2117,7 +1992,8 @@ isDataTyCon :: TyCon -> Bool -- -- NB: for a data type family, only the /instance/ 'TyCon's -- get an info table. The family declaration 'TyCon' does not -isDataTyCon (AlgTyCon {algTcRhs = rhs}) +isDataTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = rhs} <- details = case rhs of TupleTyCon { tup_sort = sort } -> isBoxed (tupleSortBoxity sort) @@ -2133,9 +2009,10 @@ isDataTyCon _ = False -- | Was this 'TyCon' declared as "type data"? -- See Note [Type data declarations] in GHC.Rename.Module. isTypeDataTyCon :: TyCon -> Bool -isTypeDataTyCon (AlgTyCon {algTcRhs = DataTyCon {is_type_data = type_data }}) - = type_data -isTypeDataTyCon _ = False +isTypeDataTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = DataTyCon {is_type_data = type_data }} <- details + = type_data + | otherwise = False -- | 'isInjectiveTyCon' is true of 'TyCon's for which this property holds -- (where r is the role passed in): @@ -2143,31 +2020,39 @@ isTypeDataTyCon _ = False -- (where r1, r2, and r3, are the roles given by tyConRolesX tc r) -- See also Note [Decomposing TyConApp equalities] in "GHC.Tc.Solver.Canonical" isInjectiveTyCon :: TyCon -> Role -> Bool -isInjectiveTyCon _ Phantom = True -- Vacuously; (t1 ~P t2) holes for all t1, t2! - -isInjectiveTyCon (AlgTyCon {}) Nominal = True -isInjectiveTyCon (AlgTyCon {algTcRhs = rhs}) Representational - = isGenInjAlgRhs rhs -isInjectiveTyCon (SynonymTyCon {}) _ = False -isInjectiveTyCon (FamilyTyCon { famTcFlav = DataFamilyTyCon _ }) - Nominal = True -isInjectiveTyCon (FamilyTyCon { famTcInj = Injective inj }) Nominal = and inj -isInjectiveTyCon (FamilyTyCon {}) _ = False -isInjectiveTyCon (PrimTyCon {}) _ = True -isInjectiveTyCon (PromotedDataCon {}) _ = True -isInjectiveTyCon (TcTyCon {}) _ = True +isInjectiveTyCon (TyCon { tyConDetails = details }) role + = go details role + where + go _ Phantom = True -- Vacuously; (t1 ~P t2) holes for all t1, t2! + go (AlgTyCon {}) Nominal = True + go (AlgTyCon {algTcRhs = rhs}) Representational + = isGenInjAlgRhs rhs + go (SynonymTyCon {}) _ = False + go (FamilyTyCon { famTcFlav = DataFamilyTyCon _ }) + Nominal = True + go (FamilyTyCon { famTcInj = Injective inj }) Nominal = and inj + go (FamilyTyCon {}) _ = False + go (PrimTyCon {}) _ = True + go (PromotedDataCon {}) _ = True + go (TcTyCon {}) _ = True + -- Reply True for TcTyCon to minimise knock on type errors -- See Note [How TcTyCons work] item (1) in GHC.Tc.TyCl + -- | 'isGenerativeTyCon' is true of 'TyCon's for which this property holds -- (where r is the role passed in): -- If (T tys ~r t), then (t's head ~r T). -- See also Note [Decomposing TyConApp equalities] in "GHC.Tc.Solver.Canonical" isGenerativeTyCon :: TyCon -> Role -> Bool -isGenerativeTyCon (FamilyTyCon { famTcFlav = DataFamilyTyCon _ }) Nominal = True -isGenerativeTyCon (FamilyTyCon {}) _ = False - -- in all other cases, injectivity implies generativity -isGenerativeTyCon tc r = isInjectiveTyCon tc r +isGenerativeTyCon tc@(TyCon { tyConDetails = details }) role + = go role details + where + go Nominal (FamilyTyCon { famTcFlav = DataFamilyTyCon _ }) = True + go _ (FamilyTyCon {}) = False + + -- In all other cases, injectivity implies generativity + go r _ = isInjectiveTyCon tc r -- | Is this an 'AlgTyConRhs' of a 'TyCon' that is generative and injective -- with respect to representational equality? @@ -2180,42 +2065,46 @@ isGenInjAlgRhs (NewTyCon {}) = False -- | Is this 'TyCon' that for a @newtype@ isNewTyCon :: TyCon -> Bool -isNewTyCon (AlgTyCon {algTcRhs = NewTyCon {}}) = True -isNewTyCon _ = False +isNewTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon {}} <- details = True + | otherwise = False -- | Take a 'TyCon' apart into the 'TyVar's it scopes over, the 'Type' it -- expands into, and (possibly) a coercion from the representation type to the -- @newtype at . -- Returns @Nothing@ if this is not possible. unwrapNewTyCon_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched) -unwrapNewTyCon_maybe (AlgTyCon { tyConTyVars = tvs, - algTcRhs = NewTyCon { nt_co = co, - nt_rhs = rhs }}) - = Just (tvs, rhs, co) -unwrapNewTyCon_maybe _ = Nothing +unwrapNewTyCon_maybe (TyCon { tyConTyVars = tvs, tyConDetails = details }) + | AlgTyCon { algTcRhs = NewTyCon { nt_co = co, nt_rhs = rhs }} <- details + = Just (tvs, rhs, co) + | otherwise = Nothing unwrapNewTyConEtad_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched) -unwrapNewTyConEtad_maybe (AlgTyCon { algTcRhs = NewTyCon { nt_co = co, - nt_etad_rhs = (tvs,rhs) }}) - = Just (tvs, rhs, co) -unwrapNewTyConEtad_maybe _ = Nothing +unwrapNewTyConEtad_maybe (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = NewTyCon { nt_co = co + , nt_etad_rhs = (tvs,rhs) }} <- details + = Just (tvs, rhs, co) + | otherwise = Nothing -- | Is this a 'TyCon' representing a regular H98 type synonym (@type@)? {-# INLINE isTypeSynonymTyCon #-} -- See Note [Inlining coreView] in GHC.Core.Type isTypeSynonymTyCon :: TyCon -> Bool -isTypeSynonymTyCon (SynonymTyCon {}) = True -isTypeSynonymTyCon _ = False +isTypeSynonymTyCon (TyCon { tyConDetails = details }) + | SynonymTyCon {} <- details = True + | otherwise = False isTauTyCon :: TyCon -> Bool -isTauTyCon (SynonymTyCon { synIsTau = is_tau }) = is_tau -isTauTyCon _ = True +isTauTyCon (TyCon { tyConDetails = details }) + | SynonymTyCon { synIsTau = is_tau } <- details = is_tau + | otherwise = True -- | Is this tycon neither a type family nor a synonym that expands -- to a type family? isFamFreeTyCon :: TyCon -> Bool -isFamFreeTyCon (SynonymTyCon { synIsFamFree = fam_free }) = fam_free -isFamFreeTyCon (FamilyTyCon { famTcFlav = flav }) = isDataFamFlav flav -isFamFreeTyCon _ = True +isFamFreeTyCon (TyCon { tyConDetails = details }) + | SynonymTyCon { synIsFamFree = fam_free } <- details = fam_free + | FamilyTyCon { famTcFlav = flav } <- details = isDataFamFlav flav + | otherwise = True -- | Is this a forgetful type synonym? If this is a type synonym whose -- RHS does not mention one (or more) of its bound variables, returns @@ -2223,8 +2112,9 @@ isFamFreeTyCon _ = True -- True may not mean anything, as the test to set this flag is -- conservative. isForgetfulSynTyCon :: TyCon -> Bool -isForgetfulSynTyCon (SynonymTyCon { synIsForgetful = forget }) = forget -isForgetfulSynTyCon _ = False +isForgetfulSynTyCon (TyCon { tyConDetails = details }) + | SynonymTyCon { synIsForgetful = forget } <- details = forget + | otherwise = False -- As for newtypes, it is in some contexts important to distinguish between -- closed synonyms and synonym families, as synonym families have no unique @@ -2245,71 +2135,86 @@ tyConMustBeSaturated = tcFlavourMustBeSaturated . tyConFlavour -- | Is this an algebraic 'TyCon' declared with the GADT syntax? isGadtSyntaxTyCon :: TyCon -> Bool -isGadtSyntaxTyCon (AlgTyCon { algTcGadtSyntax = res }) = res -isGadtSyntaxTyCon _ = False +isGadtSyntaxTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcGadtSyntax = res } <- details = res + | otherwise = False -- | Is this an algebraic 'TyCon' which is just an enumeration of values? isEnumerationTyCon :: TyCon -> Bool -- See Note [Enumeration types] in GHC.Core.TyCon -isEnumerationTyCon (AlgTyCon { tyConArity = arity, algTcRhs = rhs }) +isEnumerationTyCon (TyCon { tyConArity = arity, tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details = case rhs of DataTyCon { is_enum = res } -> res TupleTyCon {} -> arity == 0 _ -> False -isEnumerationTyCon _ = False + | otherwise = False -- | Is this a 'TyCon', synonym or otherwise, that defines a family? isFamilyTyCon :: TyCon -> Bool -isFamilyTyCon (FamilyTyCon {}) = True -isFamilyTyCon _ = False +isFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon {} <- details = True + | otherwise = False -- | Is this a 'TyCon', synonym or otherwise, that defines a family with -- instances? isOpenFamilyTyCon :: TyCon -> Bool -isOpenFamilyTyCon (FamilyTyCon {famTcFlav = flav }) - | OpenSynFamilyTyCon <- flav = True - | DataFamilyTyCon {} <- flav = True -isOpenFamilyTyCon _ = False +isOpenFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = flav } <- details + = case flav of + OpenSynFamilyTyCon -> True + DataFamilyTyCon {} -> True + _ -> False + | otherwise = False -- | Is this a synonym 'TyCon' that can have may have further instances appear? isTypeFamilyTyCon :: TyCon -> Bool -isTypeFamilyTyCon (FamilyTyCon { famTcFlav = flav }) = not (isDataFamFlav flav) -isTypeFamilyTyCon _ = False +isTypeFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon { famTcFlav = flav } <- details = not (isDataFamFlav flav) + | otherwise = False -- | Is this a synonym 'TyCon' that can have may have further instances appear? isDataFamilyTyCon :: TyCon -> Bool -isDataFamilyTyCon (FamilyTyCon { famTcFlav = flav }) = isDataFamFlav flav -isDataFamilyTyCon _ = False +isDataFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon { famTcFlav = flav } <- details = isDataFamFlav flav + | otherwise = False -- | Is this an open type family TyCon? isOpenTypeFamilyTyCon :: TyCon -> Bool -isOpenTypeFamilyTyCon (FamilyTyCon {famTcFlav = OpenSynFamilyTyCon }) = True -isOpenTypeFamilyTyCon _ = False +isOpenTypeFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = OpenSynFamilyTyCon } <- details = True + | otherwise = False -- | Is this a non-empty closed type family? Returns 'Nothing' for -- abstract or empty closed families. isClosedSynFamilyTyConWithAxiom_maybe :: TyCon -> Maybe (CoAxiom Branched) -isClosedSynFamilyTyConWithAxiom_maybe - (FamilyTyCon {famTcFlav = ClosedSynFamilyTyCon mb}) = mb -isClosedSynFamilyTyConWithAxiom_maybe _ = Nothing +isClosedSynFamilyTyConWithAxiom_maybe (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = ClosedSynFamilyTyCon mb} <- details = mb + | otherwise = Nothing + +isBuiltInSynFamTyCon_maybe :: TyCon -> Maybe BuiltInSynFamily +isBuiltInSynFamTyCon_maybe (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = BuiltInSynFamTyCon ops } <- details = Just ops + | otherwise = Nothing + +-- | Extract type variable naming the result of injective type family +tyConFamilyResVar_maybe :: TyCon -> Maybe Name +tyConFamilyResVar_maybe (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcResVar = res} <- details = res + | otherwise = Nothing -- | @'tyConInjectivityInfo' tc@ returns @'Injective' is@ if @tc@ is an -- injective tycon (where @is@ states for which 'tyConBinders' @tc@ is -- injective), or 'NotInjective' otherwise. tyConInjectivityInfo :: TyCon -> Injectivity -tyConInjectivityInfo tc - | FamilyTyCon { famTcInj = inj } <- tc +tyConInjectivityInfo tc@(TyCon { tyConDetails = details }) + | FamilyTyCon { famTcInj = inj } <- details = inj | isInjectiveTyCon tc Nominal = Injective (replicate (tyConArity tc) True) | otherwise = NotInjective -isBuiltInSynFamTyCon_maybe :: TyCon -> Maybe BuiltInSynFamily -isBuiltInSynFamTyCon_maybe - (FamilyTyCon {famTcFlav = BuiltInSynFamTyCon ops }) = Just ops -isBuiltInSynFamTyCon_maybe _ = Nothing - isDataFamFlav :: FamTyConFlav -> Bool isDataFamFlav (DataFamilyTyCon {}) = True -- Data family isDataFamFlav _ = False -- Type synonym family @@ -2338,39 +2243,50 @@ isTupleTyCon :: TyCon -> Bool -- 'isTupleTyCon', because they are built as 'AlgTyCons'. However they -- get spat into the interface file as tuple tycons, so I don't think -- it matters. -isTupleTyCon (AlgTyCon { algTcRhs = TupleTyCon {} }) = True -isTupleTyCon _ = False +isTupleTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = TupleTyCon {} } <- details = True + | otherwise = False tyConTuple_maybe :: TyCon -> Maybe TupleSort -tyConTuple_maybe (AlgTyCon { algTcRhs = rhs }) - | TupleTyCon { tup_sort = sort} <- rhs = Just sort -tyConTuple_maybe _ = Nothing +tyConTuple_maybe (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + , TupleTyCon { tup_sort = sort} <- rhs = Just sort + | otherwise = Nothing -- | Is this the 'TyCon' for an unboxed tuple? isUnboxedTupleTyCon :: TyCon -> Bool -isUnboxedTupleTyCon (AlgTyCon { algTcRhs = rhs }) - | TupleTyCon { tup_sort = sort } <- rhs - = not (isBoxed (tupleSortBoxity sort)) -isUnboxedTupleTyCon _ = False +isUnboxedTupleTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + , TupleTyCon { tup_sort = sort } <- rhs + = not (isBoxed (tupleSortBoxity sort)) + | otherwise = False -- | Is this the 'TyCon' for a boxed tuple? isBoxedTupleTyCon :: TyCon -> Bool -isBoxedTupleTyCon (AlgTyCon { algTcRhs = rhs }) - | TupleTyCon { tup_sort = sort } <- rhs - = isBoxed (tupleSortBoxity sort) -isBoxedTupleTyCon _ = False +isBoxedTupleTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + , TupleTyCon { tup_sort = sort } <- rhs + = isBoxed (tupleSortBoxity sort) + | otherwise = False -- | Is this the 'TyCon' for an unboxed sum? isUnboxedSumTyCon :: TyCon -> Bool -isUnboxedSumTyCon (AlgTyCon { algTcRhs = rhs }) - | SumTyCon {} <- rhs - = True -isUnboxedSumTyCon _ = False +isUnboxedSumTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + , SumTyCon {} <- rhs + = True + | otherwise = False isLiftedAlgTyCon :: TyCon -> Bool -isLiftedAlgTyCon (AlgTyCon { tyConResKind = res_kind }) - = isLiftedTypeKind res_kind -isLiftedAlgTyCon _ = False +isLiftedAlgTyCon (TyCon { tyConResKind = res_kind, tyConDetails = details }) + | AlgTyCon {} <- details = isLiftedTypeKind res_kind + | otherwise = False + +-- | Retrieves the promoted DataCon if this is a PromotedDataCon; +isPromotedDataCon_maybe :: TyCon -> Maybe DataCon +isPromotedDataCon_maybe (TyCon { tyConDetails = details }) + | PromotedDataCon { dataCon = dc } <- details = Just dc + | otherwise = Nothing -- | Is this the 'TyCon' for a /promoted/ tuple? isPromotedTupleTyCon :: TyCon -> Bool @@ -2381,8 +2297,9 @@ isPromotedTupleTyCon tyCon -- | Is this a PromotedDataCon? isPromotedDataCon :: TyCon -> Bool -isPromotedDataCon (PromotedDataCon {}) = True -isPromotedDataCon _ = False +isPromotedDataCon (TyCon { tyConDetails = details }) + | PromotedDataCon {} <- details = True + | otherwise = False -- | This function identifies PromotedDataCon's from data constructors in -- `data T = K1 | K2`, promoted by -XDataKinds. These type constructors @@ -2393,14 +2310,10 @@ isPromotedDataCon _ = False -- represented with their original undecorated names. -- See Note [Type data declarations] in GHC.Rename.Module isDataKindsPromotedDataCon :: TyCon -> Bool -isDataKindsPromotedDataCon (PromotedDataCon { dataCon = dc }) - = not (isTypeDataCon dc) -isDataKindsPromotedDataCon _ = False - --- | Retrieves the promoted DataCon if this is a PromotedDataCon; -isPromotedDataCon_maybe :: TyCon -> Maybe DataCon -isPromotedDataCon_maybe (PromotedDataCon { dataCon = dc }) = Just dc -isPromotedDataCon_maybe _ = Nothing +isDataKindsPromotedDataCon (TyCon { tyConDetails = details }) + | PromotedDataCon { dataCon = dc } <- details + = not (isTypeDataCon dc) + | otherwise = False -- | Is this tycon really meant for use at the kind level? That is, -- should it be permitted without -XDataKinds? @@ -2437,36 +2350,22 @@ isLiftedTypeKindTyConName = (`hasKey` liftedTypeKindTyConKey) -- (namely: boxed and unboxed tuples are wired-in and implicit, -- but constraint tuples are not) isImplicitTyCon :: TyCon -> Bool -isImplicitTyCon (PrimTyCon {}) = True -isImplicitTyCon (PromotedDataCon {}) = True -isImplicitTyCon (AlgTyCon { algTcRhs = rhs, tyConName = name }) - | TupleTyCon {} <- rhs = isWiredInName name - | SumTyCon {} <- rhs = True - | otherwise = False -isImplicitTyCon (FamilyTyCon { famTcParent = parent }) = isJust parent -isImplicitTyCon (SynonymTyCon {}) = False -isImplicitTyCon (TcTyCon {}) = False +isImplicitTyCon (TyCon { tyConName = name, tyConDetails = details }) = go details + where + go (PrimTyCon {}) = True + go (PromotedDataCon {}) = True + go (SynonymTyCon {}) = False + go (TcTyCon {}) = False + go (FamilyTyCon { famTcParent = parent }) = isJust parent + go (AlgTyCon { algTcRhs = rhs }) + | TupleTyCon {} <- rhs = isWiredInName name + | SumTyCon {} <- rhs = True + | otherwise = False tyConCType_maybe :: TyCon -> Maybe CType -tyConCType_maybe tc@(AlgTyCon {}) = tyConCType tc -tyConCType_maybe _ = Nothing - --- | Is this a TcTyCon? (That is, one only used during type-checking?) -isTcTyCon :: TyCon -> Bool -isTcTyCon (TcTyCon {}) = True -isTcTyCon _ = False - -setTcTyConKind :: TyCon -> Kind -> TyCon --- Update the Kind of a TcTyCon --- The new kind is always a zonked version of its previous --- kind, so we don't need to update any other fields. --- See Note [The Purely Kinded Type Invariant (PKTI)] in GHC.Tc.Gen.HsType -setTcTyConKind tc@(TcTyCon {}) kind = let tc' = tc { tyConKind = kind - , tyConNullaryTy = mkNakedTyConTy tc' - -- see Note [Sharing nullary TyConApps] - } - in tc' -setTcTyConKind tc _ = pprPanic "setTcTyConKind" (ppr tc) +tyConCType_maybe (TyCon { tyConDetails = details }) + | AlgTyCon { tyConCType = mb_ctype} <- details = mb_ctype + | otherwise = Nothing -- | Does this 'TyCon' have a syntactically fixed RuntimeRep when fully applied, -- as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete? @@ -2476,31 +2375,33 @@ setTcTyConKind tc _ = pprPanic "setTcTyConKind" (ppr tc) -- -- See Note [Representation-polymorphic TyCons] tcHasFixedRuntimeRep :: TyCon -> Bool -tcHasFixedRuntimeRep (AlgTyCon { algTcRhs = rhs }) = case rhs of - AbstractTyCon {} -> False - -- An abstract TyCon might not have a fixed runtime representation. - -- Note that this is an entirely different matter from the concreteness - -- of the 'TyCon', in the sense of 'isConcreteTyCon'. +tcHasFixedRuntimeRep tc@(TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + = case rhs of + AbstractTyCon {} -> False + -- An abstract TyCon might not have a fixed runtime representation. + -- Note that this is an entirely different matter from the concreteness + -- of the 'TyCon', in the sense of 'isConcreteTyCon'. - DataTyCon { data_fixed_lev = fixed_lev } -> fixed_lev - -- A datatype might not have a fixed levity with UnliftedDatatypes (#20423). - -- NB: the current representation-polymorphism checks require that - -- the representation be fully-known, including levity variables. - -- This might be relaxed in the future (#15532). + DataTyCon { data_fixed_lev = fixed_lev } -> fixed_lev + -- A datatype might not have a fixed levity with UnliftedDatatypes (#20423). + -- NB: the current representation-polymorphism checks require that + -- the representation be fully-known, including levity variables. + -- This might be relaxed in the future (#15532). - TupleTyCon { tup_sort = tuple_sort } -> isBoxed (tupleSortBoxity tuple_sort) + TupleTyCon { tup_sort = tuple_sort } -> isBoxed (tupleSortBoxity tuple_sort) - SumTyCon {} -> False -- only unboxed sums here + SumTyCon {} -> False -- only unboxed sums here - NewTyCon { nt_fixed_rep = fixed_rep } -> fixed_rep - -- A newtype might not have a fixed runtime representation - -- with UnliftedNewtypes (#17360) + NewTyCon { nt_fixed_rep = fixed_rep } -> fixed_rep + -- A newtype might not have a fixed runtime representation + -- with UnliftedNewtypes (#17360) -tcHasFixedRuntimeRep SynonymTyCon{} = False -- conservative choice -tcHasFixedRuntimeRep FamilyTyCon{} = False -tcHasFixedRuntimeRep PrimTyCon{} = True -tcHasFixedRuntimeRep TcTyCon{} = False -tcHasFixedRuntimeRep tc at PromotedDataCon{} = pprPanic "tcHasFixedRuntimeRep datacon" (ppr tc) + | SynonymTyCon {} <- details = False -- conservative choice + | FamilyTyCon{} <- details = False + | PrimTyCon{} <- details = True + | TcTyCon{} <- details = False + | PromotedDataCon{} <- details = pprPanic "tcHasFixedRuntimeRep datacon" (ppr tc) -- | Is this 'TyCon' concrete (i.e. not a synonym/type family)? -- @@ -2526,6 +2427,40 @@ isConcreteTyConFlavour = \case BuiltInTypeFlavour -> True PromotedDataConFlavour -> True +{- +----------------------------------------------- +-- TcTyCon +----------------------------------------------- +-} + +-- | Is this a TcTyCon? (That is, one only used during type-checking?) +isTcTyCon :: TyCon -> Bool +isTcTyCon (TyCon { tyConDetails = details }) + | TcTyCon {} <- details = True + | otherwise = False + +setTcTyConKind :: TyCon -> Kind -> TyCon +-- Update the Kind of a TcTyCon +-- The new kind is always a zonked version of its previous +-- kind, so we don't need to update any other fields. +-- See Note [The Purely Kinded Type Invariant (PKTI)] in GHC.Tc.Gen.HsType +setTcTyConKind tc kind + = assert (isMonoTcTyCon tc) $ + let tc' = tc { tyConKind = kind + , tyConNullaryTy = mkNakedTyConTy tc' } + -- See Note [Sharing nullary TyConApps] + in tc' + +isMonoTcTyCon :: TyCon -> Bool +isMonoTcTyCon (TyCon { tyConDetails = details }) + | TcTyCon { tctc_is_poly = is_poly } <- details = not is_poly + | otherwise = False + +tcTyConScopedTyVars :: TyCon -> [(Name,TcTyVar)] +tcTyConScopedTyVars tc@(TyCon { tyConDetails = details }) + | TcTyCon { tctc_scoped_tvs = scoped_tvs } <- details = scoped_tvs + | otherwise = pprPanic "tcTyConScopedTyVars" (ppr tc) + {- ----------------------------------------------- -- Expand type-constructor applications @@ -2546,8 +2481,9 @@ expandSynTyCon_maybe -- ^ Expand a type synonym application -- Return Nothing if the TyCon is not a synonym, -- or if not enough arguments are supplied -expandSynTyCon_maybe tc tys - | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc +expandSynTyCon_maybe (TyCon { tyConTyVars = tvs, tyConArity = arity + , tyConDetails = details }) tys + | SynonymTyCon { synTcRhs = rhs } <- details = if arity == 0 then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of @@ -2567,17 +2503,17 @@ expandSynTyCon_maybe tc tys -- exported tycon can have a pattern synonym bundled with it, e.g., -- module Foo (TyCon(.., PatSyn)) where isTyConWithSrcDataCons :: TyCon -> Bool -isTyConWithSrcDataCons (AlgTyCon { algTcRhs = rhs, algTcFlavour = parent }) = - case rhs of - DataTyCon {} -> isSrcParent - NewTyCon {} -> isSrcParent - TupleTyCon {} -> isSrcParent - _ -> False - where - isSrcParent = isNoParent parent -isTyConWithSrcDataCons (FamilyTyCon { famTcFlav = DataFamilyTyCon {} }) - = True -- #14058 -isTyConWithSrcDataCons _ = False +isTyConWithSrcDataCons (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs, algTcFlavour = parent } <- details + , let isSrcParent = isNoParent parent + = case rhs of + DataTyCon {} -> isSrcParent + NewTyCon {} -> isSrcParent + TupleTyCon {} -> isSrcParent + _ -> False + | FamilyTyCon { famTcFlav = DataFamilyTyCon {} } <- details + = True -- #14058 + | otherwise = False -- | As 'tyConDataCons_maybe', but returns the empty list of constructors if no @@ -2591,7 +2527,8 @@ tyConDataCons tycon = tyConDataCons_maybe tycon `orElse` [] -- is the sort that can have any constructors (note: this does not include -- abstract algebraic types) tyConDataCons_maybe :: TyCon -> Maybe [DataCon] -tyConDataCons_maybe (AlgTyCon {algTcRhs = rhs}) +tyConDataCons_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = rhs} <- details = case rhs of DataTyCon { data_cons = cons } -> Just cons NewTyCon { data_con = con } -> Just [con] @@ -2605,13 +2542,14 @@ tyConDataCons_maybe _ = Nothing -- is returned. If the 'TyCon' has more than one constructor, or represents a -- primitive or function type constructor then @Nothing@ is returned. tyConSingleDataCon_maybe :: TyCon -> Maybe DataCon -tyConSingleDataCon_maybe (AlgTyCon { algTcRhs = rhs }) +tyConSingleDataCon_maybe (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details = case rhs of DataTyCon { data_cons = [c] } -> Just c TupleTyCon { data_con = c } -> Just c NewTyCon { data_con = c } -> Just c _ -> Nothing -tyConSingleDataCon_maybe _ = Nothing + | otherwise = Nothing -- | Like 'tyConSingleDataCon_maybe', but panics if 'Nothing'. tyConSingleDataCon :: TyCon -> DataCon @@ -2640,68 +2578,56 @@ tyConAlgDataCons_maybe tycon -- | Determine the number of value constructors a 'TyCon' has. Panics if the -- 'TyCon' is not algebraic or a tuple tyConFamilySize :: TyCon -> Int -tyConFamilySize tc@(AlgTyCon { algTcRhs = rhs }) +tyConFamilySize tc@(TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details = case rhs of DataTyCon { data_cons_size = size } -> size NewTyCon {} -> 1 TupleTyCon {} -> 1 SumTyCon { data_cons_size = size } -> size _ -> pprPanic "tyConFamilySize 1" (ppr tc) -tyConFamilySize tc = pprPanic "tyConFamilySize 2" (ppr tc) + | otherwise = pprPanic "tyConFamilySize 2" (ppr tc) -- | Extract an 'AlgTyConRhs' with information about data constructors from an -- algebraic or tuple 'TyCon'. Panics for any other sort of 'TyCon' algTyConRhs :: TyCon -> AlgTyConRhs -algTyConRhs (AlgTyCon {algTcRhs = rhs}) = rhs -algTyConRhs other = pprPanic "algTyConRhs" (ppr other) - --- | Extract type variable naming the result of injective type family -tyConFamilyResVar_maybe :: TyCon -> Maybe Name -tyConFamilyResVar_maybe (FamilyTyCon {famTcResVar = res}) = res -tyConFamilyResVar_maybe _ = Nothing - --- | Get the list of roles for the type parameters of a TyCon -tyConRoles :: TyCon -> [Role] --- See also Note [TyCon Role signatures] -tyConRoles tc - = case tc of - { AlgTyCon { tcRoles = roles } -> roles - ; SynonymTyCon { tcRoles = roles } -> roles - ; FamilyTyCon {} -> const_role Nominal - ; PrimTyCon { tcRoles = roles } -> roles - ; PromotedDataCon { tcRoles = roles } -> roles - ; TcTyCon {} -> const_role Nominal - } - where - const_role r = replicate (tyConArity tc) r +algTyConRhs tc@(TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = rhs} <- details = rhs + | otherwise = pprPanic "algTyConRhs" (ppr tc) -- | Extract the bound type variables and type expansion of a type synonym -- 'TyCon'. Panics if the 'TyCon' is not a synonym newTyConRhs :: TyCon -> ([TyVar], Type) -newTyConRhs (AlgTyCon {tyConTyVars = tvs, algTcRhs = NewTyCon { nt_rhs = rhs }}) - = (tvs, rhs) -newTyConRhs tycon = pprPanic "newTyConRhs" (ppr tycon) +newTyConRhs tc@(TyCon { tyConTyVars = tvs, tyConDetails = details }) + | AlgTyCon { algTcRhs = NewTyCon { nt_rhs = rhs }} <- details + = (tvs, rhs) + | otherwise + = pprPanic "newTyConRhs" (ppr tc) -- | The number of type parameters that need to be passed to a newtype to -- resolve it. May be less than in the definition if it can be eta-contracted. newTyConEtadArity :: TyCon -> Int -newTyConEtadArity (AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }}) - = length (fst tvs_rhs) -newTyConEtadArity tycon = pprPanic "newTyConEtadArity" (ppr tycon) +newTyConEtadArity tc@(TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }} <- details + = length (fst tvs_rhs) + | otherwise + = pprPanic "newTyConEtadArity" (ppr tc) -- | Extract the bound type variables and type expansion of an eta-contracted -- type synonym 'TyCon'. Panics if the 'TyCon' is not a synonym newTyConEtadRhs :: TyCon -> ([TyVar], Type) -newTyConEtadRhs (AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }}) = tvs_rhs -newTyConEtadRhs tycon = pprPanic "newTyConEtadRhs" (ppr tycon) +newTyConEtadRhs tc@(TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }} <- details = tvs_rhs + | otherwise = pprPanic "newTyConEtadRhs" (ppr tc) -- | Extracts the @newtype@ coercion from such a 'TyCon', which can be used to -- construct something with the @newtype at s type from its representation type -- (right hand side). If the supplied 'TyCon' is not a @newtype@, returns -- @Nothing@ newTyConCo_maybe :: TyCon -> Maybe (CoAxiom Unbranched) -newTyConCo_maybe (AlgTyCon {algTcRhs = NewTyCon { nt_co = co }}) = Just co -newTyConCo_maybe _ = Nothing +newTyConCo_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon { nt_co = co }} <- details = Just co + | otherwise = Nothing newTyConCo :: TyCon -> CoAxiom Unbranched newTyConCo tc = case newTyConCo_maybe tc of @@ -2709,83 +2635,93 @@ newTyConCo tc = case newTyConCo_maybe tc of Nothing -> pprPanic "newTyConCo" (ppr tc) newTyConDataCon_maybe :: TyCon -> Maybe DataCon -newTyConDataCon_maybe (AlgTyCon {algTcRhs = NewTyCon { data_con = con }}) = Just con -newTyConDataCon_maybe _ = Nothing +newTyConDataCon_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon { data_con = con }} <- details = Just con + | otherwise = Nothing -- | Find the \"stupid theta\" of the 'TyCon'. A \"stupid theta\" is the context -- to the left of an algebraic type declaration, e.g. @Eq a@ in the declaration -- @data Eq a => T a ... at . See @Note [The stupid context]@ in "GHC.Core.DataCon". tyConStupidTheta :: TyCon -> [PredType] -tyConStupidTheta (AlgTyCon {algTcStupidTheta = stupid}) = stupid -tyConStupidTheta (PrimTyCon {}) = [] -tyConStupidTheta tycon = pprPanic "tyConStupidTheta" (ppr tycon) +tyConStupidTheta tc@(TyCon { tyConDetails = details }) + | AlgTyCon {algTcStupidTheta = stupid} <- details = stupid + | PrimTyCon {} <- details = [] + | otherwise = pprPanic "tyConStupidTheta" (ppr tc) -- | Extract the 'TyVar's bound by a vanilla type synonym -- and the corresponding (unsubstituted) right hand side. synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type) -synTyConDefn_maybe (SynonymTyCon {tyConTyVars = tyvars, synTcRhs = ty}) +synTyConDefn_maybe (TyCon { tyConTyVars = tyvars, tyConDetails = details }) + | SynonymTyCon {synTcRhs = ty} <- details = Just (tyvars, ty) -synTyConDefn_maybe _ = Nothing + | otherwise + = Nothing -- | Extract the information pertaining to the right hand side of a type synonym -- (@type@) declaration. synTyConRhs_maybe :: TyCon -> Maybe Type -synTyConRhs_maybe (SynonymTyCon {synTcRhs = rhs}) = Just rhs -synTyConRhs_maybe _ = Nothing +synTyConRhs_maybe (TyCon { tyConDetails = details }) + | SynonymTyCon {synTcRhs = rhs} <- details = Just rhs + | otherwise = Nothing -- | Extract the flavour of a type family (with all the extra information that -- it carries) famTyConFlav_maybe :: TyCon -> Maybe FamTyConFlav -famTyConFlav_maybe (FamilyTyCon {famTcFlav = flav}) = Just flav -famTyConFlav_maybe _ = Nothing +famTyConFlav_maybe (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = flav} <- details = Just flav + | otherwise = Nothing -- | Is this 'TyCon' that for a class instance? isClassTyCon :: TyCon -> Bool -isClassTyCon (AlgTyCon {algTcFlavour = ClassTyCon {}}) = True -isClassTyCon _ = False +isClassTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = ClassTyCon {}} <- details = True + | otherwise = False -- | If this 'TyCon' is that for a class instance, return the class it is for. -- Otherwise returns @Nothing@ tyConClass_maybe :: TyCon -> Maybe Class -tyConClass_maybe (AlgTyCon {algTcFlavour = ClassTyCon clas _}) = Just clas -tyConClass_maybe _ = Nothing +tyConClass_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = ClassTyCon clas _} <- details = Just clas + | otherwise = Nothing -- | Return the associated types of the 'TyCon', if any tyConATs :: TyCon -> [TyCon] -tyConATs (AlgTyCon {algTcFlavour = ClassTyCon clas _}) = classATs clas -tyConATs _ = [] +tyConATs (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = ClassTyCon clas _} <- details = classATs clas + | otherwise = [] ---------------------------------------------------------------------------- -- | Is this 'TyCon' that for a data family instance? isFamInstTyCon :: TyCon -> Bool -isFamInstTyCon (AlgTyCon {algTcFlavour = DataFamInstTyCon {} }) - = True -isFamInstTyCon _ = False +isFamInstTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = DataFamInstTyCon {} } <- details = True + | otherwise = False tyConFamInstSig_maybe :: TyCon -> Maybe (TyCon, [Type], CoAxiom Unbranched) -tyConFamInstSig_maybe (AlgTyCon {algTcFlavour = DataFamInstTyCon ax f ts }) - = Just (f, ts, ax) -tyConFamInstSig_maybe _ = Nothing +tyConFamInstSig_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = DataFamInstTyCon ax f ts } <- details = Just (f, ts, ax) + | otherwise = Nothing -- | If this 'TyCon' is that of a data family instance, return the family in question -- and the instance types. Otherwise, return @Nothing@ tyConFamInst_maybe :: TyCon -> Maybe (TyCon, [Type]) -tyConFamInst_maybe (AlgTyCon {algTcFlavour = DataFamInstTyCon _ f ts }) - = Just (f, ts) -tyConFamInst_maybe _ = Nothing +tyConFamInst_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = DataFamInstTyCon _ f ts } <- details = Just (f, ts) + | otherwise = Nothing -- | If this 'TyCon' is that of a data family instance, return a 'TyCon' which -- represents a coercion identifying the representation type with the type -- instance family. Otherwise, return @Nothing@ tyConFamilyCoercion_maybe :: TyCon -> Maybe (CoAxiom Unbranched) -tyConFamilyCoercion_maybe (AlgTyCon {algTcFlavour = DataFamInstTyCon ax _ _ }) - = Just ax -tyConFamilyCoercion_maybe _ = Nothing +tyConFamilyCoercion_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = DataFamInstTyCon ax _ _ } <- details = Just ax + | otherwise = Nothing -- | Extract any 'RuntimeRepInfo' from this TyCon tyConPromDataConInfo :: TyCon -> PromDataConInfo -tyConPromDataConInfo (PromotedDataCon { promDcInfo = rri }) = rri -tyConPromDataConInfo _ = NoPromInfo +tyConPromDataConInfo (TyCon { tyConDetails = details }) + | PromotedDataCon { promDcInfo = rri } <- details = rri + | otherwise = NoPromInfo -- could panic in that second case. But Douglas Adams told me not to. {- @@ -2875,26 +2811,30 @@ instance Outputable TyConFlavour where go PromotedDataConFlavour = "promoted data constructor" tyConFlavour :: TyCon -> TyConFlavour -tyConFlavour (AlgTyCon { algTcFlavour = parent, algTcRhs = rhs }) - | ClassTyCon _ _ <- parent = ClassFlavour - | otherwise = case rhs of +tyConFlavour (TyCon { tyConDetails = details }) + | AlgTyCon { algTcFlavour = parent, algTcRhs = rhs } <- details + = case parent of + ClassTyCon {} -> ClassFlavour + _ -> case rhs of TupleTyCon { tup_sort = sort } -> TupleFlavour (tupleSortBoxity sort) SumTyCon {} -> SumFlavour DataTyCon {} -> DataTypeFlavour NewTyCon {} -> NewtypeFlavour AbstractTyCon {} -> AbstractTypeFlavour -tyConFlavour (FamilyTyCon { famTcFlav = flav, famTcParent = parent }) + + | FamilyTyCon { famTcFlav = flav, famTcParent = parent } <- details = case flav of DataFamilyTyCon{} -> DataFamilyFlavour parent OpenSynFamilyTyCon -> OpenTypeFamilyFlavour parent ClosedSynFamilyTyCon{} -> ClosedTypeFamilyFlavour AbstractClosedSynFamilyTyCon -> ClosedTypeFamilyFlavour BuiltInSynFamTyCon{} -> ClosedTypeFamilyFlavour -tyConFlavour (SynonymTyCon {}) = TypeSynonymFlavour -tyConFlavour (PrimTyCon {}) = BuiltInTypeFlavour -tyConFlavour (PromotedDataCon {}) = PromotedDataConFlavour -tyConFlavour (TcTyCon { tcTyConFlavour = flav }) = flav + + | SynonymTyCon {} <- details = TypeSynonymFlavour + | PrimTyCon {} <- details = BuiltInTypeFlavour + | PromotedDataCon {} <- details = PromotedDataConFlavour + | TcTyCon { tctc_flavour = flav } <-details = flav -- | Can this flavour of 'TyCon' appear unsaturated? tcFlavourMustBeSaturated :: TyConFlavour -> Bool ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -532,7 +532,7 @@ tyConToIfaceDecl env tycon , IfaceData { ifName = getName tycon, ifBinders = if_binders, ifResKind = if_res_kind, - ifCType = tyConCType tycon, + ifCType = tyConCType_maybe tycon, ifRoles = tyConRoles tycon, ifCtxt = tidyToIfaceContext tc_env1 (tyConStupidTheta tycon), ifCons = ifaceConDecls (algTyConRhs tycon), ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -2121,7 +2121,7 @@ reifyTyCon tc | isTypeFamilyTyCon tc = do { let tvs = tyConTyVars tc res_kind = tyConResKind tc - resVar = famTcResVar tc + resVar = tyConFamilyResVar_maybe tc ; kind' <- reifyKind res_kind ; let (resultSig, injectivity) = ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -5177,8 +5177,7 @@ addVDQNote :: TcTyCon -> TcM a -> TcM a -- See Note [Inferring visible dependent quantification] -- Only types without a signature (CUSK or SAK) here addVDQNote tycon thing_inside - | assertPpr (isTcTyCon tycon) (ppr tycon) $ - assertPpr (not (tcTyConIsPoly tycon)) (ppr tycon $$ ppr tc_kind) + | assertPpr (isMonoTcTyCon tycon) (ppr tycon $$ ppr tc_kind) has_vdq = addLandmarkErrCtxt vdq_warning thing_inside | otherwise ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -2484,9 +2484,9 @@ zonkTcTyCon :: TcTyCon -> TcM TcTyCon -- A non-poly TcTyCon may have unification -- variables that need zonking, but poly ones cannot zonkTcTyCon tc - | tcTyConIsPoly tc = return tc - | otherwise = do { tck' <- zonkTcType (tyConKind tc) + | isMonoTcTyCon tc = do { tck' <- zonkTcType (tyConKind tc) ; return (setTcTyConKind tc tck') } + | otherwise = return tc zonkTcTyVar :: TcTyVar -> TcM TcType -- Simply look through all Flexis ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 2ffde83344bab8ed0aee3e8ef46f43856c7ca6ef +Subproject commit edc72530978d8a9ec92f51d288484986ec0051e3 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce126993688e7ea803aee5b831655e318bde58d3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce126993688e7ea803aee5b831655e318bde58d3 You're receiving 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 Dec 2 06:23:09 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 02 Dec 2022 01:23:09 -0500 Subject: [Git][ghc/ghc][master] ApplicativeDo: Set pattern location before running exhaustiveness checker Message-ID: <638999cd5b2ef_17512e64b9d706665b9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 4 changed files: - compiler/GHC/HsToCore/Expr.hs - + testsuite/tests/ado/T22483.hs - + testsuite/tests/ado/T22483.stderr - testsuite/tests/ado/all.T Changes: ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -714,7 +714,8 @@ dsDo ctx stmts ; body' <- dsLExpr $ noLocA $ HsDo body_ty ctx (noLocA stmts) ; let match_args (pat, fail_op) (vs,body) - = do { var <- selectSimpleMatchVarL ManyTy pat + = putSrcSpanDs (getLocA pat) $ + do { var <- selectSimpleMatchVarL ManyTy pat ; match <- matchSinglePatVar var Nothing (StmtCtxt (HsDoStmt ctx)) pat body_ty (cantFailMatchResult body) ; match_code <- dsHandleMonadicFailure ctx pat match fail_op ===================================== testsuite/tests/ado/T22483.hs ===================================== @@ -0,0 +1,7 @@ +main = do + let x = () + res2 <- pure () + ~(Just res1) <- seq x (pure $ Nothing @()) + print res1 + print res2 + pure () ===================================== testsuite/tests/ado/T22483.stderr ===================================== @@ -0,0 +1,8 @@ + +T22483.hs:1:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: main :: IO () + +T22483.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns (in -Wall)] + Pattern match(es) are non-exhaustive + In a pattern binding: + Patterns of type ‘Maybe ()’ not matched: Nothing ===================================== testsuite/tests/ado/all.T ===================================== @@ -21,3 +21,4 @@ test('T16628', normal, compile_fail, ['']) test('T17835', normal, compile, ['']) test('T20540', normal, compile, ['']) test('T16135', when(compiler_debugged(),expect_broken(16135)), compile, ['']) +test('T22483', normal, compile, ['-Wall']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74c767df770766d8d52e87b9ff7da10f94620a91 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74c767df770766d8d52e87b9ff7da10f94620a91 You're receiving 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 Dec 2 12:41:49 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Fri, 02 Dec 2022 07:41:49 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/mark-fragile-tests Message-ID: <6389f28d368c8_17512e2338aa687282bb@gitlab.mail> Bryan R pushed new branch wip/mark-fragile-tests at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/mark-fragile-tests You're receiving 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 Dec 2 12:56:21 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Fri, 02 Dec 2022 07:56:21 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22492 Message-ID: <6389f5f58b434_17512e52be8738567@gitlab.mail> Ryan Scott pushed new branch wip/T22492 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22492 You're receiving 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 Dec 2 13:35:26 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 02 Dec 2022 08:35:26 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/fresh-or-reuse Message-ID: <6389ff1ee9821_17512e240afea074299f@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/fresh-or-reuse at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/fresh-or-reuse You're receiving 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 Dec 2 15:56:55 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 02 Dec 2022 10:56:55 -0500 Subject: [Git][ghc/ghc][wip/int-index/fresh-or-reuse] Refactor: FreshOrReuse instead of addTyClTyVarBinds Message-ID: <638a204710953_17512e2758a954774584@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/fresh-or-reuse at Glasgow Haskell Compiler / GHC Commits: a46f93f8 by Vladislav Zavialov at 2022-12-02T18:56:44+03:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - 1 changed file: - compiler/GHC/HsToCore/Quote.hs Changes: ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -461,7 +461,7 @@ repTyClD (L loc (FamDecl { tcdFam = fam })) = liftM Just $ repTyClD (L loc (SynDecl { tcdLName = tc, tcdTyVars = tvs, tcdRhs = rhs })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repSynDecl tc1 bndrs rhs ; return (Just (locA loc, dec)) } @@ -469,7 +469,7 @@ repTyClD (L loc (DataDecl { tcdLName = tc , tcdTyVars = tvs , tcdDataDefn = defn })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repDataDefn tc1 (Left bndrs) defn ; return (Just (locA loc, dec)) } @@ -478,7 +478,7 @@ repTyClD (L loc (ClassDecl { tcdCtxt = cxt, tcdLName = cls, tcdSigs = sigs, tcdMeths = meth_binds, tcdATs = ats, tcdATDefs = atds })) = do { cls1 <- lookupLOcc cls -- See Note [Binders and occurrences] - ; dec <- addQTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { cxt1 <- repLContext cxt -- See Note [Scoped type variables in quotes] ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs meth_binds @@ -549,14 +549,11 @@ repFamilyDecl decl@(L loc (FamilyDecl { fdInfo = info , fdResultSig = L _ resultSig , fdInjectivityAnn = injectivity })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; let mkHsQTvs :: [LHsTyVarBndr () GhcRn] -> LHsQTyVars GhcRn - mkHsQTvs tvs = HsQTvs { hsq_ext = [] - , hsq_explicit = tvs } - resTyVar = case resultSig of - TyVarSig _ bndr -> mkHsQTvs [bndr] - _ -> mkHsQTvs [] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> - addTyClTyVarBinds resTyVar $ \_ -> + ; let resTyVar = case resultSig of + TyVarSig _ bndr -> [hsLTyVarName bndr] + _ -> [] + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> + addSimpleTyVarBinds ReuseBoundNames resTyVar $ case info of ClosedTypeFamily Nothing -> notHandled (ThAbstractClosedTypeFamily decl) @@ -645,7 +642,7 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds , cid_datafam_insts = adts , cid_overlap_mode = overlap }) - = addSimpleTyVarBinds tvs $ + = addSimpleTyVarBinds FreshNamesOnly tvs $ -- We must bring the type variables into scope, so their -- occurrences don't fail, even though the binders don't -- appear in the resulting data structure @@ -672,7 +669,7 @@ repStandaloneDerivD :: LDerivDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat , deriv_type = ty })) = do { dec <- repDerivStrategy strat $ \strat' -> - addSimpleTyVarBinds tvs $ + addSimpleTyVarBinds FreshNamesOnly tvs $ do { cxt' <- repLContext cxt ; inst_ty' <- repLTy inst_ty ; repDeriv strat' cxt' inst_ty' } @@ -804,16 +801,17 @@ repDefD (L loc (DefaultDecl _ tys)) = do { tys1 <- repLTys tys repRuleD :: LRuleDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repRuleD (L loc (HsRule { rd_name = n , rd_act = act - , rd_tyvs = ty_bndrs + , rd_tyvs = m_ty_bndrs , rd_tmvs = tm_bndrs , rd_lhs = lhs , rd_rhs = rhs })) - = do { rule <- addHsTyVarBinds (fromMaybe [] ty_bndrs) $ \ ex_bndrs -> + = do { let ty_bndrs = fromMaybe [] m_ty_bndrs + ; rule <- addHsTyVarBinds FreshNamesOnly ty_bndrs $ \ ex_bndrs -> do { let tm_bndr_names = concatMap ruleBndrNames tm_bndrs ; ss <- mkGenSyms tm_bndr_names ; rule <- addBinds ss $ do { elt_ty <- wrapName tyVarBndrUnitTyConName - ; ty_bndrs' <- return $ case ty_bndrs of + ; ty_bndrs' <- return $ case m_ty_bndrs of Nothing -> coreNothing' (mkListTy elt_ty) Just _ -> coreJust' (mkListTy elt_ty) ex_bndrs ; tm_bndrs' <- repListM ruleBndrTyConName @@ -878,7 +876,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_ex_tvs = con_tvs , con_mb_cxt = mcxt , con_args = args })) - = addHsTyVarBinds con_tvs $ \ ex_bndrs -> + = addHsTyVarBinds FreshNamesOnly con_tvs $ \ ex_bndrs -> do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt @@ -1188,14 +1186,11 @@ addHsOuterFamEqnTyVarBinds outer_bndrs thing_inside = do elt_ty <- wrapName tyVarBndrUnitTyConName case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> - addTyClTyVarBinds (mk_qtvs imp_tvs []) $ \_th_exp_bndrs -> + addSimpleTyVarBinds ReuseBoundNames imp_tvs $ thing_inside $ coreNothingList elt_ty HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addTyClTyVarBinds (mk_qtvs [] exp_bndrs) $ \th_exp_bndrs -> + addHsTyVarBinds ReuseBoundNames exp_bndrs $ \th_exp_bndrs -> thing_inside $ coreJustList elt_ty th_exp_bndrs - where - mk_qtvs imp_tvs exp_tvs = HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs } addHsOuterSigTyVarBinds :: HsOuterSigTyVarBndrs GhcRn @@ -1204,9 +1199,9 @@ addHsOuterSigTyVarBinds :: addHsOuterSigTyVarBinds outer_bndrs thing_inside = case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> do th_nil <- coreListM tyVarBndrSpecTyConName [] - addSimpleTyVarBinds imp_tvs $ thing_inside th_nil + addSimpleTyVarBinds FreshNamesOnly imp_tvs $ thing_inside th_nil HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addHsTyVarBinds exp_bndrs thing_inside + addHsTyVarBinds FreshNamesOnly exp_bndrs thing_inside -- | If a type implicitly quantifies its outermost type variables, return -- 'True' if the list of implicitly bound type variables is empty. If a type @@ -1230,69 +1225,79 @@ nullOuterExplicit (HsOuterExplicit{hso_bndrs = exp_bndrs}) = null exp_bndrs nullOuterExplicit (HsOuterImplicit{}) = True -- Vacuously true, as there is no outermost explicit quantification -addSimpleTyVarBinds :: [Name] -- the binders to be added +-- Do we want to generate fresh names for type variables +-- or reuse the ones that are already in scope? +data FreshOrReuse + = FreshNamesOnly + -- FreshNamesOnly is the default strategy: generate fresh names for all type + -- variables, regardless of existing variables in the MetaEnv + | ReuseBoundNames + -- ReuseBoundNames is used for data/newtype declarations and type family + -- instances, so that the nested type variables work right: + -- + -- class C a where + -- type W a b + -- instance C (T a) where + -- type W (T a) b = blah + -- + -- The 'a' in the type instance is the one bound by the instance decl + -- + -- Test cases: TH_reifyExplicitForAllFams T9081 T9199 T10811 + +mkGenSyms' :: FreshOrReuse -> [Name] -> MetaM [GenSymBind] +mkGenSyms' FreshNamesOnly names = mkGenSyms names +mkGenSyms' ReuseBoundNames names = + -- Make fresh names for the ones that are not already in scope + -- This makes things work for family declarations + do { env <- lift dsGetMetaEnv + ; mkGenSyms (filterOut (`elemNameEnv` env) names) } + +addSimpleTyVarBinds :: FreshOrReuse + -> [Name] -- the binders to be added -> MetaM (Core (M a)) -- action in the ext env -> MetaM (Core (M a)) -addSimpleTyVarBinds names thing_inside - = do { fresh_names <- mkGenSyms names +addSimpleTyVarBinds fresh_or_reuse names thing_inside + = do { fresh_names <- mkGenSyms' fresh_or_reuse names ; term <- addBinds fresh_names thing_inside ; wrapGenSyms fresh_names term } addHsTyVarBinds :: forall flag flag' a. RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addHsTyVarBinds exp_tvs thing_inside - = do { fresh_exp_names <- mkGenSyms (hsLTyVarNames exp_tvs) +addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside + = do { fresh_exp_names <- mkGenSyms' fresh_or_reuse (hsLTyVarNames exp_tvs) ; term <- addBinds fresh_exp_names $ do { kbs <- repListM (tyVarBndrName @flag @flag') repTyVarBndr exp_tvs ; thing_inside kbs } ; wrapGenSyms fresh_exp_names term } -addQTyVarBinds :: LHsQTyVars GhcRn -- the binders to be added +addQTyVarBinds :: FreshOrReuse + -> LHsQTyVars GhcRn -- the binders to be added -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addQTyVarBinds (HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs }) - thing_inside - = addTyVarBinds exp_tvs imp_tvs thing_inside +addQTyVarBinds fresh_or_reuse qtvs thing_inside = + let HsQTvs { hsq_ext = imp_tvs + , hsq_explicit = exp_tvs } + = qtvs + in addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside addTyVarBinds :: RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> [Name] -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -- gensym a list of type variables and enter them into the meta environment; -- the computations passed as the second argument is executed in that extended -- meta environment and gets the *new* names on Core-level as an argument -addTyVarBinds exp_tvs imp_tvs thing_inside - = addSimpleTyVarBinds imp_tvs $ - addHsTyVarBinds exp_tvs $ +addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside + = addSimpleTyVarBinds fresh_or_reuse imp_tvs $ + addHsTyVarBinds fresh_or_reuse exp_tvs $ thing_inside -addTyClTyVarBinds :: LHsQTyVars GhcRn - -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) - -> MetaM (Core (M a)) --- Used for data/newtype declarations, and family instances, --- so that the nested type variables work right --- instance C (T a) where --- type W (T a) = blah --- The 'a' in the type instance is the one bound by the instance decl -addTyClTyVarBinds tvs m - = do { let tv_names = hsAllLTyVarNames tvs - ; env <- lift $ dsGetMetaEnv - ; freshNames <- mkGenSyms (filterOut (`elemNameEnv` env) tv_names) - -- Make fresh names for the ones that are not already in scope - -- This makes things work for family declarations - - ; term <- addBinds freshNames $ - do { kbs <- repListM tyVarBndrUnitTyConName repTyVarBndr - (hsQTvExplicit tvs) - ; m kbs } - - ; wrapGenSyms freshNames term } - -- | Represent a type variable binder repTyVarBndr :: RepTV flag flag' => LHsTyVarBndr flag GhcRn -> MetaM (Core (M (TH.TyVarBndr flag'))) @@ -1341,7 +1346,7 @@ repLTy ty = repTy (unLoc ty) repForallT :: HsType GhcRn -> MetaM (Core (M TH.Type)) repForallT ty | (tvs, ctxt, tau) <- splitLHsSigmaTyInvis (noLocA ty) - = addHsTyVarBinds tvs $ \bndrs -> + = addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { ctxt1 <- repLContext ctxt ; tau1 <- repLTy tau ; repTForall bndrs ctxt1 tau1 -- forall a. C a => {...} @@ -1352,7 +1357,7 @@ repTy ty@(HsForAllTy { hst_tele = tele, hst_body = body }) = case tele of HsForAllInvis{} -> repForallT ty HsForAllVis { hsf_vis_bndrs = tvs } -> - addHsTyVarBinds tvs $ \bndrs -> + addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do body1 <- repLTy body repTForallVis bndrs body1 repTy ty@(HsQualTy {}) = repForallT ty @@ -1606,7 +1611,7 @@ repE (RecordUpd { rupd_flds = Right _ }) panic "The impossible has happened!" repE (ExprWithTySig _ e wc_ty) - = addSimpleTyVarBinds (get_scoped_tvs_from_sig sig_ty) $ + = addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig sig_ty) $ do { e1 <- repLE e ; t1 <- rep_ty_sig' sig_ty ; repSigExp e1 t1 } @@ -2560,7 +2565,7 @@ repDerivStrategy mds thing_inside = StockStrategy _ -> thing_inside =<< just =<< repStockStrategy AnyclassStrategy _ -> thing_inside =<< just =<< repAnyclassStrategy NewtypeStrategy _ -> thing_inside =<< just =<< repNewtypeStrategy - ViaStrategy ty -> addSimpleTyVarBinds (get_scoped_tvs_from_sig ty) $ + ViaStrategy ty -> addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig ty) $ do ty' <- rep_ty_sig' ty via_strat <- repViaStrategy ty' m_via_strat <- just via_strat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a46f93f8c34d7e2bed21576431f9e4acdd81295f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a46f93f8c34d7e2bed21576431f9e4acdd81295f You're receiving 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 Dec 2 16:30:33 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Fri, 02 Dec 2022 11:30:33 -0500 Subject: [Git][ghc/ghc][wip/or-pats] Introduce language extension and errors Message-ID: <638a28291b64_17512e64b9d70789199@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: c353400f by David Knothe at 2022-12-02T17:30:25+01:00 Introduce language extension and errors - - - - - 10 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Types/Error/Codes.hs - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3719,6 +3719,7 @@ xFlagsDeps = [ depFlagSpec' "NullaryTypeClasses" LangExt.NullaryTypeClasses (deprecatedForExtension "MultiParamTypeClasses"), flagSpec "NumDecimals" LangExt.NumDecimals, + flagSpec "OrPatterns" LangExt.OrPatterns, depFlagSpecOp "OverlappingInstances" LangExt.OverlappingInstances setOverlappingInsts "instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS", ===================================== compiler/GHC/Parser.y ===================================== @@ -3061,7 +3061,13 @@ texp :: { ECP } $1 >>= \ $1 -> pvA $ mkHsSectionR_PV (comb2 (reLocN $1) (reLoc $>)) (n2l $1) $2 } - | 'one' 'of' vocurly orpats close { ecpFromPat (sLLa ($1) (reLoc (last $4)) (mkorpat $4)) } + | 'one' 'of' vocurly orpats close + {% do { + let pat = sLLa $1 (reLoc (last $4)) (mkorpat $4) + ; orPatsOn <- hintOrPats pat + ; when (orPatsOn && length $4 < 2) $ addError $ mkPlainErrorMsgEnvelope (locA (getLoc pat)) (PsErrOrPatNeedsTwoAlternatives pat) + ; return $ ecpFromPat pat + } } -- View patterns get parenthesized above | exp '->' texp { ECP $ @@ -4186,6 +4192,13 @@ looksLikeMult ty1 l_op ty2 = True | otherwise = False +-- Hint about or-patterns +hintOrPats :: MonadP m => LPat GhcPs -> m Bool +hintOrPats pat = do + orPatsEnabled <- getBit OrPatternsBit + unless orPatsEnabled $ addError $ mkPlainErrorMsgEnvelope (locA (getLoc pat)) $ PsErrIllegalOrPat pat + return orPatsEnabled + -- Hint about the MultiWayIf extension hintMultiWayIf :: SrcSpan -> P () hintMultiWayIf span = do ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -523,6 +523,13 @@ instance Diagnostic PsMessage where , text "'" <> text [looks_like_char] <> text "' (" <> text looks_like_char_name <> text ")" <> comma , text "but it is not" ] + PsErrOrPatNeedsTwoAlternatives pat + -> mkSimpleDecorated $ vcat [text "Or-pattern needs at least two alternatives:" <+> ppr (unLoc pat)] + + PsErrIllegalOrPat pat + -> mkSimpleDecorated $ vcat [text "Illegal or-pattern:" <+> ppr (unLoc pat)] + + diagnosticReason = \case PsUnknownMessage m -> diagnosticReason m PsHeaderMessage m -> psHeaderMessageReason m @@ -641,6 +648,8 @@ instance Diagnostic PsMessage where PsErrInvalidCApiImport {} -> ErrorWithoutFlag PsErrMultipleConForNewtype {} -> ErrorWithoutFlag PsErrUnicodeCharLooksLike{} -> ErrorWithoutFlag + PsErrOrPatNeedsTwoAlternatives{} -> ErrorWithoutFlag + PsErrIllegalOrPat{} -> ErrorWithoutFlag diagnosticHints = \case PsUnknownMessage m -> diagnosticHints m @@ -812,6 +821,8 @@ instance Diagnostic PsMessage where PsErrInvalidCApiImport {} -> noHints PsErrMultipleConForNewtype {} -> noHints PsErrUnicodeCharLooksLike{} -> noHints + PsErrIllegalOrPat{} -> [suggestExtension LangExt.OrPatterns] + PsErrOrPatNeedsTwoAlternatives{} -> noHints diagnosticCode = constructorCode ===================================== compiler/GHC/Parser/Errors/Types.hs ===================================== @@ -471,6 +471,10 @@ data PsMessage Char -- ^ the character it looks like String -- ^ the name of the character that it looks like + | PsErrIllegalOrPat (LPat GhcPs) + + | PsErrOrPatNeedsTwoAlternatives (LPat GhcPs) + deriving Generic -- | Extra details about a parse error, which helps ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2907,6 +2907,7 @@ data ExtBits | NoLexicalNegationBit -- See Note [Why not LexicalNegationBit] | OverloadedRecordDotBit | OverloadedRecordUpdateBit + | OrPatternsBit -- Flags that are updated once parsing starts | InRulePragBit @@ -2986,6 +2987,7 @@ mkParserOpts extensionFlags diag_opts supported .|. NoLexicalNegationBit `xoptNotBit` LangExt.LexicalNegation -- See Note [Why not LexicalNegationBit] .|. OverloadedRecordDotBit `xoptBit` LangExt.OverloadedRecordDot .|. OverloadedRecordUpdateBit `xoptBit` LangExt.OverloadedRecordUpdate -- Enable testing via 'getBit OverloadedRecordUpdateBit' in the parser (RecordDotSyntax parsing uses that information). + .|. OrPatternsBit `xoptBit` LangExt.OrPatterns optBits = HaddockBit `setBitIf` isHaddock .|. RawTokenStreamBit `setBitIf` rawTokStream ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -616,7 +616,7 @@ rnPatAndThen mk (OrPat _ pats) checkNoVarsBound pat = do let bnds = collectPatsBinders CollNoDictBinders [pat] unless (null bnds) $ - liftCps $ addErrAt (locA $ getLoc pat) TcRnOrPatBindsVariables + liftCps $ addErrAt (locA $ getLoc pat) (TcRnOrPatBindsVariables pat) rnPatAndThen mk (SumPat _ pat alt arity) = do { pat <- rnLPatAndThen mk pat ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1153,9 +1153,8 @@ instance Diagnostic TcRnMessage where False -> text (TH.pprint item)) TcRnReportCustomQuasiError _ msg -> mkSimpleDecorated $ text msg TcRnInterfaceLookupError _ sdoc -> mkSimpleDecorated sdoc - TcRnOrPatBindsVariables - -> mkSimpleDecorated $ - text "Or Pattern may not bind variables" + TcRnOrPatBindsVariables pat + -> mkSimpleDecorated $ vcat [text "Or-pattern may not bind variables:" <+> ppr (unLoc pat)] TcRnUnsatisfiedMinimalDef mindef -> mkSimpleDecorated $ vcat [text "No explicit implementation for" @@ -1595,7 +1594,7 @@ instance Diagnostic TcRnMessage where -> if isError then ErrorWithoutFlag else WarningWithoutFlag TcRnInterfaceLookupError{} -> ErrorWithoutFlag - TcRnOrPatBindsVariables + TcRnOrPatBindsVariables{} -> ErrorWithoutFlag TcRnUnsatisfiedMinimalDef{} -> WarningWithFlag (Opt_WarnMissingMethods) @@ -2003,7 +2002,7 @@ instance Diagnostic TcRnMessage where -> noHints TcRnInterfaceLookupError{} -> noHints - TcRnOrPatBindsVariables + TcRnOrPatBindsVariables{} -> noHints TcRnUnsatisfiedMinimalDef{} -> noHints ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2554,8 +2554,8 @@ data TcRnMessage where Test case: none yet (TODO) -} + TcRnOrPatBindsVariables :: LPat GhcRn -> TcRnMessage - TcRnOrPatBindsVariables :: TcRnMessage {- | TcRnUnsatisfiedMinimalDef is a warning that occurs when a class instance is missing methods that are required by the minimal definition. ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -268,6 +268,8 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "PsErrInvalidCApiImport" = 72744 GhcDiagnosticCode "PsErrMultipleConForNewtype" = 05380 GhcDiagnosticCode "PsErrUnicodeCharLooksLike" = 31623 + GhcDiagnosticCode "PsErrIllegalOrPat" = 29847 + GhcDiagnosticCode "PsErrOrPatNeedsTwoAlternatives" = 96152 -- Driver diagnostic codes GhcDiagnosticCode "DriverMissingHomeModules" = 32850 @@ -470,7 +472,6 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnNameByTemplateHaskellQuote" = 40027 GhcDiagnosticCode "TcRnIllegalBindingOfBuiltIn" = 69639 GhcDiagnosticCode "TcRnOrPatBindsVariables" = 81303 - GhcDiagnosticCode "TcRnIllegalHsigDefaultMethods" = 93006 GhcDiagnosticCode "TcRnBadGenericMethod" = 59794 GhcDiagnosticCode "TcRnWarningMinimalDefIncomplete" = 13511 ===================================== libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs ===================================== @@ -64,6 +64,7 @@ data Extension | RecordWildCards | NamedFieldPuns | ViewPatterns + | OrPatterns | GADTs | GADTSyntax | NPlusKPatterns View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c353400f78ee9fbb8036d93557ead205181cd0fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c353400f78ee9fbb8036d93557ead205181cd0fc You're receiving 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 Dec 2 18:45:39 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 02 Dec 2022 13:45:39 -0500 Subject: [Git][ghc/ghc][wip/int-index/fresh-or-reuse] 2 commits: Refactor: FreshOrReuse instead of addTyClTyVarBinds Message-ID: <638a47d356e6b_17512e64b9d70815666@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/fresh-or-reuse at Glasgow Haskell Compiler / GHC Commits: 9df95d39 by Vladislav Zavialov at 2022-12-02T20:45:44+03:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - 9f2399a4 by Vladislav Zavialov at 2022-12-02T21:44:48+03:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 1 changed file: - compiler/GHC/HsToCore/Quote.hs Changes: ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -461,7 +461,7 @@ repTyClD (L loc (FamDecl { tcdFam = fam })) = liftM Just $ repTyClD (L loc (SynDecl { tcdLName = tc, tcdTyVars = tvs, tcdRhs = rhs })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repSynDecl tc1 bndrs rhs ; return (Just (locA loc, dec)) } @@ -469,7 +469,7 @@ repTyClD (L loc (DataDecl { tcdLName = tc , tcdTyVars = tvs , tcdDataDefn = defn })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repDataDefn tc1 (Left bndrs) defn ; return (Just (locA loc, dec)) } @@ -478,7 +478,7 @@ repTyClD (L loc (ClassDecl { tcdCtxt = cxt, tcdLName = cls, tcdSigs = sigs, tcdMeths = meth_binds, tcdATs = ats, tcdATDefs = atds })) = do { cls1 <- lookupLOcc cls -- See Note [Binders and occurrences] - ; dec <- addQTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { cxt1 <- repLContext cxt -- See Note [Scoped type variables in quotes] ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs meth_binds @@ -549,14 +549,11 @@ repFamilyDecl decl@(L loc (FamilyDecl { fdInfo = info , fdResultSig = L _ resultSig , fdInjectivityAnn = injectivity })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; let mkHsQTvs :: [LHsTyVarBndr () GhcRn] -> LHsQTyVars GhcRn - mkHsQTvs tvs = HsQTvs { hsq_ext = [] - , hsq_explicit = tvs } - resTyVar = case resultSig of - TyVarSig _ bndr -> mkHsQTvs [bndr] - _ -> mkHsQTvs [] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> - addTyClTyVarBinds resTyVar $ \_ -> + ; let resTyVar = case resultSig of + TyVarSig _ bndr -> [hsLTyVarName bndr] + _ -> [] + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> + addSimpleTyVarBinds ReuseBoundNames resTyVar $ case info of ClosedTypeFamily Nothing -> notHandled (ThAbstractClosedTypeFamily decl) @@ -645,7 +642,7 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds , cid_datafam_insts = adts , cid_overlap_mode = overlap }) - = addSimpleTyVarBinds tvs $ + = addSimpleTyVarBinds FreshNamesOnly tvs $ -- We must bring the type variables into scope, so their -- occurrences don't fail, even though the binders don't -- appear in the resulting data structure @@ -672,7 +669,7 @@ repStandaloneDerivD :: LDerivDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat , deriv_type = ty })) = do { dec <- repDerivStrategy strat $ \strat' -> - addSimpleTyVarBinds tvs $ + addSimpleTyVarBinds FreshNamesOnly tvs $ do { cxt' <- repLContext cxt ; inst_ty' <- repLTy inst_ty ; repDeriv strat' cxt' inst_ty' } @@ -804,16 +801,17 @@ repDefD (L loc (DefaultDecl _ tys)) = do { tys1 <- repLTys tys repRuleD :: LRuleDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repRuleD (L loc (HsRule { rd_name = n , rd_act = act - , rd_tyvs = ty_bndrs + , rd_tyvs = m_ty_bndrs , rd_tmvs = tm_bndrs , rd_lhs = lhs , rd_rhs = rhs })) - = do { rule <- addHsTyVarBinds (fromMaybe [] ty_bndrs) $ \ ex_bndrs -> + = do { let ty_bndrs = fromMaybe [] m_ty_bndrs + ; rule <- addHsTyVarBinds FreshNamesOnly ty_bndrs $ \ ex_bndrs -> do { let tm_bndr_names = concatMap ruleBndrNames tm_bndrs ; ss <- mkGenSyms tm_bndr_names ; rule <- addBinds ss $ do { elt_ty <- wrapName tyVarBndrUnitTyConName - ; ty_bndrs' <- return $ case ty_bndrs of + ; ty_bndrs' <- return $ case m_ty_bndrs of Nothing -> coreNothing' (mkListTy elt_ty) Just _ -> coreJust' (mkListTy elt_ty) ex_bndrs ; tm_bndrs' <- repListM ruleBndrTyConName @@ -878,7 +876,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_ex_tvs = con_tvs , con_mb_cxt = mcxt , con_args = args })) - = addHsTyVarBinds con_tvs $ \ ex_bndrs -> + = addHsTyVarBinds FreshNamesOnly con_tvs $ \ ex_bndrs -> do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt @@ -1188,14 +1186,11 @@ addHsOuterFamEqnTyVarBinds outer_bndrs thing_inside = do elt_ty <- wrapName tyVarBndrUnitTyConName case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> - addTyClTyVarBinds (mk_qtvs imp_tvs []) $ \_th_exp_bndrs -> + addSimpleTyVarBinds ReuseBoundNames imp_tvs $ thing_inside $ coreNothingList elt_ty HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addTyClTyVarBinds (mk_qtvs [] exp_bndrs) $ \th_exp_bndrs -> + addHsTyVarBinds FreshNamesOnly exp_bndrs $ \th_exp_bndrs -> thing_inside $ coreJustList elt_ty th_exp_bndrs - where - mk_qtvs imp_tvs exp_tvs = HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs } addHsOuterSigTyVarBinds :: HsOuterSigTyVarBndrs GhcRn @@ -1204,9 +1199,9 @@ addHsOuterSigTyVarBinds :: addHsOuterSigTyVarBinds outer_bndrs thing_inside = case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> do th_nil <- coreListM tyVarBndrSpecTyConName [] - addSimpleTyVarBinds imp_tvs $ thing_inside th_nil + addSimpleTyVarBinds FreshNamesOnly imp_tvs $ thing_inside th_nil HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addHsTyVarBinds exp_bndrs thing_inside + addHsTyVarBinds FreshNamesOnly exp_bndrs thing_inside -- | If a type implicitly quantifies its outermost type variables, return -- 'True' if the list of implicitly bound type variables is empty. If a type @@ -1230,69 +1225,86 @@ nullOuterExplicit (HsOuterExplicit{hso_bndrs = exp_bndrs}) = null exp_bndrs nullOuterExplicit (HsOuterImplicit{}) = True -- Vacuously true, as there is no outermost explicit quantification -addSimpleTyVarBinds :: [Name] -- the binders to be added +-- Do we want to generate fresh names for type variables +-- or reuse the ones that are already in scope? +data FreshOrReuse + = FreshNamesOnly + -- Generate fresh names for all type variables, regardless of existing + -- variables in the MetaEnv. + -- + -- This is the default strategy. + + | ReuseBoundNames + -- Generate fresh names for type variables not in the MetaEnv. + -- Where a name is already bound in the MetaEnv, use that existing binding; + -- do not create a new one with a fresh name. + -- + -- This is the strategy used for data/newtype declarations and type family + -- instances, so that the nested type variables work right: + -- + -- class C a where + -- type W a b + -- instance C (T a) where + -- type W (T a) b = blah + -- + -- The 'a' in the type instance is the one bound by the instance decl + -- + -- Test cases: TH_reifyExplicitForAllFams T9081 T9199 T10811 + +mkGenSyms' :: FreshOrReuse -> [Name] -> MetaM [GenSymBind] +mkGenSyms' FreshNamesOnly names = mkGenSyms names +mkGenSyms' ReuseBoundNames names = + -- Make fresh names for the ones that are not already in scope + -- This makes things work for associated types + do { env <- lift dsGetMetaEnv + ; mkGenSyms (filterOut (`elemNameEnv` env) names) } + +addSimpleTyVarBinds :: FreshOrReuse + -> [Name] -- the binders to be added -> MetaM (Core (M a)) -- action in the ext env -> MetaM (Core (M a)) -addSimpleTyVarBinds names thing_inside - = do { fresh_names <- mkGenSyms names +addSimpleTyVarBinds fresh_or_reuse names thing_inside + = do { fresh_names <- mkGenSyms' fresh_or_reuse names ; term <- addBinds fresh_names thing_inside ; wrapGenSyms fresh_names term } addHsTyVarBinds :: forall flag flag' a. RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addHsTyVarBinds exp_tvs thing_inside - = do { fresh_exp_names <- mkGenSyms (hsLTyVarNames exp_tvs) +addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside + = do { fresh_exp_names <- mkGenSyms' fresh_or_reuse (hsLTyVarNames exp_tvs) ; term <- addBinds fresh_exp_names $ do { kbs <- repListM (tyVarBndrName @flag @flag') repTyVarBndr exp_tvs ; thing_inside kbs } ; wrapGenSyms fresh_exp_names term } -addQTyVarBinds :: LHsQTyVars GhcRn -- the binders to be added +addQTyVarBinds :: FreshOrReuse + -> LHsQTyVars GhcRn -- the binders to be added -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addQTyVarBinds (HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs }) - thing_inside - = addTyVarBinds exp_tvs imp_tvs thing_inside +addQTyVarBinds fresh_or_reuse qtvs thing_inside = + let HsQTvs { hsq_ext = imp_tvs + , hsq_explicit = exp_tvs } + = qtvs + in addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside addTyVarBinds :: RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> [Name] -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -- gensym a list of type variables and enter them into the meta environment; -- the computations passed as the second argument is executed in that extended -- meta environment and gets the *new* names on Core-level as an argument -addTyVarBinds exp_tvs imp_tvs thing_inside - = addSimpleTyVarBinds imp_tvs $ - addHsTyVarBinds exp_tvs $ +addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside + = addSimpleTyVarBinds fresh_or_reuse imp_tvs $ + addHsTyVarBinds fresh_or_reuse exp_tvs $ thing_inside -addTyClTyVarBinds :: LHsQTyVars GhcRn - -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) - -> MetaM (Core (M a)) --- Used for data/newtype declarations, and family instances, --- so that the nested type variables work right --- instance C (T a) where --- type W (T a) = blah --- The 'a' in the type instance is the one bound by the instance decl -addTyClTyVarBinds tvs m - = do { let tv_names = hsAllLTyVarNames tvs - ; env <- lift $ dsGetMetaEnv - ; freshNames <- mkGenSyms (filterOut (`elemNameEnv` env) tv_names) - -- Make fresh names for the ones that are not already in scope - -- This makes things work for family declarations - - ; term <- addBinds freshNames $ - do { kbs <- repListM tyVarBndrUnitTyConName repTyVarBndr - (hsQTvExplicit tvs) - ; m kbs } - - ; wrapGenSyms freshNames term } - -- | Represent a type variable binder repTyVarBndr :: RepTV flag flag' => LHsTyVarBndr flag GhcRn -> MetaM (Core (M (TH.TyVarBndr flag'))) @@ -1341,7 +1353,7 @@ repLTy ty = repTy (unLoc ty) repForallT :: HsType GhcRn -> MetaM (Core (M TH.Type)) repForallT ty | (tvs, ctxt, tau) <- splitLHsSigmaTyInvis (noLocA ty) - = addHsTyVarBinds tvs $ \bndrs -> + = addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { ctxt1 <- repLContext ctxt ; tau1 <- repLTy tau ; repTForall bndrs ctxt1 tau1 -- forall a. C a => {...} @@ -1352,7 +1364,7 @@ repTy ty@(HsForAllTy { hst_tele = tele, hst_body = body }) = case tele of HsForAllInvis{} -> repForallT ty HsForAllVis { hsf_vis_bndrs = tvs } -> - addHsTyVarBinds tvs $ \bndrs -> + addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do body1 <- repLTy body repTForallVis bndrs body1 repTy ty@(HsQualTy {}) = repForallT ty @@ -1606,7 +1618,7 @@ repE (RecordUpd { rupd_flds = Right _ }) panic "The impossible has happened!" repE (ExprWithTySig _ e wc_ty) - = addSimpleTyVarBinds (get_scoped_tvs_from_sig sig_ty) $ + = addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig sig_ty) $ do { e1 <- repLE e ; t1 <- rep_ty_sig' sig_ty ; repSigExp e1 t1 } @@ -2560,7 +2572,7 @@ repDerivStrategy mds thing_inside = StockStrategy _ -> thing_inside =<< just =<< repStockStrategy AnyclassStrategy _ -> thing_inside =<< just =<< repAnyclassStrategy NewtypeStrategy _ -> thing_inside =<< just =<< repNewtypeStrategy - ViaStrategy ty -> addSimpleTyVarBinds (get_scoped_tvs_from_sig ty) $ + ViaStrategy ty -> addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig ty) $ do ty' <- rep_ty_sig' ty via_strat <- repViaStrategy ty' m_via_strat <- just via_strat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a46f93f8c34d7e2bed21576431f9e4acdd81295f...9f2399a446e166adfeeb44f245425c4c5d97b9ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a46f93f8c34d7e2bed21576431f9e4acdd81295f...9f2399a446e166adfeeb44f245425c4c5d97b9ee You're receiving 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 Dec 2 18:56:42 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 02 Dec 2022 13:56:42 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Refactor TyCon to have a top-level product Message-ID: <638a4a6af0a8d_17512ed8b993c822582@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - bd5446ae by Matthew Pickering at 2022-12-02T13:56:17-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 4dd67cb0 by Krzysztof Gogolewski at 2022-12-02T13:56:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - 26 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + compiler/GHC/Core/TyCo/FVs.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - + testsuite/tests/ado/T22483.hs - + testsuite/tests/ado/T22483.stderr - testsuite/tests/ado/all.T - + testsuite/tests/driver/fat-iface/T22405/Main.hs - + testsuite/tests/driver/fat-iface/T22405/Main2.hs - + testsuite/tests/driver/fat-iface/T22405/Makefile - + testsuite/tests/driver/fat-iface/T22405/T22405.stdout - + testsuite/tests/driver/fat-iface/T22405/T22405b.stdout - + testsuite/tests/driver/fat-iface/T22405/all.T - + testsuite/tests/linear/should_compile/T22546.hs - testsuite/tests/linear/should_compile/all.T - utils/haddock Changes: ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -1038,12 +1038,11 @@ unboxedTupleKind = unboxedTupleSumKind tupleRepDataConTyCon mk_tuple :: Boxity -> Int -> (TyCon,DataCon) mk_tuple Boxed arity = (tycon, tuple_con) where - tycon = mkTupleTyCon tc_name tc_binders tc_res_kind tc_arity tuple_con + tycon = mkTupleTyCon tc_name tc_binders tc_res_kind tuple_con BoxedTuple flavour tc_binders = mkTemplateAnonTyConBinders (replicate arity liftedTypeKind) tc_res_kind = liftedTypeKind - tc_arity = arity flavour = VanillaAlgTyCon (mkPrelTyConRepName tc_name) dc_tvs = binderVars tc_binders @@ -1061,7 +1060,7 @@ mk_tuple Boxed arity = (tycon, tuple_con) mk_tuple Unboxed arity = (tycon, tuple_con) where - tycon = mkTupleTyCon tc_name tc_binders tc_res_kind tc_arity tuple_con + tycon = mkTupleTyCon tc_name tc_binders tc_res_kind tuple_con UnboxedTuple flavour -- See Note [Unboxed tuple RuntimeRep vars] in GHC.Core.TyCon @@ -1070,8 +1069,6 @@ mk_tuple Unboxed arity = (tycon, tuple_con) (\ks -> map mkTYPEapp ks) tc_res_kind = unboxedTupleKind rr_tys - - tc_arity = arity * 2 flavour = VanillaAlgTyCon (mkPrelTyConRepName tc_name) dc_tvs = binderVars tc_binders @@ -1224,7 +1221,7 @@ unboxedSumKind = unboxedTupleSumKind sumRepDataConTyCon mk_sum :: Arity -> (TyCon, Array ConTagZ DataCon) mk_sum arity = (tycon, sum_cons) where - tycon = mkSumTyCon tc_name tc_binders tc_res_kind (arity * 2) tyvars (elems sum_cons) + tycon = mkSumTyCon tc_name tc_binders tc_res_kind (elems sum_cons) UnboxedSumTyCon tc_binders = mkTemplateTyConBinders (replicate arity runtimeRepTy) ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -3235,22 +3235,29 @@ ensureSubUsage Zero described_mult err_msg = ensureSubMult ManyTy describe ensureSubUsage (MUsage m) described_mult err_msg = ensureSubMult m described_mult err_msg ensureSubMult :: Mult -> Mult -> SDoc -> LintM () -ensureSubMult actual_usage described_usage err_msg = do +ensureSubMult actual_mult described_mult err_msg = do flags <- getLintFlags - when (lf_check_linearity flags) $ case actual_usage' `submult` described_usage' of - Submult -> return () - Unknown -> case isMultMul actual_usage' of - Just (m1, m2) -> ensureSubMult m1 described_usage' err_msg >> - ensureSubMult m2 described_usage' err_msg - Nothing -> when (not (actual_usage' `eqType` described_usage')) (addErrL err_msg) - - where actual_usage' = normalize actual_usage - described_usage' = normalize described_usage - - normalize :: Mult -> Mult - normalize m = case isMultMul m of - Just (m1, m2) -> mkMultMul (normalize m1) (normalize m2) - Nothing -> m + when (lf_check_linearity flags) $ + unless (deepSubMult actual_mult described_mult) $ + addErrL err_msg + where + -- Check for submultiplicity using the following rules: + -- 1. x*y <= z when x <= z and y <= z. + -- This rule follows from the fact that x*y = sup{x,y} for any + -- multiplicities x,y. + -- 2. x <= y*z when x <= y or x <= z. + -- This rule is not complete: when x = y*z, we cannot + -- change y*z <= y*z to y*z <= y or y*z <= z. + -- However, we eliminate products on the LHS in step 1. + -- 3. One <= x and x <= Many for any x, as checked by 'submult'. + -- 4. x <= x. + -- Otherwise, we fail. + deepSubMult :: Mult -> Mult -> Bool + deepSubMult m n + | Just (m1, m2) <- isMultMul m = deepSubMult m1 n && deepSubMult m2 n + | Just (n1, n2) <- isMultMul n = deepSubMult m n1 || deepSubMult m n2 + | Submult <- m `submult` n = True + | otherwise = m `eqType` n lintRole :: Outputable thing => thing -- where the role appeared ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -271,7 +271,10 @@ eqDeBruijnType env_t1@(D env1 t1) env_t2@(D env2 t2) = -> TEQ _ -> TNEQ - gos _ _ [] [] = TEQ + -- These bangs make 'gos' strict in the CMEnv, which in turn + -- keeps the CMEnv unboxed across the go/gos mutual recursion + -- (If you want a test case, T9872c really exercises this code.) + gos !_ !_ [] [] = TEQ gos e1 e2 (ty1:tys1) (ty2:tys2) = go (D e1 ty1) (D e2 ty2) `andEq` gos e1 e2 tys1 tys2 gos _ _ _ _ = TNEQ ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -571,6 +571,11 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. +instance Outputable i => Outputable (UnboxingDecision i) where + ppr DontUnbox = text "DontUnbox" + ppr DropAbsent = text "DropAbsent" + ppr (DoUnbox i) = text "DoUnbox" <> braces (ppr i) + -- | Do we want to create workers just for unlifting? wwUseForUnlifting :: WwOpts -> WwUse wwUseForUnlifting !opts ===================================== compiler/GHC/Core/TyCo/FVs.hs-boot ===================================== @@ -0,0 +1,6 @@ +module GHC.Core.TyCo.FVs where + +import GHC.Prelude ( Bool ) +import {-# SOURCE #-} GHC.Core.TyCo.Rep ( Type ) + +noFreeVarsOfType :: Type -> Bool ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -81,7 +81,7 @@ module GHC.Core.TyCon( tyConKind, tyConUnique, tyConTyVars, tyConVisibleTyVars, - tyConCType, tyConCType_maybe, + tyConCType_maybe, tyConDataCons, tyConDataCons_maybe, tyConSingleDataCon_maybe, tyConSingleDataCon, tyConAlgDataCons_maybe, @@ -96,7 +96,7 @@ module GHC.Core.TyCon( tyConFamInst_maybe, tyConFamInstSig_maybe, tyConFamilyCoercion_maybe, tyConFamilyResVar_maybe, synTyConDefn_maybe, synTyConRhs_maybe, - famTyConFlav_maybe, famTcResVar, + famTyConFlav_maybe, algTyConRhs, newTyConRhs, newTyConEtadArity, newTyConEtadRhs, unwrapNewTyCon_maybe, unwrapNewTyConEtad_maybe, @@ -104,7 +104,8 @@ module GHC.Core.TyCon( algTcFields, tyConPromDataConInfo, tyConBinders, tyConResKind, tyConInvisTVBinders, - tcTyConScopedTyVars, tcTyConIsPoly, + tcTyConScopedTyVars, isMonoTcTyCon, + tyConHasClosedResKind, mkTyConTagMap, -- ** Manipulating TyCons @@ -140,6 +141,8 @@ import GHC.Platform import {-# SOURCE #-} GHC.Core.TyCo.Rep ( Kind, Type, PredType, mkForAllTy, mkNakedFunTy, mkNakedTyConTy ) +import {-# SOURCE #-} GHC.Core.TyCo.FVs + ( noFreeVarsOfType ) import {-# SOURCE #-} GHC.Core.TyCo.Ppr ( pprType ) import {-# SOURCE #-} GHC.Builtin.Types @@ -775,10 +778,34 @@ instance Binary TyConBndrVis where -- -- This data type also encodes a number of primitive, built in type constructors -- such as those for function and tuple types. - +-- -- If you edit this type, you may need to update the GHC formalism -- See Note [GHC Formalism] in GHC.Core.Lint -data TyCon = +data TyCon = TyCon { + tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: + -- identical to Unique of Name stored in + -- tyConName field. + + tyConName :: !Name, -- ^ Name of the constructor + + -- See Note [The binders/kind/arity fields of a TyCon] + tyConBinders :: [TyConBinder], -- ^ Full binders + tyConResKind :: Kind, -- ^ Result kind + tyConHasClosedResKind :: Bool, + + -- Cached values + tyConTyVars :: [TyVar], -- ^ TyVar binders + tyConKind :: Kind, -- ^ Kind of this TyCon + tyConArity :: Arity, -- ^ Arity + tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ + + tyConRoles :: [Role], -- ^ The role for each type variable + -- This list has length = tyConArity + -- See also Note [TyCon Role signatures] + + tyConDetails :: !TyConDetails } + +data TyConDetails = -- | Algebraic data types, from -- - @data@ declarations -- - @newtype@ declarations @@ -792,20 +819,6 @@ data TyCon = -- Data/newtype/type /families/ are handled by 'FamilyTyCon'. -- See 'AlgTyConRhs' for more information. AlgTyCon { - tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: - -- identical to Unique of Name stored in - -- tyConName field. - - tyConName :: Name, -- ^ Name of the constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConTyVars :: [TyVar], -- ^ TyVar binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ - -- The tyConTyVars scope over: -- -- 1. The 'algTcStupidTheta' @@ -815,10 +828,6 @@ data TyCon = -- Note that it does /not/ scope over the data -- constructors. - tcRoles :: [Role], -- ^ The role for each type variable - -- This list has length = tyConArity - -- See also Note [TyCon Role signatures] - tyConCType :: Maybe CType,-- ^ The C type that should be used -- for this type when using the FFI -- and CAPI @@ -853,25 +862,8 @@ data TyCon = -- | Represents type synonyms | SynonymTyCon { - tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: - -- identical to Unique of Name stored in - -- tyConName field. - - tyConName :: Name, -- ^ Name of the constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConTyVars :: [TyVar], -- ^ TyVar binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ -- tyConTyVars scope over: synTcRhs - tcRoles :: [Role], -- ^ The role for each type variable - -- This list has length = tyConArity - -- See also Note [TyCon Role signatures] - synTcRhs :: Type, -- ^ Contains information about the expansion -- of the synonym @@ -892,19 +884,6 @@ data TyCon = -- | Represents families (both type and data) -- Argument roles are all Nominal | FamilyTyCon { - tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: - -- identical to Unique of Name stored in - -- tyConName field. - - tyConName :: Name, -- ^ Name of the constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConTyVars :: [TyVar], -- ^ TyVar binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ -- tyConTyVars connect an associated family TyCon -- with its parent class; see GHC.Tc.Validity.checkConsistentFamInst @@ -930,23 +909,6 @@ data TyCon = -- the usual suspects (such as @Int#@) as well as foreign-imported -- types and kinds (@*@, @#@, and @?@) | PrimTyCon { - tyConUnique :: !Unique, -- ^ A Unique of this TyCon. Invariant: - -- identical to Unique of Name stored in - -- tyConName field. - - tyConName :: Name, -- ^ Name of the constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ - - tcRoles :: [Role], -- ^ The role for each type variable - -- This list has length = tyConArity - -- See also Note [TyCon Role signatures] - primRepName :: TyConRepName -- ^ The 'Typeable' representation. -- A cached version of -- @'mkPrelTyConRepName' ('tyConName' tc)@. @@ -954,18 +916,6 @@ data TyCon = -- | Represents promoted data constructor. | PromotedDataCon { -- See Note [Promoted data constructors] - tyConUnique :: !Unique, -- ^ Same Unique as the data constructor - tyConName :: Name, -- ^ Same Name as the data constructor - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConPiTyBinder], -- ^ Full binders - -- TyConPiTyBinder: see Note [Promoted GADT data constructors] - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ - - tcRoles :: [Role], -- ^ Roles: N for kind vars, R for type vars dataCon :: DataCon, -- ^ Corresponding data constructor tcRepName :: TyConRepName, promDcInfo :: PromDataConInfo -- ^ See comments with 'PromDataConInfo' @@ -974,31 +924,20 @@ data TyCon = -- | These exist only during type-checking. See Note [How TcTyCons work] -- in "GHC.Tc.TyCl" | TcTyCon { - tyConUnique :: !Unique, - tyConName :: Name, - - -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConBinder], -- ^ Full binders - tyConTyVars :: [TyVar], -- ^ TyVar binders - tyConResKind :: Kind, -- ^ Result kind - tyConKind :: Kind, -- ^ Kind of this TyCon - tyConArity :: Arity, -- ^ Arity - tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ - -- NB: the tyConArity of a TcTyCon must match -- the number of Required (positional, user-specified) -- arguments to the type constructor; see the use -- of tyConArity in generaliseTcTyCon - tcTyConScopedTyVars :: [(Name,TcTyVar)], + tctc_scoped_tvs :: [(Name,TcTyVar)], -- ^ Scoped tyvars over the tycon's body -- The range is always a skolem or TcTyVar, be -- MonoTcTyCon only: see Note [Scoped tyvars in a TcTyCon] - tcTyConIsPoly :: Bool, -- ^ Is this TcTyCon already generalized? - -- Used only to make zonking more efficient + tctc_is_poly :: Bool, -- ^ Is this TcTyCon already generalized? + -- Used only to make zonking more efficient - tcTyConFlavour :: TyConFlavour + tctc_flavour :: TyConFlavour -- ^ What sort of 'TyCon' this represents. } @@ -1517,21 +1456,24 @@ type TyConRepName = Name -- $tcMaybe = TyCon { tyConName = "Maybe", ... } tyConRepName_maybe :: TyCon -> Maybe TyConRepName -tyConRepName_maybe (PrimTyCon { primRepName = rep_nm }) - = Just rep_nm -tyConRepName_maybe (AlgTyCon { algTcFlavour = parent }) = case parent of - VanillaAlgTyCon rep_nm -> Just rep_nm - UnboxedSumTyCon -> Nothing - ClassTyCon _ rep_nm -> Just rep_nm - DataFamInstTyCon {} -> Nothing -tyConRepName_maybe (FamilyTyCon { famTcFlav = DataFamilyTyCon rep_nm }) - = Just rep_nm -tyConRepName_maybe (PromotedDataCon { dataCon = dc, tcRepName = rep_nm }) - | isUnboxedSumDataCon dc -- see #13276 - = Nothing - | otherwise - = Just rep_nm -tyConRepName_maybe _ = Nothing +tyConRepName_maybe (TyCon { tyConDetails = details }) = get_rep_nm details + where + get_rep_nm (PrimTyCon { primRepName = rep_nm }) + = Just rep_nm + get_rep_nm (AlgTyCon { algTcFlavour = parent }) + = case parent of + VanillaAlgTyCon rep_nm -> Just rep_nm + UnboxedSumTyCon -> Nothing + ClassTyCon _ rep_nm -> Just rep_nm + DataFamInstTyCon {} -> Nothing + get_rep_nm (FamilyTyCon { famTcFlav = DataFamilyTyCon rep_nm }) + = Just rep_nm + get_rep_nm (PromotedDataCon { dataCon = dc, tcRepName = rep_nm }) + | isUnboxedSumDataCon dc -- see #13276 + = Nothing + | otherwise + = Just rep_nm + get_rep_nm _ = Nothing -- | Make a 'Name' for the 'Typeable' representation of the given wired-in type mkPrelTyConRepName :: Name -> TyConRepName @@ -1821,9 +1763,9 @@ tyConFieldLabels tc = dFsEnvElts $ tyConFieldLabelEnv tc -- | The labels for the fields of this particular 'TyCon' tyConFieldLabelEnv :: TyCon -> FieldLabelEnv -tyConFieldLabelEnv tc - | isAlgTyCon tc = algTcFields tc - | otherwise = emptyDFsEnv +tyConFieldLabelEnv (TyCon { tyConDetails = details }) + | AlgTyCon { algTcFields = fields } <- details = fields + | otherwise = emptyDFsEnv -- | Look up a field label belonging to this 'TyCon' lookupTyConFieldLabel :: FieldLabelString -> TyCon -> Maybe FieldLabel @@ -1853,6 +1795,25 @@ module mutual-recursion. And they aren't called from many places. So we compromise, and move their Kind calculation to the call site. -} +mkTyCon :: Name -> [TyConBinder] -> Kind -> [Role] -> TyConDetails -> TyCon +mkTyCon name binders res_kind roles details + = tc + where + -- Recurisve binding because of tcNullaryTy + tc = TyCon { tyConName = name + , tyConUnique = nameUnique name + , tyConBinders = binders + , tyConResKind = res_kind + , tyConRoles = roles + , tyConDetails = details + + -- Cached things + , tyConKind = mkTyConKind binders res_kind + , tyConArity = length binders + , tyConNullaryTy = mkNakedTyConTy tc + , tyConHasClosedResKind = noFreeVarsOfType res_kind + , tyConTyVars = binderVars binders } + -- | This is the making of an algebraic 'TyCon'. mkAlgTyCon :: Name -> [TyConBinder] -- ^ Binders of the 'TyCon' @@ -1867,25 +1828,14 @@ mkAlgTyCon :: Name -> Bool -- ^ Was the 'TyCon' declared with GADT syntax? -> TyCon mkAlgTyCon name binders res_kind roles cType stupid rhs parent gadt_syn - = let tc = - AlgTyCon { - tyConName = name, - tyConUnique = nameUnique name, - tyConBinders = binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = length binders, - tyConNullaryTy = mkNakedTyConTy tc, - tyConTyVars = binderVars binders, - tcRoles = roles, - tyConCType = cType, - algTcStupidTheta = stupid, - algTcRhs = rhs, - algTcFields = fieldsOfAlgTcRhs rhs, - algTcFlavour = assertPpr (okParent name parent) (ppr name $$ ppr parent) parent, - algTcGadtSyntax = gadt_syn - } - in tc + = mkTyCon name binders res_kind roles $ + AlgTyCon { tyConCType = cType + , algTcStupidTheta = stupid + , algTcRhs = rhs + , algTcFields = fieldsOfAlgTcRhs rhs + , algTcFlavour = assertPpr (okParent name parent) + (ppr name $$ ppr parent) parent + , algTcGadtSyntax = gadt_syn } -- | Simpler specialization of 'mkAlgTyCon' for classes mkClassTyCon :: Name -> [TyConBinder] @@ -1899,61 +1849,37 @@ mkClassTyCon name binders roles rhs clas tc_rep_name mkTupleTyCon :: Name -> [TyConBinder] -> Kind -- ^ Result kind of the 'TyCon' - -> Arity -- ^ Arity of the tuple 'TyCon' -> DataCon -> TupleSort -- ^ Whether the tuple is boxed or unboxed -> AlgTyConFlav -> TyCon -mkTupleTyCon name binders res_kind arity con sort parent - = let tc = - AlgTyCon { - tyConUnique = nameUnique name, - tyConName = name, - tyConBinders = binders, - tyConTyVars = binderVars binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = arity, - tyConNullaryTy = mkNakedTyConTy tc, - tcRoles = replicate arity Representational, - tyConCType = Nothing, - algTcGadtSyntax = False, - algTcStupidTheta = [], - algTcRhs = TupleTyCon { data_con = con, - tup_sort = sort }, - algTcFields = emptyDFsEnv, - algTcFlavour = parent - } - in tc +mkTupleTyCon name binders res_kind con sort parent + = mkTyCon name binders res_kind (constRoles binders Representational) $ + AlgTyCon { tyConCType = Nothing + , algTcGadtSyntax = False + , algTcStupidTheta = [] + , algTcRhs = TupleTyCon { data_con = con + , tup_sort = sort } + , algTcFields = emptyDFsEnv + , algTcFlavour = parent } + +constRoles :: [TyConBinder] -> Role -> [Role] +constRoles bndrs role = [role | _ <- bndrs] mkSumTyCon :: Name - -> [TyConBinder] - -> Kind -- ^ Kind of the resulting 'TyCon' - -> Arity -- ^ Arity of the sum - -> [TyVar] -- ^ 'TyVar's scoped over: see 'tyConTyVars' - -> [DataCon] - -> AlgTyConFlav - -> TyCon -mkSumTyCon name binders res_kind arity tyvars cons parent - = let tc = - AlgTyCon { - tyConUnique = nameUnique name, - tyConName = name, - tyConBinders = binders, - tyConTyVars = tyvars, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = arity, - tyConNullaryTy = mkNakedTyConTy tc, - tcRoles = replicate arity Representational, - tyConCType = Nothing, - algTcGadtSyntax = False, - algTcStupidTheta = [], - algTcRhs = mkSumTyConRhs cons, - algTcFields = emptyDFsEnv, - algTcFlavour = parent - } - in tc + -> [TyConBinder] + -> Kind -- ^ Kind of the resulting 'TyCon' + -> [DataCon] + -> AlgTyConFlav + -> TyCon +mkSumTyCon name binders res_kind cons parent + = mkTyCon name binders res_kind (constRoles binders Representational) $ + AlgTyCon { tyConCType = Nothing + , algTcGadtSyntax = False + , algTcStupidTheta = [] + , algTcRhs = mkSumTyConRhs cons + , algTcFields = emptyDFsEnv + , algTcFlavour = parent } -- | Makes a tycon suitable for use during type-checking. It stores -- a variety of details about the definition of the TyCon, but no @@ -1971,19 +1897,10 @@ mkTcTyCon :: Name -> TyConFlavour -- ^ What sort of 'TyCon' this represents -> TyCon mkTcTyCon name binders res_kind scoped_tvs poly flav - = let tc = - TcTyCon { tyConUnique = getUnique name - , tyConName = name - , tyConTyVars = binderVars binders - , tyConBinders = binders - , tyConResKind = res_kind - , tyConKind = mkTyConKind binders res_kind - , tyConArity = length binders - , tyConNullaryTy = mkNakedTyConTy tc - , tcTyConScopedTyVars = scoped_tvs - , tcTyConIsPoly = poly - , tcTyConFlavour = flav } - in tc + = mkTyCon name binders res_kind (constRoles binders Nominal) $ + TcTyCon { tctc_scoped_tvs = scoped_tvs + , tctc_is_poly = poly + , tctc_flavour = flav } -- | No scoped type variables (to be used with mkTcTyCon). noTcTyConScopedTyVars :: [(Name, TcTyVar)] @@ -2000,64 +1917,29 @@ mkPrimTyCon :: Name -> [TyConBinder] -> [Role] -> TyCon mkPrimTyCon name binders res_kind roles - = let tc = - PrimTyCon { - tyConName = name, - tyConUnique = nameUnique name, - tyConBinders = binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = length roles, - tyConNullaryTy = mkNakedTyConTy tc, - tcRoles = roles, - primRepName = mkPrelTyConRepName name - } - in tc + = mkTyCon name binders res_kind roles $ + PrimTyCon { primRepName = mkPrelTyConRepName name } -- | Create a type synonym 'TyCon' mkSynonymTyCon :: Name -> [TyConBinder] -> Kind -- ^ /result/ kind -> [Role] -> Type -> Bool -> Bool -> Bool -> TyCon mkSynonymTyCon name binders res_kind roles rhs is_tau is_fam_free is_forgetful - = let tc = - SynonymTyCon { - tyConName = name, - tyConUnique = nameUnique name, - tyConBinders = binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = length binders, - tyConNullaryTy = mkNakedTyConTy tc, - tyConTyVars = binderVars binders, - tcRoles = roles, - synTcRhs = rhs, - synIsTau = is_tau, - synIsFamFree = is_fam_free, - synIsForgetful = is_forgetful - } - in tc + = mkTyCon name binders res_kind roles $ + SynonymTyCon { synTcRhs = rhs + , synIsTau = is_tau + , synIsFamFree = is_fam_free + , synIsForgetful = is_forgetful } -- | Create a type family 'TyCon' mkFamilyTyCon :: Name -> [TyConBinder] -> Kind -- ^ /result/ kind -> Maybe Name -> FamTyConFlav -> Maybe Class -> Injectivity -> TyCon mkFamilyTyCon name binders res_kind resVar flav parent inj - = let tc = - FamilyTyCon - { tyConUnique = nameUnique name - , tyConName = name - , tyConBinders = binders - , tyConResKind = res_kind - , tyConKind = mkTyConKind binders res_kind - , tyConArity = length binders - , tyConNullaryTy = mkNakedTyConTy tc - , tyConTyVars = binderVars binders - , famTcResVar = resVar - , famTcFlav = flav - , famTcParent = classTyCon <$> parent - , famTcInj = inj - } - in tc - + = mkTyCon name binders res_kind (constRoles binders Nominal) $ + FamilyTyCon { famTcResVar = resVar + , famTcFlav = flav + , famTcParent = classTyCon <$> parent + , famTcInj = inj } -- | Create a promoted data constructor 'TyCon' -- Somewhat dodgily, we give it the same Name @@ -2067,43 +1949,36 @@ mkPromotedDataCon :: DataCon -> Name -> TyConRepName -> [TyConPiTyBinder] -> Kind -> [Role] -> PromDataConInfo -> TyCon mkPromotedDataCon con name rep_name binders res_kind roles rep_info - = let tc = - PromotedDataCon { - tyConUnique = nameUnique name, - tyConName = name, - tyConArity = length roles, - tyConNullaryTy = mkNakedTyConTy tc, - tcRoles = roles, - tyConBinders = binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - dataCon = con, - tcRepName = rep_name, - promDcInfo = rep_info - } - in tc + = mkTyCon name binders res_kind roles $ + PromotedDataCon { dataCon = con + , tcRepName = rep_name + , promDcInfo = rep_info } -- | Test if the 'TyCon' is algebraic but abstract (invisible data constructors) isAbstractTyCon :: TyCon -> Bool -isAbstractTyCon (AlgTyCon { algTcRhs = AbstractTyCon {} }) = True -isAbstractTyCon _ = False +isAbstractTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = AbstractTyCon {} } <- details = True + | otherwise = False -- | Does this 'TyCon' represent something that cannot be defined in Haskell? isPrimTyCon :: TyCon -> Bool -isPrimTyCon (PrimTyCon {}) = True -isPrimTyCon _ = False +isPrimTyCon (TyCon { tyConDetails = details }) + | PrimTyCon {} <- details = True + | otherwise = False -- | Returns @True@ if the supplied 'TyCon' resulted from either a -- @data@ or @newtype@ declaration isAlgTyCon :: TyCon -> Bool -isAlgTyCon (AlgTyCon {}) = True -isAlgTyCon _ = False +isAlgTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {} <- details = True + | otherwise = False -- | Returns @True@ for vanilla AlgTyCons -- that is, those created -- with a @data@ or @newtype@ declaration. isVanillaAlgTyCon :: TyCon -> Bool -isVanillaAlgTyCon (AlgTyCon { algTcFlavour = VanillaAlgTyCon _ }) = True -isVanillaAlgTyCon _ = False +isVanillaAlgTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcFlavour = VanillaAlgTyCon _ } <- details = True + | otherwise = False isDataTyCon :: TyCon -> Bool -- ^ Returns @True@ for data types that are /definitely/ represented by @@ -2117,7 +1992,8 @@ isDataTyCon :: TyCon -> Bool -- -- NB: for a data type family, only the /instance/ 'TyCon's -- get an info table. The family declaration 'TyCon' does not -isDataTyCon (AlgTyCon {algTcRhs = rhs}) +isDataTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = rhs} <- details = case rhs of TupleTyCon { tup_sort = sort } -> isBoxed (tupleSortBoxity sort) @@ -2133,9 +2009,10 @@ isDataTyCon _ = False -- | Was this 'TyCon' declared as "type data"? -- See Note [Type data declarations] in GHC.Rename.Module. isTypeDataTyCon :: TyCon -> Bool -isTypeDataTyCon (AlgTyCon {algTcRhs = DataTyCon {is_type_data = type_data }}) - = type_data -isTypeDataTyCon _ = False +isTypeDataTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = DataTyCon {is_type_data = type_data }} <- details + = type_data + | otherwise = False -- | 'isInjectiveTyCon' is true of 'TyCon's for which this property holds -- (where r is the role passed in): @@ -2143,31 +2020,39 @@ isTypeDataTyCon _ = False -- (where r1, r2, and r3, are the roles given by tyConRolesX tc r) -- See also Note [Decomposing TyConApp equalities] in "GHC.Tc.Solver.Canonical" isInjectiveTyCon :: TyCon -> Role -> Bool -isInjectiveTyCon _ Phantom = True -- Vacuously; (t1 ~P t2) holes for all t1, t2! - -isInjectiveTyCon (AlgTyCon {}) Nominal = True -isInjectiveTyCon (AlgTyCon {algTcRhs = rhs}) Representational - = isGenInjAlgRhs rhs -isInjectiveTyCon (SynonymTyCon {}) _ = False -isInjectiveTyCon (FamilyTyCon { famTcFlav = DataFamilyTyCon _ }) - Nominal = True -isInjectiveTyCon (FamilyTyCon { famTcInj = Injective inj }) Nominal = and inj -isInjectiveTyCon (FamilyTyCon {}) _ = False -isInjectiveTyCon (PrimTyCon {}) _ = True -isInjectiveTyCon (PromotedDataCon {}) _ = True -isInjectiveTyCon (TcTyCon {}) _ = True +isInjectiveTyCon (TyCon { tyConDetails = details }) role + = go details role + where + go _ Phantom = True -- Vacuously; (t1 ~P t2) holes for all t1, t2! + go (AlgTyCon {}) Nominal = True + go (AlgTyCon {algTcRhs = rhs}) Representational + = isGenInjAlgRhs rhs + go (SynonymTyCon {}) _ = False + go (FamilyTyCon { famTcFlav = DataFamilyTyCon _ }) + Nominal = True + go (FamilyTyCon { famTcInj = Injective inj }) Nominal = and inj + go (FamilyTyCon {}) _ = False + go (PrimTyCon {}) _ = True + go (PromotedDataCon {}) _ = True + go (TcTyCon {}) _ = True + -- Reply True for TcTyCon to minimise knock on type errors -- See Note [How TcTyCons work] item (1) in GHC.Tc.TyCl + -- | 'isGenerativeTyCon' is true of 'TyCon's for which this property holds -- (where r is the role passed in): -- If (T tys ~r t), then (t's head ~r T). -- See also Note [Decomposing TyConApp equalities] in "GHC.Tc.Solver.Canonical" isGenerativeTyCon :: TyCon -> Role -> Bool -isGenerativeTyCon (FamilyTyCon { famTcFlav = DataFamilyTyCon _ }) Nominal = True -isGenerativeTyCon (FamilyTyCon {}) _ = False - -- in all other cases, injectivity implies generativity -isGenerativeTyCon tc r = isInjectiveTyCon tc r +isGenerativeTyCon tc@(TyCon { tyConDetails = details }) role + = go role details + where + go Nominal (FamilyTyCon { famTcFlav = DataFamilyTyCon _ }) = True + go _ (FamilyTyCon {}) = False + + -- In all other cases, injectivity implies generativity + go r _ = isInjectiveTyCon tc r -- | Is this an 'AlgTyConRhs' of a 'TyCon' that is generative and injective -- with respect to representational equality? @@ -2180,42 +2065,46 @@ isGenInjAlgRhs (NewTyCon {}) = False -- | Is this 'TyCon' that for a @newtype@ isNewTyCon :: TyCon -> Bool -isNewTyCon (AlgTyCon {algTcRhs = NewTyCon {}}) = True -isNewTyCon _ = False +isNewTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon {}} <- details = True + | otherwise = False -- | Take a 'TyCon' apart into the 'TyVar's it scopes over, the 'Type' it -- expands into, and (possibly) a coercion from the representation type to the -- @newtype at . -- Returns @Nothing@ if this is not possible. unwrapNewTyCon_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched) -unwrapNewTyCon_maybe (AlgTyCon { tyConTyVars = tvs, - algTcRhs = NewTyCon { nt_co = co, - nt_rhs = rhs }}) - = Just (tvs, rhs, co) -unwrapNewTyCon_maybe _ = Nothing +unwrapNewTyCon_maybe (TyCon { tyConTyVars = tvs, tyConDetails = details }) + | AlgTyCon { algTcRhs = NewTyCon { nt_co = co, nt_rhs = rhs }} <- details + = Just (tvs, rhs, co) + | otherwise = Nothing unwrapNewTyConEtad_maybe :: TyCon -> Maybe ([TyVar], Type, CoAxiom Unbranched) -unwrapNewTyConEtad_maybe (AlgTyCon { algTcRhs = NewTyCon { nt_co = co, - nt_etad_rhs = (tvs,rhs) }}) - = Just (tvs, rhs, co) -unwrapNewTyConEtad_maybe _ = Nothing +unwrapNewTyConEtad_maybe (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = NewTyCon { nt_co = co + , nt_etad_rhs = (tvs,rhs) }} <- details + = Just (tvs, rhs, co) + | otherwise = Nothing -- | Is this a 'TyCon' representing a regular H98 type synonym (@type@)? {-# INLINE isTypeSynonymTyCon #-} -- See Note [Inlining coreView] in GHC.Core.Type isTypeSynonymTyCon :: TyCon -> Bool -isTypeSynonymTyCon (SynonymTyCon {}) = True -isTypeSynonymTyCon _ = False +isTypeSynonymTyCon (TyCon { tyConDetails = details }) + | SynonymTyCon {} <- details = True + | otherwise = False isTauTyCon :: TyCon -> Bool -isTauTyCon (SynonymTyCon { synIsTau = is_tau }) = is_tau -isTauTyCon _ = True +isTauTyCon (TyCon { tyConDetails = details }) + | SynonymTyCon { synIsTau = is_tau } <- details = is_tau + | otherwise = True -- | Is this tycon neither a type family nor a synonym that expands -- to a type family? isFamFreeTyCon :: TyCon -> Bool -isFamFreeTyCon (SynonymTyCon { synIsFamFree = fam_free }) = fam_free -isFamFreeTyCon (FamilyTyCon { famTcFlav = flav }) = isDataFamFlav flav -isFamFreeTyCon _ = True +isFamFreeTyCon (TyCon { tyConDetails = details }) + | SynonymTyCon { synIsFamFree = fam_free } <- details = fam_free + | FamilyTyCon { famTcFlav = flav } <- details = isDataFamFlav flav + | otherwise = True -- | Is this a forgetful type synonym? If this is a type synonym whose -- RHS does not mention one (or more) of its bound variables, returns @@ -2223,8 +2112,9 @@ isFamFreeTyCon _ = True -- True may not mean anything, as the test to set this flag is -- conservative. isForgetfulSynTyCon :: TyCon -> Bool -isForgetfulSynTyCon (SynonymTyCon { synIsForgetful = forget }) = forget -isForgetfulSynTyCon _ = False +isForgetfulSynTyCon (TyCon { tyConDetails = details }) + | SynonymTyCon { synIsForgetful = forget } <- details = forget + | otherwise = False -- As for newtypes, it is in some contexts important to distinguish between -- closed synonyms and synonym families, as synonym families have no unique @@ -2245,71 +2135,86 @@ tyConMustBeSaturated = tcFlavourMustBeSaturated . tyConFlavour -- | Is this an algebraic 'TyCon' declared with the GADT syntax? isGadtSyntaxTyCon :: TyCon -> Bool -isGadtSyntaxTyCon (AlgTyCon { algTcGadtSyntax = res }) = res -isGadtSyntaxTyCon _ = False +isGadtSyntaxTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcGadtSyntax = res } <- details = res + | otherwise = False -- | Is this an algebraic 'TyCon' which is just an enumeration of values? isEnumerationTyCon :: TyCon -> Bool -- See Note [Enumeration types] in GHC.Core.TyCon -isEnumerationTyCon (AlgTyCon { tyConArity = arity, algTcRhs = rhs }) +isEnumerationTyCon (TyCon { tyConArity = arity, tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details = case rhs of DataTyCon { is_enum = res } -> res TupleTyCon {} -> arity == 0 _ -> False -isEnumerationTyCon _ = False + | otherwise = False -- | Is this a 'TyCon', synonym or otherwise, that defines a family? isFamilyTyCon :: TyCon -> Bool -isFamilyTyCon (FamilyTyCon {}) = True -isFamilyTyCon _ = False +isFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon {} <- details = True + | otherwise = False -- | Is this a 'TyCon', synonym or otherwise, that defines a family with -- instances? isOpenFamilyTyCon :: TyCon -> Bool -isOpenFamilyTyCon (FamilyTyCon {famTcFlav = flav }) - | OpenSynFamilyTyCon <- flav = True - | DataFamilyTyCon {} <- flav = True -isOpenFamilyTyCon _ = False +isOpenFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = flav } <- details + = case flav of + OpenSynFamilyTyCon -> True + DataFamilyTyCon {} -> True + _ -> False + | otherwise = False -- | Is this a synonym 'TyCon' that can have may have further instances appear? isTypeFamilyTyCon :: TyCon -> Bool -isTypeFamilyTyCon (FamilyTyCon { famTcFlav = flav }) = not (isDataFamFlav flav) -isTypeFamilyTyCon _ = False +isTypeFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon { famTcFlav = flav } <- details = not (isDataFamFlav flav) + | otherwise = False -- | Is this a synonym 'TyCon' that can have may have further instances appear? isDataFamilyTyCon :: TyCon -> Bool -isDataFamilyTyCon (FamilyTyCon { famTcFlav = flav }) = isDataFamFlav flav -isDataFamilyTyCon _ = False +isDataFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon { famTcFlav = flav } <- details = isDataFamFlav flav + | otherwise = False -- | Is this an open type family TyCon? isOpenTypeFamilyTyCon :: TyCon -> Bool -isOpenTypeFamilyTyCon (FamilyTyCon {famTcFlav = OpenSynFamilyTyCon }) = True -isOpenTypeFamilyTyCon _ = False +isOpenTypeFamilyTyCon (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = OpenSynFamilyTyCon } <- details = True + | otherwise = False -- | Is this a non-empty closed type family? Returns 'Nothing' for -- abstract or empty closed families. isClosedSynFamilyTyConWithAxiom_maybe :: TyCon -> Maybe (CoAxiom Branched) -isClosedSynFamilyTyConWithAxiom_maybe - (FamilyTyCon {famTcFlav = ClosedSynFamilyTyCon mb}) = mb -isClosedSynFamilyTyConWithAxiom_maybe _ = Nothing +isClosedSynFamilyTyConWithAxiom_maybe (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = ClosedSynFamilyTyCon mb} <- details = mb + | otherwise = Nothing + +isBuiltInSynFamTyCon_maybe :: TyCon -> Maybe BuiltInSynFamily +isBuiltInSynFamTyCon_maybe (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = BuiltInSynFamTyCon ops } <- details = Just ops + | otherwise = Nothing + +-- | Extract type variable naming the result of injective type family +tyConFamilyResVar_maybe :: TyCon -> Maybe Name +tyConFamilyResVar_maybe (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcResVar = res} <- details = res + | otherwise = Nothing -- | @'tyConInjectivityInfo' tc@ returns @'Injective' is@ if @tc@ is an -- injective tycon (where @is@ states for which 'tyConBinders' @tc@ is -- injective), or 'NotInjective' otherwise. tyConInjectivityInfo :: TyCon -> Injectivity -tyConInjectivityInfo tc - | FamilyTyCon { famTcInj = inj } <- tc +tyConInjectivityInfo tc@(TyCon { tyConDetails = details }) + | FamilyTyCon { famTcInj = inj } <- details = inj | isInjectiveTyCon tc Nominal = Injective (replicate (tyConArity tc) True) | otherwise = NotInjective -isBuiltInSynFamTyCon_maybe :: TyCon -> Maybe BuiltInSynFamily -isBuiltInSynFamTyCon_maybe - (FamilyTyCon {famTcFlav = BuiltInSynFamTyCon ops }) = Just ops -isBuiltInSynFamTyCon_maybe _ = Nothing - isDataFamFlav :: FamTyConFlav -> Bool isDataFamFlav (DataFamilyTyCon {}) = True -- Data family isDataFamFlav _ = False -- Type synonym family @@ -2338,39 +2243,50 @@ isTupleTyCon :: TyCon -> Bool -- 'isTupleTyCon', because they are built as 'AlgTyCons'. However they -- get spat into the interface file as tuple tycons, so I don't think -- it matters. -isTupleTyCon (AlgTyCon { algTcRhs = TupleTyCon {} }) = True -isTupleTyCon _ = False +isTupleTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = TupleTyCon {} } <- details = True + | otherwise = False tyConTuple_maybe :: TyCon -> Maybe TupleSort -tyConTuple_maybe (AlgTyCon { algTcRhs = rhs }) - | TupleTyCon { tup_sort = sort} <- rhs = Just sort -tyConTuple_maybe _ = Nothing +tyConTuple_maybe (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + , TupleTyCon { tup_sort = sort} <- rhs = Just sort + | otherwise = Nothing -- | Is this the 'TyCon' for an unboxed tuple? isUnboxedTupleTyCon :: TyCon -> Bool -isUnboxedTupleTyCon (AlgTyCon { algTcRhs = rhs }) - | TupleTyCon { tup_sort = sort } <- rhs - = not (isBoxed (tupleSortBoxity sort)) -isUnboxedTupleTyCon _ = False +isUnboxedTupleTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + , TupleTyCon { tup_sort = sort } <- rhs + = not (isBoxed (tupleSortBoxity sort)) + | otherwise = False -- | Is this the 'TyCon' for a boxed tuple? isBoxedTupleTyCon :: TyCon -> Bool -isBoxedTupleTyCon (AlgTyCon { algTcRhs = rhs }) - | TupleTyCon { tup_sort = sort } <- rhs - = isBoxed (tupleSortBoxity sort) -isBoxedTupleTyCon _ = False +isBoxedTupleTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + , TupleTyCon { tup_sort = sort } <- rhs + = isBoxed (tupleSortBoxity sort) + | otherwise = False -- | Is this the 'TyCon' for an unboxed sum? isUnboxedSumTyCon :: TyCon -> Bool -isUnboxedSumTyCon (AlgTyCon { algTcRhs = rhs }) - | SumTyCon {} <- rhs - = True -isUnboxedSumTyCon _ = False +isUnboxedSumTyCon (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + , SumTyCon {} <- rhs + = True + | otherwise = False isLiftedAlgTyCon :: TyCon -> Bool -isLiftedAlgTyCon (AlgTyCon { tyConResKind = res_kind }) - = isLiftedTypeKind res_kind -isLiftedAlgTyCon _ = False +isLiftedAlgTyCon (TyCon { tyConResKind = res_kind, tyConDetails = details }) + | AlgTyCon {} <- details = isLiftedTypeKind res_kind + | otherwise = False + +-- | Retrieves the promoted DataCon if this is a PromotedDataCon; +isPromotedDataCon_maybe :: TyCon -> Maybe DataCon +isPromotedDataCon_maybe (TyCon { tyConDetails = details }) + | PromotedDataCon { dataCon = dc } <- details = Just dc + | otherwise = Nothing -- | Is this the 'TyCon' for a /promoted/ tuple? isPromotedTupleTyCon :: TyCon -> Bool @@ -2381,8 +2297,9 @@ isPromotedTupleTyCon tyCon -- | Is this a PromotedDataCon? isPromotedDataCon :: TyCon -> Bool -isPromotedDataCon (PromotedDataCon {}) = True -isPromotedDataCon _ = False +isPromotedDataCon (TyCon { tyConDetails = details }) + | PromotedDataCon {} <- details = True + | otherwise = False -- | This function identifies PromotedDataCon's from data constructors in -- `data T = K1 | K2`, promoted by -XDataKinds. These type constructors @@ -2393,14 +2310,10 @@ isPromotedDataCon _ = False -- represented with their original undecorated names. -- See Note [Type data declarations] in GHC.Rename.Module isDataKindsPromotedDataCon :: TyCon -> Bool -isDataKindsPromotedDataCon (PromotedDataCon { dataCon = dc }) - = not (isTypeDataCon dc) -isDataKindsPromotedDataCon _ = False - --- | Retrieves the promoted DataCon if this is a PromotedDataCon; -isPromotedDataCon_maybe :: TyCon -> Maybe DataCon -isPromotedDataCon_maybe (PromotedDataCon { dataCon = dc }) = Just dc -isPromotedDataCon_maybe _ = Nothing +isDataKindsPromotedDataCon (TyCon { tyConDetails = details }) + | PromotedDataCon { dataCon = dc } <- details + = not (isTypeDataCon dc) + | otherwise = False -- | Is this tycon really meant for use at the kind level? That is, -- should it be permitted without -XDataKinds? @@ -2437,36 +2350,22 @@ isLiftedTypeKindTyConName = (`hasKey` liftedTypeKindTyConKey) -- (namely: boxed and unboxed tuples are wired-in and implicit, -- but constraint tuples are not) isImplicitTyCon :: TyCon -> Bool -isImplicitTyCon (PrimTyCon {}) = True -isImplicitTyCon (PromotedDataCon {}) = True -isImplicitTyCon (AlgTyCon { algTcRhs = rhs, tyConName = name }) - | TupleTyCon {} <- rhs = isWiredInName name - | SumTyCon {} <- rhs = True - | otherwise = False -isImplicitTyCon (FamilyTyCon { famTcParent = parent }) = isJust parent -isImplicitTyCon (SynonymTyCon {}) = False -isImplicitTyCon (TcTyCon {}) = False +isImplicitTyCon (TyCon { tyConName = name, tyConDetails = details }) = go details + where + go (PrimTyCon {}) = True + go (PromotedDataCon {}) = True + go (SynonymTyCon {}) = False + go (TcTyCon {}) = False + go (FamilyTyCon { famTcParent = parent }) = isJust parent + go (AlgTyCon { algTcRhs = rhs }) + | TupleTyCon {} <- rhs = isWiredInName name + | SumTyCon {} <- rhs = True + | otherwise = False tyConCType_maybe :: TyCon -> Maybe CType -tyConCType_maybe tc@(AlgTyCon {}) = tyConCType tc -tyConCType_maybe _ = Nothing - --- | Is this a TcTyCon? (That is, one only used during type-checking?) -isTcTyCon :: TyCon -> Bool -isTcTyCon (TcTyCon {}) = True -isTcTyCon _ = False - -setTcTyConKind :: TyCon -> Kind -> TyCon --- Update the Kind of a TcTyCon --- The new kind is always a zonked version of its previous --- kind, so we don't need to update any other fields. --- See Note [The Purely Kinded Type Invariant (PKTI)] in GHC.Tc.Gen.HsType -setTcTyConKind tc@(TcTyCon {}) kind = let tc' = tc { tyConKind = kind - , tyConNullaryTy = mkNakedTyConTy tc' - -- see Note [Sharing nullary TyConApps] - } - in tc' -setTcTyConKind tc _ = pprPanic "setTcTyConKind" (ppr tc) +tyConCType_maybe (TyCon { tyConDetails = details }) + | AlgTyCon { tyConCType = mb_ctype} <- details = mb_ctype + | otherwise = Nothing -- | Does this 'TyCon' have a syntactically fixed RuntimeRep when fully applied, -- as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete? @@ -2476,31 +2375,33 @@ setTcTyConKind tc _ = pprPanic "setTcTyConKind" (ppr tc) -- -- See Note [Representation-polymorphic TyCons] tcHasFixedRuntimeRep :: TyCon -> Bool -tcHasFixedRuntimeRep (AlgTyCon { algTcRhs = rhs }) = case rhs of - AbstractTyCon {} -> False - -- An abstract TyCon might not have a fixed runtime representation. - -- Note that this is an entirely different matter from the concreteness - -- of the 'TyCon', in the sense of 'isConcreteTyCon'. +tcHasFixedRuntimeRep tc@(TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details + = case rhs of + AbstractTyCon {} -> False + -- An abstract TyCon might not have a fixed runtime representation. + -- Note that this is an entirely different matter from the concreteness + -- of the 'TyCon', in the sense of 'isConcreteTyCon'. - DataTyCon { data_fixed_lev = fixed_lev } -> fixed_lev - -- A datatype might not have a fixed levity with UnliftedDatatypes (#20423). - -- NB: the current representation-polymorphism checks require that - -- the representation be fully-known, including levity variables. - -- This might be relaxed in the future (#15532). + DataTyCon { data_fixed_lev = fixed_lev } -> fixed_lev + -- A datatype might not have a fixed levity with UnliftedDatatypes (#20423). + -- NB: the current representation-polymorphism checks require that + -- the representation be fully-known, including levity variables. + -- This might be relaxed in the future (#15532). - TupleTyCon { tup_sort = tuple_sort } -> isBoxed (tupleSortBoxity tuple_sort) + TupleTyCon { tup_sort = tuple_sort } -> isBoxed (tupleSortBoxity tuple_sort) - SumTyCon {} -> False -- only unboxed sums here + SumTyCon {} -> False -- only unboxed sums here - NewTyCon { nt_fixed_rep = fixed_rep } -> fixed_rep - -- A newtype might not have a fixed runtime representation - -- with UnliftedNewtypes (#17360) + NewTyCon { nt_fixed_rep = fixed_rep } -> fixed_rep + -- A newtype might not have a fixed runtime representation + -- with UnliftedNewtypes (#17360) -tcHasFixedRuntimeRep SynonymTyCon{} = False -- conservative choice -tcHasFixedRuntimeRep FamilyTyCon{} = False -tcHasFixedRuntimeRep PrimTyCon{} = True -tcHasFixedRuntimeRep TcTyCon{} = False -tcHasFixedRuntimeRep tc at PromotedDataCon{} = pprPanic "tcHasFixedRuntimeRep datacon" (ppr tc) + | SynonymTyCon {} <- details = False -- conservative choice + | FamilyTyCon{} <- details = False + | PrimTyCon{} <- details = True + | TcTyCon{} <- details = False + | PromotedDataCon{} <- details = pprPanic "tcHasFixedRuntimeRep datacon" (ppr tc) -- | Is this 'TyCon' concrete (i.e. not a synonym/type family)? -- @@ -2526,6 +2427,40 @@ isConcreteTyConFlavour = \case BuiltInTypeFlavour -> True PromotedDataConFlavour -> True +{- +----------------------------------------------- +-- TcTyCon +----------------------------------------------- +-} + +-- | Is this a TcTyCon? (That is, one only used during type-checking?) +isTcTyCon :: TyCon -> Bool +isTcTyCon (TyCon { tyConDetails = details }) + | TcTyCon {} <- details = True + | otherwise = False + +setTcTyConKind :: TyCon -> Kind -> TyCon +-- Update the Kind of a TcTyCon +-- The new kind is always a zonked version of its previous +-- kind, so we don't need to update any other fields. +-- See Note [The Purely Kinded Type Invariant (PKTI)] in GHC.Tc.Gen.HsType +setTcTyConKind tc kind + = assert (isMonoTcTyCon tc) $ + let tc' = tc { tyConKind = kind + , tyConNullaryTy = mkNakedTyConTy tc' } + -- See Note [Sharing nullary TyConApps] + in tc' + +isMonoTcTyCon :: TyCon -> Bool +isMonoTcTyCon (TyCon { tyConDetails = details }) + | TcTyCon { tctc_is_poly = is_poly } <- details = not is_poly + | otherwise = False + +tcTyConScopedTyVars :: TyCon -> [(Name,TcTyVar)] +tcTyConScopedTyVars tc@(TyCon { tyConDetails = details }) + | TcTyCon { tctc_scoped_tvs = scoped_tvs } <- details = scoped_tvs + | otherwise = pprPanic "tcTyConScopedTyVars" (ppr tc) + {- ----------------------------------------------- -- Expand type-constructor applications @@ -2546,8 +2481,9 @@ expandSynTyCon_maybe -- ^ Expand a type synonym application -- Return Nothing if the TyCon is not a synonym, -- or if not enough arguments are supplied -expandSynTyCon_maybe tc tys - | SynonymTyCon { tyConTyVars = tvs, synTcRhs = rhs, tyConArity = arity } <- tc +expandSynTyCon_maybe (TyCon { tyConTyVars = tvs, tyConArity = arity + , tyConDetails = details }) tys + | SynonymTyCon { synTcRhs = rhs } <- details = if arity == 0 then ExpandsSyn [] rhs tys -- Avoid a bit of work in the case of nullary synonyms else case tys `listLengthCmp` arity of @@ -2567,17 +2503,17 @@ expandSynTyCon_maybe tc tys -- exported tycon can have a pattern synonym bundled with it, e.g., -- module Foo (TyCon(.., PatSyn)) where isTyConWithSrcDataCons :: TyCon -> Bool -isTyConWithSrcDataCons (AlgTyCon { algTcRhs = rhs, algTcFlavour = parent }) = - case rhs of - DataTyCon {} -> isSrcParent - NewTyCon {} -> isSrcParent - TupleTyCon {} -> isSrcParent - _ -> False - where - isSrcParent = isNoParent parent -isTyConWithSrcDataCons (FamilyTyCon { famTcFlav = DataFamilyTyCon {} }) - = True -- #14058 -isTyConWithSrcDataCons _ = False +isTyConWithSrcDataCons (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs, algTcFlavour = parent } <- details + , let isSrcParent = isNoParent parent + = case rhs of + DataTyCon {} -> isSrcParent + NewTyCon {} -> isSrcParent + TupleTyCon {} -> isSrcParent + _ -> False + | FamilyTyCon { famTcFlav = DataFamilyTyCon {} } <- details + = True -- #14058 + | otherwise = False -- | As 'tyConDataCons_maybe', but returns the empty list of constructors if no @@ -2591,7 +2527,8 @@ tyConDataCons tycon = tyConDataCons_maybe tycon `orElse` [] -- is the sort that can have any constructors (note: this does not include -- abstract algebraic types) tyConDataCons_maybe :: TyCon -> Maybe [DataCon] -tyConDataCons_maybe (AlgTyCon {algTcRhs = rhs}) +tyConDataCons_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = rhs} <- details = case rhs of DataTyCon { data_cons = cons } -> Just cons NewTyCon { data_con = con } -> Just [con] @@ -2605,13 +2542,14 @@ tyConDataCons_maybe _ = Nothing -- is returned. If the 'TyCon' has more than one constructor, or represents a -- primitive or function type constructor then @Nothing@ is returned. tyConSingleDataCon_maybe :: TyCon -> Maybe DataCon -tyConSingleDataCon_maybe (AlgTyCon { algTcRhs = rhs }) +tyConSingleDataCon_maybe (TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details = case rhs of DataTyCon { data_cons = [c] } -> Just c TupleTyCon { data_con = c } -> Just c NewTyCon { data_con = c } -> Just c _ -> Nothing -tyConSingleDataCon_maybe _ = Nothing + | otherwise = Nothing -- | Like 'tyConSingleDataCon_maybe', but panics if 'Nothing'. tyConSingleDataCon :: TyCon -> DataCon @@ -2640,68 +2578,56 @@ tyConAlgDataCons_maybe tycon -- | Determine the number of value constructors a 'TyCon' has. Panics if the -- 'TyCon' is not algebraic or a tuple tyConFamilySize :: TyCon -> Int -tyConFamilySize tc@(AlgTyCon { algTcRhs = rhs }) +tyConFamilySize tc@(TyCon { tyConDetails = details }) + | AlgTyCon { algTcRhs = rhs } <- details = case rhs of DataTyCon { data_cons_size = size } -> size NewTyCon {} -> 1 TupleTyCon {} -> 1 SumTyCon { data_cons_size = size } -> size _ -> pprPanic "tyConFamilySize 1" (ppr tc) -tyConFamilySize tc = pprPanic "tyConFamilySize 2" (ppr tc) + | otherwise = pprPanic "tyConFamilySize 2" (ppr tc) -- | Extract an 'AlgTyConRhs' with information about data constructors from an -- algebraic or tuple 'TyCon'. Panics for any other sort of 'TyCon' algTyConRhs :: TyCon -> AlgTyConRhs -algTyConRhs (AlgTyCon {algTcRhs = rhs}) = rhs -algTyConRhs other = pprPanic "algTyConRhs" (ppr other) - --- | Extract type variable naming the result of injective type family -tyConFamilyResVar_maybe :: TyCon -> Maybe Name -tyConFamilyResVar_maybe (FamilyTyCon {famTcResVar = res}) = res -tyConFamilyResVar_maybe _ = Nothing - --- | Get the list of roles for the type parameters of a TyCon -tyConRoles :: TyCon -> [Role] --- See also Note [TyCon Role signatures] -tyConRoles tc - = case tc of - { AlgTyCon { tcRoles = roles } -> roles - ; SynonymTyCon { tcRoles = roles } -> roles - ; FamilyTyCon {} -> const_role Nominal - ; PrimTyCon { tcRoles = roles } -> roles - ; PromotedDataCon { tcRoles = roles } -> roles - ; TcTyCon {} -> const_role Nominal - } - where - const_role r = replicate (tyConArity tc) r +algTyConRhs tc@(TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = rhs} <- details = rhs + | otherwise = pprPanic "algTyConRhs" (ppr tc) -- | Extract the bound type variables and type expansion of a type synonym -- 'TyCon'. Panics if the 'TyCon' is not a synonym newTyConRhs :: TyCon -> ([TyVar], Type) -newTyConRhs (AlgTyCon {tyConTyVars = tvs, algTcRhs = NewTyCon { nt_rhs = rhs }}) - = (tvs, rhs) -newTyConRhs tycon = pprPanic "newTyConRhs" (ppr tycon) +newTyConRhs tc@(TyCon { tyConTyVars = tvs, tyConDetails = details }) + | AlgTyCon { algTcRhs = NewTyCon { nt_rhs = rhs }} <- details + = (tvs, rhs) + | otherwise + = pprPanic "newTyConRhs" (ppr tc) -- | The number of type parameters that need to be passed to a newtype to -- resolve it. May be less than in the definition if it can be eta-contracted. newTyConEtadArity :: TyCon -> Int -newTyConEtadArity (AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }}) - = length (fst tvs_rhs) -newTyConEtadArity tycon = pprPanic "newTyConEtadArity" (ppr tycon) +newTyConEtadArity tc@(TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }} <- details + = length (fst tvs_rhs) + | otherwise + = pprPanic "newTyConEtadArity" (ppr tc) -- | Extract the bound type variables and type expansion of an eta-contracted -- type synonym 'TyCon'. Panics if the 'TyCon' is not a synonym newTyConEtadRhs :: TyCon -> ([TyVar], Type) -newTyConEtadRhs (AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }}) = tvs_rhs -newTyConEtadRhs tycon = pprPanic "newTyConEtadRhs" (ppr tycon) +newTyConEtadRhs tc@(TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon { nt_etad_rhs = tvs_rhs }} <- details = tvs_rhs + | otherwise = pprPanic "newTyConEtadRhs" (ppr tc) -- | Extracts the @newtype@ coercion from such a 'TyCon', which can be used to -- construct something with the @newtype at s type from its representation type -- (right hand side). If the supplied 'TyCon' is not a @newtype@, returns -- @Nothing@ newTyConCo_maybe :: TyCon -> Maybe (CoAxiom Unbranched) -newTyConCo_maybe (AlgTyCon {algTcRhs = NewTyCon { nt_co = co }}) = Just co -newTyConCo_maybe _ = Nothing +newTyConCo_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon { nt_co = co }} <- details = Just co + | otherwise = Nothing newTyConCo :: TyCon -> CoAxiom Unbranched newTyConCo tc = case newTyConCo_maybe tc of @@ -2709,83 +2635,93 @@ newTyConCo tc = case newTyConCo_maybe tc of Nothing -> pprPanic "newTyConCo" (ppr tc) newTyConDataCon_maybe :: TyCon -> Maybe DataCon -newTyConDataCon_maybe (AlgTyCon {algTcRhs = NewTyCon { data_con = con }}) = Just con -newTyConDataCon_maybe _ = Nothing +newTyConDataCon_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcRhs = NewTyCon { data_con = con }} <- details = Just con + | otherwise = Nothing -- | Find the \"stupid theta\" of the 'TyCon'. A \"stupid theta\" is the context -- to the left of an algebraic type declaration, e.g. @Eq a@ in the declaration -- @data Eq a => T a ... at . See @Note [The stupid context]@ in "GHC.Core.DataCon". tyConStupidTheta :: TyCon -> [PredType] -tyConStupidTheta (AlgTyCon {algTcStupidTheta = stupid}) = stupid -tyConStupidTheta (PrimTyCon {}) = [] -tyConStupidTheta tycon = pprPanic "tyConStupidTheta" (ppr tycon) +tyConStupidTheta tc@(TyCon { tyConDetails = details }) + | AlgTyCon {algTcStupidTheta = stupid} <- details = stupid + | PrimTyCon {} <- details = [] + | otherwise = pprPanic "tyConStupidTheta" (ppr tc) -- | Extract the 'TyVar's bound by a vanilla type synonym -- and the corresponding (unsubstituted) right hand side. synTyConDefn_maybe :: TyCon -> Maybe ([TyVar], Type) -synTyConDefn_maybe (SynonymTyCon {tyConTyVars = tyvars, synTcRhs = ty}) +synTyConDefn_maybe (TyCon { tyConTyVars = tyvars, tyConDetails = details }) + | SynonymTyCon {synTcRhs = ty} <- details = Just (tyvars, ty) -synTyConDefn_maybe _ = Nothing + | otherwise + = Nothing -- | Extract the information pertaining to the right hand side of a type synonym -- (@type@) declaration. synTyConRhs_maybe :: TyCon -> Maybe Type -synTyConRhs_maybe (SynonymTyCon {synTcRhs = rhs}) = Just rhs -synTyConRhs_maybe _ = Nothing +synTyConRhs_maybe (TyCon { tyConDetails = details }) + | SynonymTyCon {synTcRhs = rhs} <- details = Just rhs + | otherwise = Nothing -- | Extract the flavour of a type family (with all the extra information that -- it carries) famTyConFlav_maybe :: TyCon -> Maybe FamTyConFlav -famTyConFlav_maybe (FamilyTyCon {famTcFlav = flav}) = Just flav -famTyConFlav_maybe _ = Nothing +famTyConFlav_maybe (TyCon { tyConDetails = details }) + | FamilyTyCon {famTcFlav = flav} <- details = Just flav + | otherwise = Nothing -- | Is this 'TyCon' that for a class instance? isClassTyCon :: TyCon -> Bool -isClassTyCon (AlgTyCon {algTcFlavour = ClassTyCon {}}) = True -isClassTyCon _ = False +isClassTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = ClassTyCon {}} <- details = True + | otherwise = False -- | If this 'TyCon' is that for a class instance, return the class it is for. -- Otherwise returns @Nothing@ tyConClass_maybe :: TyCon -> Maybe Class -tyConClass_maybe (AlgTyCon {algTcFlavour = ClassTyCon clas _}) = Just clas -tyConClass_maybe _ = Nothing +tyConClass_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = ClassTyCon clas _} <- details = Just clas + | otherwise = Nothing -- | Return the associated types of the 'TyCon', if any tyConATs :: TyCon -> [TyCon] -tyConATs (AlgTyCon {algTcFlavour = ClassTyCon clas _}) = classATs clas -tyConATs _ = [] +tyConATs (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = ClassTyCon clas _} <- details = classATs clas + | otherwise = [] ---------------------------------------------------------------------------- -- | Is this 'TyCon' that for a data family instance? isFamInstTyCon :: TyCon -> Bool -isFamInstTyCon (AlgTyCon {algTcFlavour = DataFamInstTyCon {} }) - = True -isFamInstTyCon _ = False +isFamInstTyCon (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = DataFamInstTyCon {} } <- details = True + | otherwise = False tyConFamInstSig_maybe :: TyCon -> Maybe (TyCon, [Type], CoAxiom Unbranched) -tyConFamInstSig_maybe (AlgTyCon {algTcFlavour = DataFamInstTyCon ax f ts }) - = Just (f, ts, ax) -tyConFamInstSig_maybe _ = Nothing +tyConFamInstSig_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = DataFamInstTyCon ax f ts } <- details = Just (f, ts, ax) + | otherwise = Nothing -- | If this 'TyCon' is that of a data family instance, return the family in question -- and the instance types. Otherwise, return @Nothing@ tyConFamInst_maybe :: TyCon -> Maybe (TyCon, [Type]) -tyConFamInst_maybe (AlgTyCon {algTcFlavour = DataFamInstTyCon _ f ts }) - = Just (f, ts) -tyConFamInst_maybe _ = Nothing +tyConFamInst_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = DataFamInstTyCon _ f ts } <- details = Just (f, ts) + | otherwise = Nothing -- | If this 'TyCon' is that of a data family instance, return a 'TyCon' which -- represents a coercion identifying the representation type with the type -- instance family. Otherwise, return @Nothing@ tyConFamilyCoercion_maybe :: TyCon -> Maybe (CoAxiom Unbranched) -tyConFamilyCoercion_maybe (AlgTyCon {algTcFlavour = DataFamInstTyCon ax _ _ }) - = Just ax -tyConFamilyCoercion_maybe _ = Nothing +tyConFamilyCoercion_maybe (TyCon { tyConDetails = details }) + | AlgTyCon {algTcFlavour = DataFamInstTyCon ax _ _ } <- details = Just ax + | otherwise = Nothing -- | Extract any 'RuntimeRepInfo' from this TyCon tyConPromDataConInfo :: TyCon -> PromDataConInfo -tyConPromDataConInfo (PromotedDataCon { promDcInfo = rri }) = rri -tyConPromDataConInfo _ = NoPromInfo +tyConPromDataConInfo (TyCon { tyConDetails = details }) + | PromotedDataCon { promDcInfo = rri } <- details = rri + | otherwise = NoPromInfo -- could panic in that second case. But Douglas Adams told me not to. {- @@ -2875,26 +2811,30 @@ instance Outputable TyConFlavour where go PromotedDataConFlavour = "promoted data constructor" tyConFlavour :: TyCon -> TyConFlavour -tyConFlavour (AlgTyCon { algTcFlavour = parent, algTcRhs = rhs }) - | ClassTyCon _ _ <- parent = ClassFlavour - | otherwise = case rhs of +tyConFlavour (TyCon { tyConDetails = details }) + | AlgTyCon { algTcFlavour = parent, algTcRhs = rhs } <- details + = case parent of + ClassTyCon {} -> ClassFlavour + _ -> case rhs of TupleTyCon { tup_sort = sort } -> TupleFlavour (tupleSortBoxity sort) SumTyCon {} -> SumFlavour DataTyCon {} -> DataTypeFlavour NewTyCon {} -> NewtypeFlavour AbstractTyCon {} -> AbstractTypeFlavour -tyConFlavour (FamilyTyCon { famTcFlav = flav, famTcParent = parent }) + + | FamilyTyCon { famTcFlav = flav, famTcParent = parent } <- details = case flav of DataFamilyTyCon{} -> DataFamilyFlavour parent OpenSynFamilyTyCon -> OpenTypeFamilyFlavour parent ClosedSynFamilyTyCon{} -> ClosedTypeFamilyFlavour AbstractClosedSynFamilyTyCon -> ClosedTypeFamilyFlavour BuiltInSynFamTyCon{} -> ClosedTypeFamilyFlavour -tyConFlavour (SynonymTyCon {}) = TypeSynonymFlavour -tyConFlavour (PrimTyCon {}) = BuiltInTypeFlavour -tyConFlavour (PromotedDataCon {}) = PromotedDataConFlavour -tyConFlavour (TcTyCon { tcTyConFlavour = flav }) = flav + + | SynonymTyCon {} <- details = TypeSynonymFlavour + | PrimTyCon {} <- details = BuiltInTypeFlavour + | PromotedDataCon {} <- details = PromotedDataConFlavour + | TcTyCon { tctc_flavour = flav } <-details = flav -- | Can this flavour of 'TyCon' appear unsaturated? tcFlavourMustBeSaturated :: TyConFlavour -> Bool ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -714,7 +714,8 @@ dsDo ctx stmts ; body' <- dsLExpr $ noLocA $ HsDo body_ty ctx (noLocA stmts) ; let match_args (pat, fail_op) (vs,body) - = do { var <- selectSimpleMatchVarL ManyTy pat + = putSrcSpanDs (getLocA pat) $ + do { var <- selectSimpleMatchVarL ManyTy pat ; match <- matchSinglePatVar var Nothing (StmtCtxt (HsDoStmt ctx)) pat body_ty (cantFailMatchResult body) ; match_code <- dsHandleMonadicFailure ctx pat match fail_op ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -532,7 +532,7 @@ tyConToIfaceDecl env tycon , IfaceData { ifName = getName tycon, ifBinders = if_binders, ifResKind = if_res_kind, - ifCType = tyConCType tycon, + ifCType = tyConCType_maybe tycon, ifRoles = tyConRoles tycon, ifCtxt = tidyToIfaceContext tc_env1 (tyConStupidTheta tycon), ifCons = ifaceConDecls (algTyConRhs tycon), ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -123,6 +123,7 @@ import GHC.Driver.Env.KnotVars import GHC.Unit.Module.WholeCoreBindings import Data.IORef import Data.Foldable +import GHC.Builtin.Names (ioTyConName, rOOT_MAIN) {- This module takes @@ -930,7 +931,17 @@ tc_iface_binding i IfUseUnfoldingRhs = return (unfoldingTemplate $ realIdUnfoldi tc_iface_binding _ (IfRhs rhs) = tcIfaceExpr rhs mk_top_id :: IfaceTopBndrInfo -> IfL Id -mk_top_id (IfGblTopBndr gbl_name) = tcIfaceExtId gbl_name +mk_top_id (IfGblTopBndr gbl_name) + -- See Note [Root-main Id] + -- This special binding is actually defined in the current module + -- (hence don't go looking for it externally) but the module name is rOOT_MAIN + -- rather than the current module so we need this special case. + -- See some similar logic in `GHC.Rename.Env`. + | Just rOOT_MAIN == nameModule_maybe gbl_name + = do + ATyCon ioTyCon <- tcIfaceGlobal ioTyConName + return $ mkExportedVanillaId gbl_name (mkTyConApp ioTyCon [unitTy]) + | otherwise = tcIfaceExtId gbl_name mk_top_id (IfLclTopBndr raw_name iface_type info details) = do name <- newIfaceName (mkVarOccFS raw_name) ty <- tcIfaceType iface_type ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -207,6 +207,11 @@ newTopSrcBinder (L loc rdr_name) -- the nice Exact name for the TyCon gets swizzled to an Orig name. -- Hence the badOrigBinding error message. -- + + -- MP 2022: I suspect this code path is never called for `rOOT_MAIN` anymore + -- because External Core has been removed but we instead have some similar logic for + -- serialising whole programs into interface files in GHC.IfaceToCore.mk_top_id. + -- Except for the ":Main.main = ..." definition inserted into -- the Main module; ugh! ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -2121,7 +2121,7 @@ reifyTyCon tc | isTypeFamilyTyCon tc = do { let tvs = tyConTyVars tc res_kind = tyConResKind tc - resVar = famTcResVar tc + resVar = tyConFamilyResVar_maybe tc ; kind' <- reifyKind res_kind ; let (resultSig, injectivity) = ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2047,6 +2047,14 @@ This is unusual: it's a LocalId whose Name has a Module from another module. Tiresomely, we must filter it out again in GHC.Iface.Make, less we get two defns for 'main' in the interface file! +When using `-fwrite-if-simplified-core` the root_main_id can end up in an interface file. +When the interface is read back in we have to add a special case when creating the +Id because otherwise we would go looking for the :Main module which obviously doesn't +exist. For this logic see GHC.IfaceToCore.mk_top_id. + +There is also some similar (probably dead) logic in GHC.Rename.Env which says it +was added for External Core which faced a similar issue. + ********************************************************* * * ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -5177,8 +5177,7 @@ addVDQNote :: TcTyCon -> TcM a -> TcM a -- See Note [Inferring visible dependent quantification] -- Only types without a signature (CUSK or SAK) here addVDQNote tycon thing_inside - | assertPpr (isTcTyCon tycon) (ppr tycon) $ - assertPpr (not (tcTyConIsPoly tycon)) (ppr tycon $$ ppr tc_kind) + | assertPpr (isMonoTcTyCon tycon) (ppr tycon $$ ppr tc_kind) has_vdq = addLandmarkErrCtxt vdq_warning thing_inside | otherwise ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -2484,9 +2484,9 @@ zonkTcTyCon :: TcTyCon -> TcM TcTyCon -- A non-poly TcTyCon may have unification -- variables that need zonking, but poly ones cannot zonkTcTyCon tc - | tcTyConIsPoly tc = return tc - | otherwise = do { tck' <- zonkTcType (tyConKind tc) + | isMonoTcTyCon tc = do { tck' <- zonkTcType (tyConKind tc) ; return (setTcTyConKind tc tck') } + | otherwise = return tc zonkTcTyVar :: TcTyVar -> TcM TcType -- Simply look through all Flexis ===================================== testsuite/tests/ado/T22483.hs ===================================== @@ -0,0 +1,7 @@ +main = do + let x = () + res2 <- pure () + ~(Just res1) <- seq x (pure $ Nothing @()) + print res1 + print res2 + pure () ===================================== testsuite/tests/ado/T22483.stderr ===================================== @@ -0,0 +1,8 @@ + +T22483.hs:1:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: main :: IO () + +T22483.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns (in -Wall)] + Pattern match(es) are non-exhaustive + In a pattern binding: + Patterns of type ‘Maybe ()’ not matched: Nothing ===================================== testsuite/tests/ado/all.T ===================================== @@ -21,3 +21,4 @@ test('T16628', normal, compile_fail, ['']) test('T17835', normal, compile, ['']) test('T20540', normal, compile, ['']) test('T16135', when(compiler_debugged(),expect_broken(16135)), compile, ['']) +test('T22483', normal, compile, ['-Wall']) ===================================== testsuite/tests/driver/fat-iface/T22405/Main.hs ===================================== @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = return () ===================================== testsuite/tests/driver/fat-iface/T22405/Main2.hs ===================================== @@ -0,0 +1,6 @@ +module Main2 where + +main :: IO () +main = return () + + ===================================== testsuite/tests/driver/fat-iface/T22405/Makefile ===================================== @@ -0,0 +1,17 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +TEST_HC_OPTS_NO_RTSOPTS = $(filter-out -rtsopts,$(TEST_HC_OPTS)) + +clean: + rm -f *.hi *.hi-fat *.o + +T22405: clean + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main + +T22405b: clean + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main2 -main-is Main2 + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main2 -main-is Main2 + ===================================== testsuite/tests/driver/fat-iface/T22405/T22405.stdout ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Main ( Main.hs, Main.o, interpreted ) +[2 of 2] Linking Main ===================================== testsuite/tests/driver/fat-iface/T22405/T22405b.stdout ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Main2 ( Main2.hs, Main2.o, interpreted ) +[2 of 2] Linking Main2 ===================================== testsuite/tests/driver/fat-iface/T22405/all.T ===================================== @@ -0,0 +1,2 @@ +test('T22405', [extra_files(['Main.hs'])], makefile_test, ['T22405']) +test('T22405b', [extra_files(['Main2.hs'])], makefile_test, ['T22405b']) ===================================== testsuite/tests/linear/should_compile/T22546.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE LinearTypes, GADTSyntax #-} + +module T22546 where + +import GHC.Types (Multiplicity (..)) +import Data.Kind (Type) + +data T :: Multiplicity -> Type where + MkT :: () %m-> T m + +unMkT :: T m %n-> () +unMkT (MkT x) = x ===================================== testsuite/tests/linear/should_compile/all.T ===================================== @@ -39,3 +39,4 @@ test('LinearDataConSections', normal, compile, ['']) test('T18731', normal, compile, ['']) test('T19400', unless(compiler_debugged(), skip), compile, ['']) test('T20023', normal, compile, ['']) +test('T22546', normal, compile, ['']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 2ffde83344bab8ed0aee3e8ef46f43856c7ca6ef +Subproject commit edc72530978d8a9ec92f51d288484986ec0051e3 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/561e9f181cf6f6011de25eaabe210686099b9aeb...4dd67cb0ec230aa876a529d8cb4fa78eb3c7adfe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/561e9f181cf6f6011de25eaabe210686099b9aeb...4dd67cb0ec230aa876a529d8cb4fa78eb3c7adfe You're receiving 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 Dec 2 22:03:47 2022 From: gitlab at gitlab.haskell.org (Richard Eisenberg (@rae)) Date: Fri, 02 Dec 2022 17:03:47 -0500 Subject: [Git][ghc/ghc][wip/p547] Drop support for kind constraints. Message-ID: <638a76434679_17512ed8b993c847350@gitlab.mail> Richard Eisenberg pushed to branch wip/p547 at Glasgow Haskell Compiler / GHC Commits: 1591f26b by Richard Eisenberg at 2022-12-02T17:03:35-05:00 Drop support for kind constraints. This implements GHC proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. - - - - - 30 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Rewrite.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Var.hs - docs/users_guide/exts/data_kinds.rst - testsuite/tests/dependent/should_compile/all.T - testsuite/tests/dependent/should_fail/T13780a.stderr - testsuite/tests/dependent/should_compile/T14845_compile.hs → testsuite/tests/dependent/should_fail/T14845_compile.hs - + testsuite/tests/dependent/should_fail/T14845_compile.stderr - testsuite/tests/dependent/should_fail/all.T - testsuite/tests/saks/should_compile/all.T - testsuite/tests/saks/should_fail/all.T - testsuite/tests/saks/should_compile/saks007.hs → testsuite/tests/saks/should_fail/saks007.hs - + testsuite/tests/saks/should_fail/saks007.stderr - testsuite/tests/saks/should_fail/saks007_fail.stderr - testsuite/tests/typecheck/should_compile/all.T - + testsuite/tests/typecheck/should_fail/T12102.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1591f26bad5afb4f1f6c1a9acfd56806025eb3a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1591f26bad5afb4f1f6c1a9acfd56806025eb3a9 You're receiving 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 Dec 2 22:12:55 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 02 Dec 2022 17:12:55 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T18964 Message-ID: <638a7867a8a8d_17512e2b9799948504f3@gitlab.mail> Sebastian Graf pushed new branch wip/T18964 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18964 You're receiving 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 Dec 2 23:11:11 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 02 Dec 2022 18:11:11 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T21761 Message-ID: <638a860fef704_17512e64b9d70873421@gitlab.mail> Sebastian Graf pushed new branch wip/T21761 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T21761 You're receiving 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 Dec 3 00:47:02 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 02 Dec 2022 19:47:02 -0500 Subject: [Git][ghc/ghc][master] Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` Message-ID: <638a9c86994a0_17512e2338aa6888251@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 9 changed files: - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Module.hs - + testsuite/tests/driver/fat-iface/T22405/Main.hs - + testsuite/tests/driver/fat-iface/T22405/Main2.hs - + testsuite/tests/driver/fat-iface/T22405/Makefile - + testsuite/tests/driver/fat-iface/T22405/T22405.stdout - + testsuite/tests/driver/fat-iface/T22405/T22405b.stdout - + testsuite/tests/driver/fat-iface/T22405/all.T Changes: ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -123,6 +123,7 @@ import GHC.Driver.Env.KnotVars import GHC.Unit.Module.WholeCoreBindings import Data.IORef import Data.Foldable +import GHC.Builtin.Names (ioTyConName, rOOT_MAIN) {- This module takes @@ -930,7 +931,17 @@ tc_iface_binding i IfUseUnfoldingRhs = return (unfoldingTemplate $ realIdUnfoldi tc_iface_binding _ (IfRhs rhs) = tcIfaceExpr rhs mk_top_id :: IfaceTopBndrInfo -> IfL Id -mk_top_id (IfGblTopBndr gbl_name) = tcIfaceExtId gbl_name +mk_top_id (IfGblTopBndr gbl_name) + -- See Note [Root-main Id] + -- This special binding is actually defined in the current module + -- (hence don't go looking for it externally) but the module name is rOOT_MAIN + -- rather than the current module so we need this special case. + -- See some similar logic in `GHC.Rename.Env`. + | Just rOOT_MAIN == nameModule_maybe gbl_name + = do + ATyCon ioTyCon <- tcIfaceGlobal ioTyConName + return $ mkExportedVanillaId gbl_name (mkTyConApp ioTyCon [unitTy]) + | otherwise = tcIfaceExtId gbl_name mk_top_id (IfLclTopBndr raw_name iface_type info details) = do name <- newIfaceName (mkVarOccFS raw_name) ty <- tcIfaceType iface_type ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -207,6 +207,11 @@ newTopSrcBinder (L loc rdr_name) -- the nice Exact name for the TyCon gets swizzled to an Orig name. -- Hence the badOrigBinding error message. -- + + -- MP 2022: I suspect this code path is never called for `rOOT_MAIN` anymore + -- because External Core has been removed but we instead have some similar logic for + -- serialising whole programs into interface files in GHC.IfaceToCore.mk_top_id. + -- Except for the ":Main.main = ..." definition inserted into -- the Main module; ugh! ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2047,6 +2047,14 @@ This is unusual: it's a LocalId whose Name has a Module from another module. Tiresomely, we must filter it out again in GHC.Iface.Make, less we get two defns for 'main' in the interface file! +When using `-fwrite-if-simplified-core` the root_main_id can end up in an interface file. +When the interface is read back in we have to add a special case when creating the +Id because otherwise we would go looking for the :Main module which obviously doesn't +exist. For this logic see GHC.IfaceToCore.mk_top_id. + +There is also some similar (probably dead) logic in GHC.Rename.Env which says it +was added for External Core which faced a similar issue. + ********************************************************* * * ===================================== testsuite/tests/driver/fat-iface/T22405/Main.hs ===================================== @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = return () ===================================== testsuite/tests/driver/fat-iface/T22405/Main2.hs ===================================== @@ -0,0 +1,6 @@ +module Main2 where + +main :: IO () +main = return () + + ===================================== testsuite/tests/driver/fat-iface/T22405/Makefile ===================================== @@ -0,0 +1,17 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +TEST_HC_OPTS_NO_RTSOPTS = $(filter-out -rtsopts,$(TEST_HC_OPTS)) + +clean: + rm -f *.hi *.hi-fat *.o + +T22405: clean + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main + +T22405b: clean + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main2 -main-is Main2 + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main2 -main-is Main2 + ===================================== testsuite/tests/driver/fat-iface/T22405/T22405.stdout ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Main ( Main.hs, Main.o, interpreted ) +[2 of 2] Linking Main ===================================== testsuite/tests/driver/fat-iface/T22405/T22405b.stdout ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Main2 ( Main2.hs, Main2.o, interpreted ) +[2 of 2] Linking Main2 ===================================== testsuite/tests/driver/fat-iface/T22405/all.T ===================================== @@ -0,0 +1,2 @@ +test('T22405', [extra_files(['Main.hs'])], makefile_test, ['T22405']) +test('T22405b', [extra_files(['Main2.hs'])], makefile_test, ['T22405b']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85ecc1a0fd6536149ae2b54f4b1985d80c0e21cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85ecc1a0fd6536149ae2b54f4b1985d80c0e21cb You're receiving 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 Dec 3 00:47:37 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 02 Dec 2022 19:47:37 -0500 Subject: [Git][ghc/ghc][master] Fix linearity checking in Lint Message-ID: <638a9ca9f0f1b_17512e240afea088775e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - 3 changed files: - compiler/GHC/Core/Lint.hs - + testsuite/tests/linear/should_compile/T22546.hs - testsuite/tests/linear/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -3235,22 +3235,29 @@ ensureSubUsage Zero described_mult err_msg = ensureSubMult ManyTy describe ensureSubUsage (MUsage m) described_mult err_msg = ensureSubMult m described_mult err_msg ensureSubMult :: Mult -> Mult -> SDoc -> LintM () -ensureSubMult actual_usage described_usage err_msg = do +ensureSubMult actual_mult described_mult err_msg = do flags <- getLintFlags - when (lf_check_linearity flags) $ case actual_usage' `submult` described_usage' of - Submult -> return () - Unknown -> case isMultMul actual_usage' of - Just (m1, m2) -> ensureSubMult m1 described_usage' err_msg >> - ensureSubMult m2 described_usage' err_msg - Nothing -> when (not (actual_usage' `eqType` described_usage')) (addErrL err_msg) - - where actual_usage' = normalize actual_usage - described_usage' = normalize described_usage - - normalize :: Mult -> Mult - normalize m = case isMultMul m of - Just (m1, m2) -> mkMultMul (normalize m1) (normalize m2) - Nothing -> m + when (lf_check_linearity flags) $ + unless (deepSubMult actual_mult described_mult) $ + addErrL err_msg + where + -- Check for submultiplicity using the following rules: + -- 1. x*y <= z when x <= z and y <= z. + -- This rule follows from the fact that x*y = sup{x,y} for any + -- multiplicities x,y. + -- 2. x <= y*z when x <= y or x <= z. + -- This rule is not complete: when x = y*z, we cannot + -- change y*z <= y*z to y*z <= y or y*z <= z. + -- However, we eliminate products on the LHS in step 1. + -- 3. One <= x and x <= Many for any x, as checked by 'submult'. + -- 4. x <= x. + -- Otherwise, we fail. + deepSubMult :: Mult -> Mult -> Bool + deepSubMult m n + | Just (m1, m2) <- isMultMul m = deepSubMult m1 n && deepSubMult m2 n + | Just (n1, n2) <- isMultMul n = deepSubMult m n1 || deepSubMult m n2 + | Submult <- m `submult` n = True + | otherwise = m `eqType` n lintRole :: Outputable thing => thing -- where the role appeared ===================================== testsuite/tests/linear/should_compile/T22546.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE LinearTypes, GADTSyntax #-} + +module T22546 where + +import GHC.Types (Multiplicity (..)) +import Data.Kind (Type) + +data T :: Multiplicity -> Type where + MkT :: () %m-> T m + +unMkT :: T m %n-> () +unMkT (MkT x) = x ===================================== testsuite/tests/linear/should_compile/all.T ===================================== @@ -39,3 +39,4 @@ test('LinearDataConSections', normal, compile, ['']) test('T18731', normal, compile, ['']) test('T19400', unless(compiler_debugged(), skip), compile, ['']) test('T20023', normal, compile, ['']) +test('T22546', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/108c319f47e31fb307d7aff718b40578c8026ddd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/108c319f47e31fb307d7aff718b40578c8026ddd You're receiving 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 Dec 3 03:18:40 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 02 Dec 2022 22:18:40 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` Message-ID: <638ac0101d1ad_17512e1e46a9d8895652@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - ac237eb4 by Bryan Richter at 2022-12-02T22:18:27-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - cdd40740 by Vladislav Zavialov at 2022-12-02T22:18:27-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - 0bf27239 by Vladislav Zavialov at 2022-12-02T22:18:27-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 14 changed files: - compiler/GHC/Core/Lint.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Module.hs - + testsuite/tests/driver/fat-iface/T22405/Main.hs - + testsuite/tests/driver/fat-iface/T22405/Main2.hs - + testsuite/tests/driver/fat-iface/T22405/Makefile - + testsuite/tests/driver/fat-iface/T22405/T22405.stdout - + testsuite/tests/driver/fat-iface/T22405/T22405b.stdout - + testsuite/tests/driver/fat-iface/T22405/all.T - testsuite/tests/lib/base/all.T - + testsuite/tests/linear/should_compile/T22546.hs - testsuite/tests/linear/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -3235,22 +3235,29 @@ ensureSubUsage Zero described_mult err_msg = ensureSubMult ManyTy describe ensureSubUsage (MUsage m) described_mult err_msg = ensureSubMult m described_mult err_msg ensureSubMult :: Mult -> Mult -> SDoc -> LintM () -ensureSubMult actual_usage described_usage err_msg = do +ensureSubMult actual_mult described_mult err_msg = do flags <- getLintFlags - when (lf_check_linearity flags) $ case actual_usage' `submult` described_usage' of - Submult -> return () - Unknown -> case isMultMul actual_usage' of - Just (m1, m2) -> ensureSubMult m1 described_usage' err_msg >> - ensureSubMult m2 described_usage' err_msg - Nothing -> when (not (actual_usage' `eqType` described_usage')) (addErrL err_msg) - - where actual_usage' = normalize actual_usage - described_usage' = normalize described_usage - - normalize :: Mult -> Mult - normalize m = case isMultMul m of - Just (m1, m2) -> mkMultMul (normalize m1) (normalize m2) - Nothing -> m + when (lf_check_linearity flags) $ + unless (deepSubMult actual_mult described_mult) $ + addErrL err_msg + where + -- Check for submultiplicity using the following rules: + -- 1. x*y <= z when x <= z and y <= z. + -- This rule follows from the fact that x*y = sup{x,y} for any + -- multiplicities x,y. + -- 2. x <= y*z when x <= y or x <= z. + -- This rule is not complete: when x = y*z, we cannot + -- change y*z <= y*z to y*z <= y or y*z <= z. + -- However, we eliminate products on the LHS in step 1. + -- 3. One <= x and x <= Many for any x, as checked by 'submult'. + -- 4. x <= x. + -- Otherwise, we fail. + deepSubMult :: Mult -> Mult -> Bool + deepSubMult m n + | Just (m1, m2) <- isMultMul m = deepSubMult m1 n && deepSubMult m2 n + | Just (n1, n2) <- isMultMul n = deepSubMult m n1 || deepSubMult m n2 + | Submult <- m `submult` n = True + | otherwise = m `eqType` n lintRole :: Outputable thing => thing -- where the role appeared ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -461,7 +461,7 @@ repTyClD (L loc (FamDecl { tcdFam = fam })) = liftM Just $ repTyClD (L loc (SynDecl { tcdLName = tc, tcdTyVars = tvs, tcdRhs = rhs })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repSynDecl tc1 bndrs rhs ; return (Just (locA loc, dec)) } @@ -469,7 +469,7 @@ repTyClD (L loc (DataDecl { tcdLName = tc , tcdTyVars = tvs , tcdDataDefn = defn })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repDataDefn tc1 (Left bndrs) defn ; return (Just (locA loc, dec)) } @@ -478,7 +478,7 @@ repTyClD (L loc (ClassDecl { tcdCtxt = cxt, tcdLName = cls, tcdSigs = sigs, tcdMeths = meth_binds, tcdATs = ats, tcdATDefs = atds })) = do { cls1 <- lookupLOcc cls -- See Note [Binders and occurrences] - ; dec <- addQTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { cxt1 <- repLContext cxt -- See Note [Scoped type variables in quotes] ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs meth_binds @@ -549,14 +549,11 @@ repFamilyDecl decl@(L loc (FamilyDecl { fdInfo = info , fdResultSig = L _ resultSig , fdInjectivityAnn = injectivity })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; let mkHsQTvs :: [LHsTyVarBndr () GhcRn] -> LHsQTyVars GhcRn - mkHsQTvs tvs = HsQTvs { hsq_ext = [] - , hsq_explicit = tvs } - resTyVar = case resultSig of - TyVarSig _ bndr -> mkHsQTvs [bndr] - _ -> mkHsQTvs [] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> - addTyClTyVarBinds resTyVar $ \_ -> + ; let resTyVar = case resultSig of + TyVarSig _ bndr -> [hsLTyVarName bndr] + _ -> [] + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> + addSimpleTyVarBinds ReuseBoundNames resTyVar $ case info of ClosedTypeFamily Nothing -> notHandled (ThAbstractClosedTypeFamily decl) @@ -645,7 +642,7 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds , cid_datafam_insts = adts , cid_overlap_mode = overlap }) - = addSimpleTyVarBinds tvs $ + = addSimpleTyVarBinds FreshNamesOnly tvs $ -- We must bring the type variables into scope, so their -- occurrences don't fail, even though the binders don't -- appear in the resulting data structure @@ -672,7 +669,7 @@ repStandaloneDerivD :: LDerivDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat , deriv_type = ty })) = do { dec <- repDerivStrategy strat $ \strat' -> - addSimpleTyVarBinds tvs $ + addSimpleTyVarBinds FreshNamesOnly tvs $ do { cxt' <- repLContext cxt ; inst_ty' <- repLTy inst_ty ; repDeriv strat' cxt' inst_ty' } @@ -804,16 +801,17 @@ repDefD (L loc (DefaultDecl _ tys)) = do { tys1 <- repLTys tys repRuleD :: LRuleDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repRuleD (L loc (HsRule { rd_name = n , rd_act = act - , rd_tyvs = ty_bndrs + , rd_tyvs = m_ty_bndrs , rd_tmvs = tm_bndrs , rd_lhs = lhs , rd_rhs = rhs })) - = do { rule <- addHsTyVarBinds (fromMaybe [] ty_bndrs) $ \ ex_bndrs -> + = do { let ty_bndrs = fromMaybe [] m_ty_bndrs + ; rule <- addHsTyVarBinds FreshNamesOnly ty_bndrs $ \ ex_bndrs -> do { let tm_bndr_names = concatMap ruleBndrNames tm_bndrs ; ss <- mkGenSyms tm_bndr_names ; rule <- addBinds ss $ do { elt_ty <- wrapName tyVarBndrUnitTyConName - ; ty_bndrs' <- return $ case ty_bndrs of + ; ty_bndrs' <- return $ case m_ty_bndrs of Nothing -> coreNothing' (mkListTy elt_ty) Just _ -> coreJust' (mkListTy elt_ty) ex_bndrs ; tm_bndrs' <- repListM ruleBndrTyConName @@ -878,7 +876,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_ex_tvs = con_tvs , con_mb_cxt = mcxt , con_args = args })) - = addHsTyVarBinds con_tvs $ \ ex_bndrs -> + = addHsTyVarBinds FreshNamesOnly con_tvs $ \ ex_bndrs -> do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt @@ -1188,14 +1186,11 @@ addHsOuterFamEqnTyVarBinds outer_bndrs thing_inside = do elt_ty <- wrapName tyVarBndrUnitTyConName case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> - addTyClTyVarBinds (mk_qtvs imp_tvs []) $ \_th_exp_bndrs -> + addSimpleTyVarBinds ReuseBoundNames imp_tvs $ thing_inside $ coreNothingList elt_ty HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addTyClTyVarBinds (mk_qtvs [] exp_bndrs) $ \th_exp_bndrs -> + addHsTyVarBinds FreshNamesOnly exp_bndrs $ \th_exp_bndrs -> thing_inside $ coreJustList elt_ty th_exp_bndrs - where - mk_qtvs imp_tvs exp_tvs = HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs } addHsOuterSigTyVarBinds :: HsOuterSigTyVarBndrs GhcRn @@ -1204,9 +1199,9 @@ addHsOuterSigTyVarBinds :: addHsOuterSigTyVarBinds outer_bndrs thing_inside = case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> do th_nil <- coreListM tyVarBndrSpecTyConName [] - addSimpleTyVarBinds imp_tvs $ thing_inside th_nil + addSimpleTyVarBinds FreshNamesOnly imp_tvs $ thing_inside th_nil HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addHsTyVarBinds exp_bndrs thing_inside + addHsTyVarBinds FreshNamesOnly exp_bndrs thing_inside -- | If a type implicitly quantifies its outermost type variables, return -- 'True' if the list of implicitly bound type variables is empty. If a type @@ -1230,69 +1225,86 @@ nullOuterExplicit (HsOuterExplicit{hso_bndrs = exp_bndrs}) = null exp_bndrs nullOuterExplicit (HsOuterImplicit{}) = True -- Vacuously true, as there is no outermost explicit quantification -addSimpleTyVarBinds :: [Name] -- the binders to be added +-- Do we want to generate fresh names for type variables +-- or reuse the ones that are already in scope? +data FreshOrReuse + = FreshNamesOnly + -- Generate fresh names for all type variables, regardless of existing + -- variables in the MetaEnv. + -- + -- This is the default strategy. + + | ReuseBoundNames + -- Generate fresh names for type variables not in the MetaEnv. + -- Where a name is already bound in the MetaEnv, use that existing binding; + -- do not create a new one with a fresh name. + -- + -- This is the strategy used for data/newtype declarations and type family + -- instances, so that the nested type variables work right: + -- + -- class C a where + -- type W a b + -- instance C (T a) where + -- type W (T a) b = blah + -- + -- The 'a' in the type instance is the one bound by the instance decl + -- + -- Test cases: TH_reifyExplicitForAllFams T9081 T9199 T10811 + +mkGenSyms' :: FreshOrReuse -> [Name] -> MetaM [GenSymBind] +mkGenSyms' FreshNamesOnly names = mkGenSyms names +mkGenSyms' ReuseBoundNames names = + -- Make fresh names for the ones that are not already in scope + -- This makes things work for associated types + do { env <- lift dsGetMetaEnv + ; mkGenSyms (filterOut (`elemNameEnv` env) names) } + +addSimpleTyVarBinds :: FreshOrReuse + -> [Name] -- the binders to be added -> MetaM (Core (M a)) -- action in the ext env -> MetaM (Core (M a)) -addSimpleTyVarBinds names thing_inside - = do { fresh_names <- mkGenSyms names +addSimpleTyVarBinds fresh_or_reuse names thing_inside + = do { fresh_names <- mkGenSyms' fresh_or_reuse names ; term <- addBinds fresh_names thing_inside ; wrapGenSyms fresh_names term } addHsTyVarBinds :: forall flag flag' a. RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addHsTyVarBinds exp_tvs thing_inside - = do { fresh_exp_names <- mkGenSyms (hsLTyVarNames exp_tvs) +addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside + = do { fresh_exp_names <- mkGenSyms' fresh_or_reuse (hsLTyVarNames exp_tvs) ; term <- addBinds fresh_exp_names $ do { kbs <- repListM (tyVarBndrName @flag @flag') repTyVarBndr exp_tvs ; thing_inside kbs } ; wrapGenSyms fresh_exp_names term } -addQTyVarBinds :: LHsQTyVars GhcRn -- the binders to be added +addQTyVarBinds :: FreshOrReuse + -> LHsQTyVars GhcRn -- the binders to be added -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addQTyVarBinds (HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs }) - thing_inside - = addTyVarBinds exp_tvs imp_tvs thing_inside +addQTyVarBinds fresh_or_reuse qtvs thing_inside = + let HsQTvs { hsq_ext = imp_tvs + , hsq_explicit = exp_tvs } + = qtvs + in addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside addTyVarBinds :: RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> [Name] -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -- gensym a list of type variables and enter them into the meta environment; -- the computations passed as the second argument is executed in that extended -- meta environment and gets the *new* names on Core-level as an argument -addTyVarBinds exp_tvs imp_tvs thing_inside - = addSimpleTyVarBinds imp_tvs $ - addHsTyVarBinds exp_tvs $ +addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside + = addSimpleTyVarBinds fresh_or_reuse imp_tvs $ + addHsTyVarBinds fresh_or_reuse exp_tvs $ thing_inside -addTyClTyVarBinds :: LHsQTyVars GhcRn - -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) - -> MetaM (Core (M a)) --- Used for data/newtype declarations, and family instances, --- so that the nested type variables work right --- instance C (T a) where --- type W (T a) = blah --- The 'a' in the type instance is the one bound by the instance decl -addTyClTyVarBinds tvs m - = do { let tv_names = hsAllLTyVarNames tvs - ; env <- lift $ dsGetMetaEnv - ; freshNames <- mkGenSyms (filterOut (`elemNameEnv` env) tv_names) - -- Make fresh names for the ones that are not already in scope - -- This makes things work for family declarations - - ; term <- addBinds freshNames $ - do { kbs <- repListM tyVarBndrUnitTyConName repTyVarBndr - (hsQTvExplicit tvs) - ; m kbs } - - ; wrapGenSyms freshNames term } - -- | Represent a type variable binder repTyVarBndr :: RepTV flag flag' => LHsTyVarBndr flag GhcRn -> MetaM (Core (M (TH.TyVarBndr flag'))) @@ -1341,7 +1353,7 @@ repLTy ty = repTy (unLoc ty) repForallT :: HsType GhcRn -> MetaM (Core (M TH.Type)) repForallT ty | (tvs, ctxt, tau) <- splitLHsSigmaTyInvis (noLocA ty) - = addHsTyVarBinds tvs $ \bndrs -> + = addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { ctxt1 <- repLContext ctxt ; tau1 <- repLTy tau ; repTForall bndrs ctxt1 tau1 -- forall a. C a => {...} @@ -1352,7 +1364,7 @@ repTy ty@(HsForAllTy { hst_tele = tele, hst_body = body }) = case tele of HsForAllInvis{} -> repForallT ty HsForAllVis { hsf_vis_bndrs = tvs } -> - addHsTyVarBinds tvs $ \bndrs -> + addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do body1 <- repLTy body repTForallVis bndrs body1 repTy ty@(HsQualTy {}) = repForallT ty @@ -1606,7 +1618,7 @@ repE (RecordUpd { rupd_flds = Right _ }) panic "The impossible has happened!" repE (ExprWithTySig _ e wc_ty) - = addSimpleTyVarBinds (get_scoped_tvs_from_sig sig_ty) $ + = addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig sig_ty) $ do { e1 <- repLE e ; t1 <- rep_ty_sig' sig_ty ; repSigExp e1 t1 } @@ -2560,7 +2572,7 @@ repDerivStrategy mds thing_inside = StockStrategy _ -> thing_inside =<< just =<< repStockStrategy AnyclassStrategy _ -> thing_inside =<< just =<< repAnyclassStrategy NewtypeStrategy _ -> thing_inside =<< just =<< repNewtypeStrategy - ViaStrategy ty -> addSimpleTyVarBinds (get_scoped_tvs_from_sig ty) $ + ViaStrategy ty -> addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig ty) $ do ty' <- rep_ty_sig' ty via_strat <- repViaStrategy ty' m_via_strat <- just via_strat ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -123,6 +123,7 @@ import GHC.Driver.Env.KnotVars import GHC.Unit.Module.WholeCoreBindings import Data.IORef import Data.Foldable +import GHC.Builtin.Names (ioTyConName, rOOT_MAIN) {- This module takes @@ -930,7 +931,17 @@ tc_iface_binding i IfUseUnfoldingRhs = return (unfoldingTemplate $ realIdUnfoldi tc_iface_binding _ (IfRhs rhs) = tcIfaceExpr rhs mk_top_id :: IfaceTopBndrInfo -> IfL Id -mk_top_id (IfGblTopBndr gbl_name) = tcIfaceExtId gbl_name +mk_top_id (IfGblTopBndr gbl_name) + -- See Note [Root-main Id] + -- This special binding is actually defined in the current module + -- (hence don't go looking for it externally) but the module name is rOOT_MAIN + -- rather than the current module so we need this special case. + -- See some similar logic in `GHC.Rename.Env`. + | Just rOOT_MAIN == nameModule_maybe gbl_name + = do + ATyCon ioTyCon <- tcIfaceGlobal ioTyConName + return $ mkExportedVanillaId gbl_name (mkTyConApp ioTyCon [unitTy]) + | otherwise = tcIfaceExtId gbl_name mk_top_id (IfLclTopBndr raw_name iface_type info details) = do name <- newIfaceName (mkVarOccFS raw_name) ty <- tcIfaceType iface_type ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -207,6 +207,11 @@ newTopSrcBinder (L loc rdr_name) -- the nice Exact name for the TyCon gets swizzled to an Orig name. -- Hence the badOrigBinding error message. -- + + -- MP 2022: I suspect this code path is never called for `rOOT_MAIN` anymore + -- because External Core has been removed but we instead have some similar logic for + -- serialising whole programs into interface files in GHC.IfaceToCore.mk_top_id. + -- Except for the ":Main.main = ..." definition inserted into -- the Main module; ugh! ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2047,6 +2047,14 @@ This is unusual: it's a LocalId whose Name has a Module from another module. Tiresomely, we must filter it out again in GHC.Iface.Make, less we get two defns for 'main' in the interface file! +When using `-fwrite-if-simplified-core` the root_main_id can end up in an interface file. +When the interface is read back in we have to add a special case when creating the +Id because otherwise we would go looking for the :Main module which obviously doesn't +exist. For this logic see GHC.IfaceToCore.mk_top_id. + +There is also some similar (probably dead) logic in GHC.Rename.Env which says it +was added for External Core which faced a similar issue. + ********************************************************* * * ===================================== testsuite/tests/driver/fat-iface/T22405/Main.hs ===================================== @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = return () ===================================== testsuite/tests/driver/fat-iface/T22405/Main2.hs ===================================== @@ -0,0 +1,6 @@ +module Main2 where + +main :: IO () +main = return () + + ===================================== testsuite/tests/driver/fat-iface/T22405/Makefile ===================================== @@ -0,0 +1,17 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +TEST_HC_OPTS_NO_RTSOPTS = $(filter-out -rtsopts,$(TEST_HC_OPTS)) + +clean: + rm -f *.hi *.hi-fat *.o + +T22405: clean + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main + +T22405b: clean + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main2 -main-is Main2 + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main2 -main-is Main2 + ===================================== testsuite/tests/driver/fat-iface/T22405/T22405.stdout ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Main ( Main.hs, Main.o, interpreted ) +[2 of 2] Linking Main ===================================== testsuite/tests/driver/fat-iface/T22405/T22405b.stdout ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Main2 ( Main2.hs, Main2.o, interpreted ) +[2 of 2] Linking Main2 ===================================== testsuite/tests/driver/fat-iface/T22405/all.T ===================================== @@ -0,0 +1,2 @@ +test('T22405', [extra_files(['Main.hs'])], makefile_test, ['T22405']) +test('T22405b', [extra_files(['Main2.hs'])], makefile_test, ['T22405b']) ===================================== testsuite/tests/lib/base/all.T ===================================== @@ -1,7 +1,7 @@ test('DataTypeOrd', normal, compile_and_run, ['']) test('T16586', normal, compile_and_run, ['-O2']) # Event-manager not supported on Windows -test('T16916', [when(opsys('mingw32'), skip), js_broken(22261)], compile_and_run, ['-O2 -threaded -with-rtsopts="-I0" -rtsopts']) +test('T16916', [when(opsys('mingw32'), skip), js_broken(22261), fragile(16966)], compile_and_run, ['-O2 -threaded -with-rtsopts="-I0" -rtsopts']) test('T17310', normal, compile, ['']) test('T19691', normal, compile, ['']) test('executablePath', [extra_run_opts(config.os), js_broken(22261)], compile_and_run, ['']) ===================================== testsuite/tests/linear/should_compile/T22546.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE LinearTypes, GADTSyntax #-} + +module T22546 where + +import GHC.Types (Multiplicity (..)) +import Data.Kind (Type) + +data T :: Multiplicity -> Type where + MkT :: () %m-> T m + +unMkT :: T m %n-> () +unMkT (MkT x) = x ===================================== testsuite/tests/linear/should_compile/all.T ===================================== @@ -39,3 +39,4 @@ test('LinearDataConSections', normal, compile, ['']) test('T18731', normal, compile, ['']) test('T19400', unless(compiler_debugged(), skip), compile, ['']) test('T20023', normal, compile, ['']) +test('T22546', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4dd67cb0ec230aa876a529d8cb4fa78eb3c7adfe...0bf27239066dd59f2524bf3df4f2f6015b5ff6d7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4dd67cb0ec230aa876a529d8cb4fa78eb3c7adfe...0bf27239066dd59f2524bf3df4f2f6015b5ff6d7 You're receiving 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 Dec 3 06:38:51 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 03 Dec 2022 01:38:51 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Mark T16916 fragile Message-ID: <638aeefb17f93_17512e2338aa6890622e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 92e01809 by Bryan Richter at 2022-12-03T01:38:41-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5673702d by Vladislav Zavialov at 2022-12-03T01:38:42-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - b4733102 by Vladislav Zavialov at 2022-12-03T01:38:42-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 2 changed files: - compiler/GHC/HsToCore/Quote.hs - testsuite/tests/lib/base/all.T Changes: ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -461,7 +461,7 @@ repTyClD (L loc (FamDecl { tcdFam = fam })) = liftM Just $ repTyClD (L loc (SynDecl { tcdLName = tc, tcdTyVars = tvs, tcdRhs = rhs })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repSynDecl tc1 bndrs rhs ; return (Just (locA loc, dec)) } @@ -469,7 +469,7 @@ repTyClD (L loc (DataDecl { tcdLName = tc , tcdTyVars = tvs , tcdDataDefn = defn })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repDataDefn tc1 (Left bndrs) defn ; return (Just (locA loc, dec)) } @@ -478,7 +478,7 @@ repTyClD (L loc (ClassDecl { tcdCtxt = cxt, tcdLName = cls, tcdSigs = sigs, tcdMeths = meth_binds, tcdATs = ats, tcdATDefs = atds })) = do { cls1 <- lookupLOcc cls -- See Note [Binders and occurrences] - ; dec <- addQTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { cxt1 <- repLContext cxt -- See Note [Scoped type variables in quotes] ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs meth_binds @@ -549,14 +549,11 @@ repFamilyDecl decl@(L loc (FamilyDecl { fdInfo = info , fdResultSig = L _ resultSig , fdInjectivityAnn = injectivity })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; let mkHsQTvs :: [LHsTyVarBndr () GhcRn] -> LHsQTyVars GhcRn - mkHsQTvs tvs = HsQTvs { hsq_ext = [] - , hsq_explicit = tvs } - resTyVar = case resultSig of - TyVarSig _ bndr -> mkHsQTvs [bndr] - _ -> mkHsQTvs [] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> - addTyClTyVarBinds resTyVar $ \_ -> + ; let resTyVar = case resultSig of + TyVarSig _ bndr -> [hsLTyVarName bndr] + _ -> [] + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> + addSimpleTyVarBinds ReuseBoundNames resTyVar $ case info of ClosedTypeFamily Nothing -> notHandled (ThAbstractClosedTypeFamily decl) @@ -645,7 +642,7 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds , cid_datafam_insts = adts , cid_overlap_mode = overlap }) - = addSimpleTyVarBinds tvs $ + = addSimpleTyVarBinds FreshNamesOnly tvs $ -- We must bring the type variables into scope, so their -- occurrences don't fail, even though the binders don't -- appear in the resulting data structure @@ -672,7 +669,7 @@ repStandaloneDerivD :: LDerivDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat , deriv_type = ty })) = do { dec <- repDerivStrategy strat $ \strat' -> - addSimpleTyVarBinds tvs $ + addSimpleTyVarBinds FreshNamesOnly tvs $ do { cxt' <- repLContext cxt ; inst_ty' <- repLTy inst_ty ; repDeriv strat' cxt' inst_ty' } @@ -804,16 +801,17 @@ repDefD (L loc (DefaultDecl _ tys)) = do { tys1 <- repLTys tys repRuleD :: LRuleDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repRuleD (L loc (HsRule { rd_name = n , rd_act = act - , rd_tyvs = ty_bndrs + , rd_tyvs = m_ty_bndrs , rd_tmvs = tm_bndrs , rd_lhs = lhs , rd_rhs = rhs })) - = do { rule <- addHsTyVarBinds (fromMaybe [] ty_bndrs) $ \ ex_bndrs -> + = do { let ty_bndrs = fromMaybe [] m_ty_bndrs + ; rule <- addHsTyVarBinds FreshNamesOnly ty_bndrs $ \ ex_bndrs -> do { let tm_bndr_names = concatMap ruleBndrNames tm_bndrs ; ss <- mkGenSyms tm_bndr_names ; rule <- addBinds ss $ do { elt_ty <- wrapName tyVarBndrUnitTyConName - ; ty_bndrs' <- return $ case ty_bndrs of + ; ty_bndrs' <- return $ case m_ty_bndrs of Nothing -> coreNothing' (mkListTy elt_ty) Just _ -> coreJust' (mkListTy elt_ty) ex_bndrs ; tm_bndrs' <- repListM ruleBndrTyConName @@ -878,7 +876,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_ex_tvs = con_tvs , con_mb_cxt = mcxt , con_args = args })) - = addHsTyVarBinds con_tvs $ \ ex_bndrs -> + = addHsTyVarBinds FreshNamesOnly con_tvs $ \ ex_bndrs -> do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt @@ -1188,14 +1186,11 @@ addHsOuterFamEqnTyVarBinds outer_bndrs thing_inside = do elt_ty <- wrapName tyVarBndrUnitTyConName case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> - addTyClTyVarBinds (mk_qtvs imp_tvs []) $ \_th_exp_bndrs -> + addSimpleTyVarBinds ReuseBoundNames imp_tvs $ thing_inside $ coreNothingList elt_ty HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addTyClTyVarBinds (mk_qtvs [] exp_bndrs) $ \th_exp_bndrs -> + addHsTyVarBinds FreshNamesOnly exp_bndrs $ \th_exp_bndrs -> thing_inside $ coreJustList elt_ty th_exp_bndrs - where - mk_qtvs imp_tvs exp_tvs = HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs } addHsOuterSigTyVarBinds :: HsOuterSigTyVarBndrs GhcRn @@ -1204,9 +1199,9 @@ addHsOuterSigTyVarBinds :: addHsOuterSigTyVarBinds outer_bndrs thing_inside = case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> do th_nil <- coreListM tyVarBndrSpecTyConName [] - addSimpleTyVarBinds imp_tvs $ thing_inside th_nil + addSimpleTyVarBinds FreshNamesOnly imp_tvs $ thing_inside th_nil HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addHsTyVarBinds exp_bndrs thing_inside + addHsTyVarBinds FreshNamesOnly exp_bndrs thing_inside -- | If a type implicitly quantifies its outermost type variables, return -- 'True' if the list of implicitly bound type variables is empty. If a type @@ -1230,69 +1225,86 @@ nullOuterExplicit (HsOuterExplicit{hso_bndrs = exp_bndrs}) = null exp_bndrs nullOuterExplicit (HsOuterImplicit{}) = True -- Vacuously true, as there is no outermost explicit quantification -addSimpleTyVarBinds :: [Name] -- the binders to be added +-- Do we want to generate fresh names for type variables +-- or reuse the ones that are already in scope? +data FreshOrReuse + = FreshNamesOnly + -- Generate fresh names for all type variables, regardless of existing + -- variables in the MetaEnv. + -- + -- This is the default strategy. + + | ReuseBoundNames + -- Generate fresh names for type variables not in the MetaEnv. + -- Where a name is already bound in the MetaEnv, use that existing binding; + -- do not create a new one with a fresh name. + -- + -- This is the strategy used for data/newtype declarations and type family + -- instances, so that the nested type variables work right: + -- + -- class C a where + -- type W a b + -- instance C (T a) where + -- type W (T a) b = blah + -- + -- The 'a' in the type instance is the one bound by the instance decl + -- + -- Test cases: TH_reifyExplicitForAllFams T9081 T9199 T10811 + +mkGenSyms' :: FreshOrReuse -> [Name] -> MetaM [GenSymBind] +mkGenSyms' FreshNamesOnly names = mkGenSyms names +mkGenSyms' ReuseBoundNames names = + -- Make fresh names for the ones that are not already in scope + -- This makes things work for associated types + do { env <- lift dsGetMetaEnv + ; mkGenSyms (filterOut (`elemNameEnv` env) names) } + +addSimpleTyVarBinds :: FreshOrReuse + -> [Name] -- the binders to be added -> MetaM (Core (M a)) -- action in the ext env -> MetaM (Core (M a)) -addSimpleTyVarBinds names thing_inside - = do { fresh_names <- mkGenSyms names +addSimpleTyVarBinds fresh_or_reuse names thing_inside + = do { fresh_names <- mkGenSyms' fresh_or_reuse names ; term <- addBinds fresh_names thing_inside ; wrapGenSyms fresh_names term } addHsTyVarBinds :: forall flag flag' a. RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addHsTyVarBinds exp_tvs thing_inside - = do { fresh_exp_names <- mkGenSyms (hsLTyVarNames exp_tvs) +addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside + = do { fresh_exp_names <- mkGenSyms' fresh_or_reuse (hsLTyVarNames exp_tvs) ; term <- addBinds fresh_exp_names $ do { kbs <- repListM (tyVarBndrName @flag @flag') repTyVarBndr exp_tvs ; thing_inside kbs } ; wrapGenSyms fresh_exp_names term } -addQTyVarBinds :: LHsQTyVars GhcRn -- the binders to be added +addQTyVarBinds :: FreshOrReuse + -> LHsQTyVars GhcRn -- the binders to be added -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addQTyVarBinds (HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs }) - thing_inside - = addTyVarBinds exp_tvs imp_tvs thing_inside +addQTyVarBinds fresh_or_reuse qtvs thing_inside = + let HsQTvs { hsq_ext = imp_tvs + , hsq_explicit = exp_tvs } + = qtvs + in addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside addTyVarBinds :: RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> [Name] -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -- gensym a list of type variables and enter them into the meta environment; -- the computations passed as the second argument is executed in that extended -- meta environment and gets the *new* names on Core-level as an argument -addTyVarBinds exp_tvs imp_tvs thing_inside - = addSimpleTyVarBinds imp_tvs $ - addHsTyVarBinds exp_tvs $ +addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside + = addSimpleTyVarBinds fresh_or_reuse imp_tvs $ + addHsTyVarBinds fresh_or_reuse exp_tvs $ thing_inside -addTyClTyVarBinds :: LHsQTyVars GhcRn - -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) - -> MetaM (Core (M a)) --- Used for data/newtype declarations, and family instances, --- so that the nested type variables work right --- instance C (T a) where --- type W (T a) = blah --- The 'a' in the type instance is the one bound by the instance decl -addTyClTyVarBinds tvs m - = do { let tv_names = hsAllLTyVarNames tvs - ; env <- lift $ dsGetMetaEnv - ; freshNames <- mkGenSyms (filterOut (`elemNameEnv` env) tv_names) - -- Make fresh names for the ones that are not already in scope - -- This makes things work for family declarations - - ; term <- addBinds freshNames $ - do { kbs <- repListM tyVarBndrUnitTyConName repTyVarBndr - (hsQTvExplicit tvs) - ; m kbs } - - ; wrapGenSyms freshNames term } - -- | Represent a type variable binder repTyVarBndr :: RepTV flag flag' => LHsTyVarBndr flag GhcRn -> MetaM (Core (M (TH.TyVarBndr flag'))) @@ -1341,7 +1353,7 @@ repLTy ty = repTy (unLoc ty) repForallT :: HsType GhcRn -> MetaM (Core (M TH.Type)) repForallT ty | (tvs, ctxt, tau) <- splitLHsSigmaTyInvis (noLocA ty) - = addHsTyVarBinds tvs $ \bndrs -> + = addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { ctxt1 <- repLContext ctxt ; tau1 <- repLTy tau ; repTForall bndrs ctxt1 tau1 -- forall a. C a => {...} @@ -1352,7 +1364,7 @@ repTy ty@(HsForAllTy { hst_tele = tele, hst_body = body }) = case tele of HsForAllInvis{} -> repForallT ty HsForAllVis { hsf_vis_bndrs = tvs } -> - addHsTyVarBinds tvs $ \bndrs -> + addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do body1 <- repLTy body repTForallVis bndrs body1 repTy ty@(HsQualTy {}) = repForallT ty @@ -1606,7 +1618,7 @@ repE (RecordUpd { rupd_flds = Right _ }) panic "The impossible has happened!" repE (ExprWithTySig _ e wc_ty) - = addSimpleTyVarBinds (get_scoped_tvs_from_sig sig_ty) $ + = addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig sig_ty) $ do { e1 <- repLE e ; t1 <- rep_ty_sig' sig_ty ; repSigExp e1 t1 } @@ -2560,7 +2572,7 @@ repDerivStrategy mds thing_inside = StockStrategy _ -> thing_inside =<< just =<< repStockStrategy AnyclassStrategy _ -> thing_inside =<< just =<< repAnyclassStrategy NewtypeStrategy _ -> thing_inside =<< just =<< repNewtypeStrategy - ViaStrategy ty -> addSimpleTyVarBinds (get_scoped_tvs_from_sig ty) $ + ViaStrategy ty -> addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig ty) $ do ty' <- rep_ty_sig' ty via_strat <- repViaStrategy ty' m_via_strat <- just via_strat ===================================== testsuite/tests/lib/base/all.T ===================================== @@ -1,7 +1,7 @@ test('DataTypeOrd', normal, compile_and_run, ['']) test('T16586', normal, compile_and_run, ['-O2']) # Event-manager not supported on Windows -test('T16916', [when(opsys('mingw32'), skip), js_broken(22261)], compile_and_run, ['-O2 -threaded -with-rtsopts="-I0" -rtsopts']) +test('T16916', [when(opsys('mingw32'), skip), js_broken(22261), fragile(16966)], compile_and_run, ['-O2 -threaded -with-rtsopts="-I0" -rtsopts']) test('T17310', normal, compile, ['']) test('T19691', normal, compile, ['']) test('executablePath', [extra_run_opts(config.os), js_broken(22261)], compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0bf27239066dd59f2524bf3df4f2f6015b5ff6d7...b47331023cc5ae0e112f7eaec90d6461dcd186fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0bf27239066dd59f2524bf3df4f2f6015b5ff6d7...b47331023cc5ae0e112f7eaec90d6461dcd186fa You're receiving 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 Dec 3 09:39:02 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 03 Dec 2022 04:39:02 -0500 Subject: [Git][ghc/ghc][master] Mark T16916 fragile Message-ID: <638b19367f584_17512e64b9d70918788@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 1 changed file: - testsuite/tests/lib/base/all.T Changes: ===================================== testsuite/tests/lib/base/all.T ===================================== @@ -1,7 +1,7 @@ test('DataTypeOrd', normal, compile_and_run, ['']) test('T16586', normal, compile_and_run, ['-O2']) # Event-manager not supported on Windows -test('T16916', [when(opsys('mingw32'), skip), js_broken(22261)], compile_and_run, ['-O2 -threaded -with-rtsopts="-I0" -rtsopts']) +test('T16916', [when(opsys('mingw32'), skip), js_broken(22261), fragile(16966)], compile_and_run, ['-O2 -threaded -with-rtsopts="-I0" -rtsopts']) test('T17310', normal, compile, ['']) test('T19691', normal, compile, ['']) test('executablePath', [extra_run_opts(config.os), js_broken(22261)], compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bb674262bd472ffeba145ebd4cd510ca16436c08 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bb674262bd472ffeba145ebd4cd510ca16436c08 You're receiving 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 Dec 3 09:39:40 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 03 Dec 2022 04:39:40 -0500 Subject: [Git][ghc/ghc][master] 2 commits: Refactor: FreshOrReuse instead of addTyClTyVarBinds Message-ID: <638b195cdec7f_17512e2fdaf3709223dd@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 1 changed file: - compiler/GHC/HsToCore/Quote.hs Changes: ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -461,7 +461,7 @@ repTyClD (L loc (FamDecl { tcdFam = fam })) = liftM Just $ repTyClD (L loc (SynDecl { tcdLName = tc, tcdTyVars = tvs, tcdRhs = rhs })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repSynDecl tc1 bndrs rhs ; return (Just (locA loc, dec)) } @@ -469,7 +469,7 @@ repTyClD (L loc (DataDecl { tcdLName = tc , tcdTyVars = tvs , tcdDataDefn = defn })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repDataDefn tc1 (Left bndrs) defn ; return (Just (locA loc, dec)) } @@ -478,7 +478,7 @@ repTyClD (L loc (ClassDecl { tcdCtxt = cxt, tcdLName = cls, tcdSigs = sigs, tcdMeths = meth_binds, tcdATs = ats, tcdATDefs = atds })) = do { cls1 <- lookupLOcc cls -- See Note [Binders and occurrences] - ; dec <- addQTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { cxt1 <- repLContext cxt -- See Note [Scoped type variables in quotes] ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs meth_binds @@ -549,14 +549,11 @@ repFamilyDecl decl@(L loc (FamilyDecl { fdInfo = info , fdResultSig = L _ resultSig , fdInjectivityAnn = injectivity })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; let mkHsQTvs :: [LHsTyVarBndr () GhcRn] -> LHsQTyVars GhcRn - mkHsQTvs tvs = HsQTvs { hsq_ext = [] - , hsq_explicit = tvs } - resTyVar = case resultSig of - TyVarSig _ bndr -> mkHsQTvs [bndr] - _ -> mkHsQTvs [] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> - addTyClTyVarBinds resTyVar $ \_ -> + ; let resTyVar = case resultSig of + TyVarSig _ bndr -> [hsLTyVarName bndr] + _ -> [] + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> + addSimpleTyVarBinds ReuseBoundNames resTyVar $ case info of ClosedTypeFamily Nothing -> notHandled (ThAbstractClosedTypeFamily decl) @@ -645,7 +642,7 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds , cid_datafam_insts = adts , cid_overlap_mode = overlap }) - = addSimpleTyVarBinds tvs $ + = addSimpleTyVarBinds FreshNamesOnly tvs $ -- We must bring the type variables into scope, so their -- occurrences don't fail, even though the binders don't -- appear in the resulting data structure @@ -672,7 +669,7 @@ repStandaloneDerivD :: LDerivDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat , deriv_type = ty })) = do { dec <- repDerivStrategy strat $ \strat' -> - addSimpleTyVarBinds tvs $ + addSimpleTyVarBinds FreshNamesOnly tvs $ do { cxt' <- repLContext cxt ; inst_ty' <- repLTy inst_ty ; repDeriv strat' cxt' inst_ty' } @@ -804,16 +801,17 @@ repDefD (L loc (DefaultDecl _ tys)) = do { tys1 <- repLTys tys repRuleD :: LRuleDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repRuleD (L loc (HsRule { rd_name = n , rd_act = act - , rd_tyvs = ty_bndrs + , rd_tyvs = m_ty_bndrs , rd_tmvs = tm_bndrs , rd_lhs = lhs , rd_rhs = rhs })) - = do { rule <- addHsTyVarBinds (fromMaybe [] ty_bndrs) $ \ ex_bndrs -> + = do { let ty_bndrs = fromMaybe [] m_ty_bndrs + ; rule <- addHsTyVarBinds FreshNamesOnly ty_bndrs $ \ ex_bndrs -> do { let tm_bndr_names = concatMap ruleBndrNames tm_bndrs ; ss <- mkGenSyms tm_bndr_names ; rule <- addBinds ss $ do { elt_ty <- wrapName tyVarBndrUnitTyConName - ; ty_bndrs' <- return $ case ty_bndrs of + ; ty_bndrs' <- return $ case m_ty_bndrs of Nothing -> coreNothing' (mkListTy elt_ty) Just _ -> coreJust' (mkListTy elt_ty) ex_bndrs ; tm_bndrs' <- repListM ruleBndrTyConName @@ -878,7 +876,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_ex_tvs = con_tvs , con_mb_cxt = mcxt , con_args = args })) - = addHsTyVarBinds con_tvs $ \ ex_bndrs -> + = addHsTyVarBinds FreshNamesOnly con_tvs $ \ ex_bndrs -> do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt @@ -1188,14 +1186,11 @@ addHsOuterFamEqnTyVarBinds outer_bndrs thing_inside = do elt_ty <- wrapName tyVarBndrUnitTyConName case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> - addTyClTyVarBinds (mk_qtvs imp_tvs []) $ \_th_exp_bndrs -> + addSimpleTyVarBinds ReuseBoundNames imp_tvs $ thing_inside $ coreNothingList elt_ty HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addTyClTyVarBinds (mk_qtvs [] exp_bndrs) $ \th_exp_bndrs -> + addHsTyVarBinds FreshNamesOnly exp_bndrs $ \th_exp_bndrs -> thing_inside $ coreJustList elt_ty th_exp_bndrs - where - mk_qtvs imp_tvs exp_tvs = HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs } addHsOuterSigTyVarBinds :: HsOuterSigTyVarBndrs GhcRn @@ -1204,9 +1199,9 @@ addHsOuterSigTyVarBinds :: addHsOuterSigTyVarBinds outer_bndrs thing_inside = case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> do th_nil <- coreListM tyVarBndrSpecTyConName [] - addSimpleTyVarBinds imp_tvs $ thing_inside th_nil + addSimpleTyVarBinds FreshNamesOnly imp_tvs $ thing_inside th_nil HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addHsTyVarBinds exp_bndrs thing_inside + addHsTyVarBinds FreshNamesOnly exp_bndrs thing_inside -- | If a type implicitly quantifies its outermost type variables, return -- 'True' if the list of implicitly bound type variables is empty. If a type @@ -1230,69 +1225,86 @@ nullOuterExplicit (HsOuterExplicit{hso_bndrs = exp_bndrs}) = null exp_bndrs nullOuterExplicit (HsOuterImplicit{}) = True -- Vacuously true, as there is no outermost explicit quantification -addSimpleTyVarBinds :: [Name] -- the binders to be added +-- Do we want to generate fresh names for type variables +-- or reuse the ones that are already in scope? +data FreshOrReuse + = FreshNamesOnly + -- Generate fresh names for all type variables, regardless of existing + -- variables in the MetaEnv. + -- + -- This is the default strategy. + + | ReuseBoundNames + -- Generate fresh names for type variables not in the MetaEnv. + -- Where a name is already bound in the MetaEnv, use that existing binding; + -- do not create a new one with a fresh name. + -- + -- This is the strategy used for data/newtype declarations and type family + -- instances, so that the nested type variables work right: + -- + -- class C a where + -- type W a b + -- instance C (T a) where + -- type W (T a) b = blah + -- + -- The 'a' in the type instance is the one bound by the instance decl + -- + -- Test cases: TH_reifyExplicitForAllFams T9081 T9199 T10811 + +mkGenSyms' :: FreshOrReuse -> [Name] -> MetaM [GenSymBind] +mkGenSyms' FreshNamesOnly names = mkGenSyms names +mkGenSyms' ReuseBoundNames names = + -- Make fresh names for the ones that are not already in scope + -- This makes things work for associated types + do { env <- lift dsGetMetaEnv + ; mkGenSyms (filterOut (`elemNameEnv` env) names) } + +addSimpleTyVarBinds :: FreshOrReuse + -> [Name] -- the binders to be added -> MetaM (Core (M a)) -- action in the ext env -> MetaM (Core (M a)) -addSimpleTyVarBinds names thing_inside - = do { fresh_names <- mkGenSyms names +addSimpleTyVarBinds fresh_or_reuse names thing_inside + = do { fresh_names <- mkGenSyms' fresh_or_reuse names ; term <- addBinds fresh_names thing_inside ; wrapGenSyms fresh_names term } addHsTyVarBinds :: forall flag flag' a. RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addHsTyVarBinds exp_tvs thing_inside - = do { fresh_exp_names <- mkGenSyms (hsLTyVarNames exp_tvs) +addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside + = do { fresh_exp_names <- mkGenSyms' fresh_or_reuse (hsLTyVarNames exp_tvs) ; term <- addBinds fresh_exp_names $ do { kbs <- repListM (tyVarBndrName @flag @flag') repTyVarBndr exp_tvs ; thing_inside kbs } ; wrapGenSyms fresh_exp_names term } -addQTyVarBinds :: LHsQTyVars GhcRn -- the binders to be added +addQTyVarBinds :: FreshOrReuse + -> LHsQTyVars GhcRn -- the binders to be added -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addQTyVarBinds (HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs }) - thing_inside - = addTyVarBinds exp_tvs imp_tvs thing_inside +addQTyVarBinds fresh_or_reuse qtvs thing_inside = + let HsQTvs { hsq_ext = imp_tvs + , hsq_explicit = exp_tvs } + = qtvs + in addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside addTyVarBinds :: RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> [Name] -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -- gensym a list of type variables and enter them into the meta environment; -- the computations passed as the second argument is executed in that extended -- meta environment and gets the *new* names on Core-level as an argument -addTyVarBinds exp_tvs imp_tvs thing_inside - = addSimpleTyVarBinds imp_tvs $ - addHsTyVarBinds exp_tvs $ +addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside + = addSimpleTyVarBinds fresh_or_reuse imp_tvs $ + addHsTyVarBinds fresh_or_reuse exp_tvs $ thing_inside -addTyClTyVarBinds :: LHsQTyVars GhcRn - -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) - -> MetaM (Core (M a)) --- Used for data/newtype declarations, and family instances, --- so that the nested type variables work right --- instance C (T a) where --- type W (T a) = blah --- The 'a' in the type instance is the one bound by the instance decl -addTyClTyVarBinds tvs m - = do { let tv_names = hsAllLTyVarNames tvs - ; env <- lift $ dsGetMetaEnv - ; freshNames <- mkGenSyms (filterOut (`elemNameEnv` env) tv_names) - -- Make fresh names for the ones that are not already in scope - -- This makes things work for family declarations - - ; term <- addBinds freshNames $ - do { kbs <- repListM tyVarBndrUnitTyConName repTyVarBndr - (hsQTvExplicit tvs) - ; m kbs } - - ; wrapGenSyms freshNames term } - -- | Represent a type variable binder repTyVarBndr :: RepTV flag flag' => LHsTyVarBndr flag GhcRn -> MetaM (Core (M (TH.TyVarBndr flag'))) @@ -1341,7 +1353,7 @@ repLTy ty = repTy (unLoc ty) repForallT :: HsType GhcRn -> MetaM (Core (M TH.Type)) repForallT ty | (tvs, ctxt, tau) <- splitLHsSigmaTyInvis (noLocA ty) - = addHsTyVarBinds tvs $ \bndrs -> + = addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { ctxt1 <- repLContext ctxt ; tau1 <- repLTy tau ; repTForall bndrs ctxt1 tau1 -- forall a. C a => {...} @@ -1352,7 +1364,7 @@ repTy ty@(HsForAllTy { hst_tele = tele, hst_body = body }) = case tele of HsForAllInvis{} -> repForallT ty HsForAllVis { hsf_vis_bndrs = tvs } -> - addHsTyVarBinds tvs $ \bndrs -> + addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do body1 <- repLTy body repTForallVis bndrs body1 repTy ty@(HsQualTy {}) = repForallT ty @@ -1606,7 +1618,7 @@ repE (RecordUpd { rupd_flds = Right _ }) panic "The impossible has happened!" repE (ExprWithTySig _ e wc_ty) - = addSimpleTyVarBinds (get_scoped_tvs_from_sig sig_ty) $ + = addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig sig_ty) $ do { e1 <- repLE e ; t1 <- rep_ty_sig' sig_ty ; repSigExp e1 t1 } @@ -2560,7 +2572,7 @@ repDerivStrategy mds thing_inside = StockStrategy _ -> thing_inside =<< just =<< repStockStrategy AnyclassStrategy _ -> thing_inside =<< just =<< repAnyclassStrategy NewtypeStrategy _ -> thing_inside =<< just =<< repNewtypeStrategy - ViaStrategy ty -> addSimpleTyVarBinds (get_scoped_tvs_from_sig ty) $ + ViaStrategy ty -> addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig ty) $ do ty' <- rep_ty_sig' ty via_strat <- repViaStrategy ty' m_via_strat <- just via_strat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bb674262bd472ffeba145ebd4cd510ca16436c08...c189b831c74a550ddb3b94cf9b9f8922856b6990 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bb674262bd472ffeba145ebd4cd510ca16436c08...c189b831c74a550ddb3b94cf9b9f8922856b6990 You're receiving 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 Dec 3 16:07:03 2022 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sat, 03 Dec 2022 11:07:03 -0500 Subject: [Git][ghc/ghc][wip/decode_cloned_stack] Invariant: Haskell ClosureTypes should be the same as if decoded with C Message-ID: <638b742799acb_17512e2fdaf370935258@gitlab.mail> Sven Tennie pushed to branch wip/decode_cloned_stack at Glasgow Haskell Compiler / GHC Commits: 989cebf1 by Sven Tennie at 2022-12-03T16:06:14+00:00 Invariant: Haskell ClosureTypes should be the same as if decoded with C - - - - - 7 changed files: - libraries/ghc-heap/tests/TestUtils.hs - libraries/ghc-heap/tests/all.T - libraries/ghc-heap/tests/stack_big_ret.hs - − libraries/ghc-heap/tests/stack_comparison.hs - libraries/ghc-heap/tests/stack_lib.c - libraries/ghc-heap/tests/stack_stm_frames.hs - libraries/ghc-heap/tests/stack_underflow.hs Changes: ===================================== libraries/ghc-heap/tests/TestUtils.hs ===================================== @@ -1,9 +1,24 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE UnliftedFFITypes #-} -module TestUtils where +module TestUtils + ( assertEqual, + assertThat, + assertStackInvariants + ) +where +import Data.Array.Byte +import GHC.Exts import GHC.Exts.DecodeStack +import GHC.Exts.Heap +import GHC.Records import GHC.Stack (HasCallStack) +import GHC.Stack.CloneStack assertEqual :: (HasCallStack, Monad m, Show a, Eq a) => a -> a -> m () assertEqual a b @@ -13,8 +28,8 @@ assertEqual a b assertThat :: (HasCallStack, Monad m) => String -> (a -> Bool) -> a -> m () assertThat s f a = if f a then pure () else error s -assertStackInvariants :: (HasCallStack, Monad m) => [StackFrame] -> m () -assertStackInvariants decodedStack = +assertStackInvariants :: (HasCallStack, Monad m) => StackSnapshot -> [StackFrame] -> m () +assertStackInvariants stack decodedStack = do assertThat "Last frame is stop frame" ( \case @@ -22,3 +37,98 @@ assertStackInvariants decodedStack = _ -> False ) (last decodedStack) + assertEqual + (toClosureTypes decodedStack) + (toClosureTypes stack) + +class ToClosureTypes a where + toClosureTypes :: a -> [ClosureType] + +instance ToClosureTypes StackSnapshot where + toClosureTypes = stackSnapshotToClosureTypes . foldStackToArrayClosure + +instance ToClosureTypes StackFrame where + toClosureTypes = stackFrameToClosureTypes + +instance ToClosureTypes a => ToClosureTypes [a] where + toClosureTypes = concatMap toClosureTypes + +foreign import ccall "foldStackToArrayClosure" foldStackToArrayClosure# :: StackSnapshot# -> ByteArray# + +foldStackToArrayClosure :: StackSnapshot -> ByteArray +foldStackToArrayClosure (StackSnapshot s#) = ByteArray (foldStackToArrayClosure# s#) + +stackSnapshotToClosureTypes :: ByteArray -> [ClosureType] +stackSnapshotToClosureTypes = wordsToClosureTypes . toWords + where + toWords :: ByteArray -> [Word] + toWords ba@(ByteArray b#) = + let s = I# (sizeofByteArray# b#) + in -- TODO: Adjust 8 to machine word size + [W# (indexWordArray# b# (toInt# i)) | i <- [0 .. maxWordIndex (ba)]] + where + maxWordIndex :: ByteArray -> Int + maxWordIndex (ByteArray ba#) = + let s = I# (sizeofByteArray# ba#) + words = s `div` 8 + in case words of + w | w == 0 -> error "ByteArray contains no content!" + w -> w - 1 + + wordsToClosureTypes :: [Word] -> [ClosureType] + wordsToClosureTypes = map (toEnum . fromIntegral) + +toInt# :: Int -> Int# +toInt# (I# i#) = i# + +stackFrameToClosureTypes :: StackFrame -> [ClosureType] +stackFrameToClosureTypes sf = + case sf of + (UpdateFrame {updatee, ..}) -> UPDATE_FRAME : getClosureTypes updatee + (CatchFrame {handler, ..}) -> CATCH_FRAME : getClosureTypes handler + (CatchStmFrame {code, handler}) -> CATCH_STM_FRAME : getClosureTypes code ++ getClosureTypes handler + (CatchRetryFrame {first_code, alt_code, ..}) -> CATCH_RETRY_FRAME : getClosureTypes first_code ++ getClosureTypes alt_code + (AtomicallyFrame {code, result}) -> ATOMICALLY_FRAME : getClosureTypes code ++ getClosureTypes result + (UnderflowFrame {..}) -> [UNDERFLOW_FRAME] + StopFrame -> [STOP_FRAME] + (RetSmall {payload, ..}) -> RET_SMALL : getBitmapClosureTypes payload + (RetBig {payload}) -> RET_BIG : getBitmapClosureTypes payload + (RetFun {fun, payload, ..}) -> RET_FUN : getClosureTypes fun ++ getBitmapClosureTypes payload + (RetBCO {instrs, literals, ptrs, payload, ..}) -> + RET_BCO : getClosureTypes instrs ++ getClosureTypes literals ++ getClosureTypes ptrs ++ getBitmapClosureTypes payload + where + getClosureTypes :: Closure -> [ClosureType] + getClosureTypes (ConstrClosure {info, ..}) = [tipe info] + getClosureTypes (FunClosure {info, ..}) = [tipe info] + getClosureTypes (ThunkClosure {info, ..}) = [tipe info] + getClosureTypes (SelectorClosure {info, ..}) = [tipe info] + getClosureTypes (PAPClosure {info, ..}) = [tipe info] + getClosureTypes (APClosure {info, ..}) = [tipe info] + getClosureTypes (APStackClosure {info, ..}) = [tipe info] + getClosureTypes (IndClosure {info, ..}) = [tipe info] + getClosureTypes (BCOClosure {info, ..}) = [tipe info] + getClosureTypes (BlackholeClosure {info, ..}) = [tipe info] + getClosureTypes (ArrWordsClosure {info, ..}) = [tipe info] + getClosureTypes (MutArrClosure {info, ..}) = [tipe info] + getClosureTypes (SmallMutArrClosure {info, ..}) = [tipe info] + getClosureTypes (MVarClosure {info, ..}) = [tipe info] + getClosureTypes (IOPortClosure {info, ..}) = [tipe info] + getClosureTypes (MutVarClosure {info, ..}) = [tipe info] + getClosureTypes (BlockingQueueClosure {info, ..}) = [tipe info] + getClosureTypes (WeakClosure {info, ..}) = [tipe info] + getClosureTypes (TSOClosure {info, ..}) = [tipe info] + getClosureTypes (StackClosure {info, ..}) = [tipe info] + getClosureTypes (OtherClosure {info, ..}) = [tipe info] + getClosureTypes (UnsupportedClosure {info, ..}) = [tipe info] + getClosureTypes _ = [] + + getBitmapClosureTypes :: [BitmapPayload] -> [ClosureType] + getBitmapClosureTypes bps = + reverse $ + foldl + ( \acc p -> case p of + (Closure c) -> getClosureTypes c ++ acc + (Primitive _) -> acc + ) + [] + bps ===================================== libraries/ghc-heap/tests/all.T ===================================== @@ -60,37 +60,35 @@ test('decode_cloned_stack', [only_ways(['normal'])], compile_and_run, ['-debug -optc-g -g']) +# TODO: Remove debug flags test('stack_big_ret', [ - extra_files(['TestUtils.hs']), + extra_files(['stack_lib.c', 'TestUtils.hs']), ignore_stdout, ignore_stderr ], - compile_and_run, - ['-debug']) + multi_compile_and_run, + ['stack_big_ret', [('stack_lib.c','')], '-debug -optc-g -g']) +# TODO: Remove debug flags # Options: # - `-kc512B -kb64B`: Make stack chunk size small to provoke underflow stack frames. test('stack_underflow', [ - extra_files(['TestUtils.hs']), + extra_files(['stack_lib.c', 'TestUtils.hs']), extra_run_opts('+RTS -kc512B -kb64B -RTS'), ignore_stdout, ignore_stderr ], - compile_and_run, ['-debug -rtsopts']) + multi_compile_and_run, + ['stack_underflow', [('stack_lib.c','')], '-debug -optc-g -g']) +# TODO: Remove debug flags test('stack_stm_frames', [ - extra_files(['TestUtils.hs']), + extra_files(['stack_lib.c', 'TestUtils.hs']), ignore_stdout, ignore_stderr ], - compile_and_run, ['-debug']) - -test('stack_comparison', - [extra_files(['stack_lib.c','TestUtils.hs']), -# ignore_stdout, - ignore_stderr - ], - multi_compile_and_run, ['stack_comparison', [('stack_lib.c','')], '-debug -optc-g -g']) + multi_compile_and_run, + ['stack_stm_frames', [('stack_lib.c','')], '-debug -optc-g -g']) ===================================== libraries/ghc-heap/tests/stack_big_ret.hs ===================================== @@ -34,11 +34,11 @@ main = do bigFun (cloneStackReturnInt stackRef) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 - stackSnapshot <- readIORef stackRef + mbStackSnapshot <- readIORef stackRef + let stackSnapshot = fromJust mbStackSnapshot + !decodedStack <- decodeStack stackSnapshot - !decodedStack <- decodeStack (fromJust stackSnapshot) - - assertStackInvariants decodedStack + assertStackInvariants stackSnapshot decodedStack assertThat "Stack contains one big return frame" (== 1) ===================================== libraries/ghc-heap/tests/stack_comparison.hs deleted ===================================== @@ -1,103 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE ForeignFunctionInterface #-} -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE UnliftedFFITypes #-} - -module Main where - -import Data.Array.Byte -import GHC.Exts -import GHC.Exts.DecodeStack -import GHC.Exts.Heap -import GHC.Exts.Heap (StgInfoTable (StgInfoTable)) -import GHC.Records -import GHC.Stack.CloneStack -import TestUtils - -foreign import ccall "foldStackToArrayClosure" foldStackToArrayClosure# :: StackSnapshot# -> ByteArray# - -foldStackToArrayClosure :: StackSnapshot -> ByteArray -foldStackToArrayClosure (StackSnapshot s#) = ByteArray (foldStackToArrayClosure# s#) - -main :: IO () -main = do - stack <- cloneMyStack - let ba = foldStackToArrayClosure stack - let s = I# (sizeofByteArray# b#) - (ByteArray b#) = ba - print . show . wordsToClosureTypes . toWords $ ba - frames <- decodeStack stack - print $ show (concatMap stackFrameToClosureTypes frames) - -toWords :: ByteArray -> [Word] -toWords ba@(ByteArray b#) = - let s = I# (sizeofByteArray# b#) - in -- TODO: Adjust 8 to machine word size - [W# (indexWordArray# b# (toInt# i)) | i <- [0 .. maxWordIndex (ba)]] - where - maxWordIndex :: ByteArray -> Int - maxWordIndex (ByteArray ba#) = - let s = I# (sizeofByteArray# ba#) - words = s `div` 8 - in case words of - w | w == 0 -> error "ByteArray contains no content!" - w -> w - 1 - -wordsToClosureTypes :: [Word] -> [ClosureType] -wordsToClosureTypes = map (toEnum . fromIntegral) - -toInt# :: Int -> Int# -toInt# (I# i#) = i# - -stackFrameToClosureTypes :: StackFrame -> [ClosureType] -stackFrameToClosureTypes sf = - case sf of - (UpdateFrame {updatee, ..}) -> UPDATE_FRAME : getClosureTypes updatee - (CatchFrame {handler, ..}) -> CATCH_FRAME : getClosureTypes handler - (CatchStmFrame {code, handler}) -> CATCH_STM_FRAME : getClosureTypes code ++ getClosureTypes handler - (CatchRetryFrame {first_code, alt_code, ..}) -> CATCH_RETRY_FRAME : getClosureTypes first_code ++ getClosureTypes alt_code - (AtomicallyFrame {code, result}) -> ATOMICALLY_FRAME : getClosureTypes code ++ getClosureTypes result - (UnderflowFrame {..}) -> [UNDERFLOW_FRAME] - StopFrame -> [STOP_FRAME] - (RetSmall {payload, ..}) -> RET_SMALL : getBitmapClosureTypes payload - (RetBig {payload}) -> RET_BIG : getBitmapClosureTypes payload - (RetFun {fun, payload, ..}) -> RET_FUN : getClosureTypes fun ++ getBitmapClosureTypes payload - (RetBCO {instrs, literals, ptrs, payload, ..}) -> - RET_BCO : getClosureTypes instrs ++ getClosureTypes literals ++ getClosureTypes ptrs ++ getBitmapClosureTypes payload - -getClosureTypes :: Closure -> [ClosureType] -getClosureTypes (ConstrClosure {info, ..}) = [tipe info] -getClosureTypes (FunClosure {info, ..}) = [tipe info] -getClosureTypes (ThunkClosure {info, ..}) = [tipe info] -getClosureTypes (SelectorClosure {info, ..}) = [tipe info] -getClosureTypes (PAPClosure {info, ..}) = [tipe info] -getClosureTypes (APClosure {info, ..}) = [tipe info] -getClosureTypes (APStackClosure {info, ..}) = [tipe info] -getClosureTypes (IndClosure {info, ..}) = [tipe info] -getClosureTypes (BCOClosure {info, ..}) = [tipe info] -getClosureTypes (BlackholeClosure {info, ..}) = [tipe info] -getClosureTypes (ArrWordsClosure {info, ..}) = [tipe info] -getClosureTypes (MutArrClosure {info, ..}) = [tipe info] -getClosureTypes (SmallMutArrClosure {info, ..}) = [tipe info] -getClosureTypes (MVarClosure {info, ..}) = [tipe info] -getClosureTypes (IOPortClosure {info, ..}) = [tipe info] -getClosureTypes (MutVarClosure {info, ..}) = [tipe info] -getClosureTypes (BlockingQueueClosure {info, ..}) = [tipe info] -getClosureTypes (WeakClosure {info, ..}) = [tipe info] -getClosureTypes (TSOClosure {info, ..}) = [tipe info] -getClosureTypes (StackClosure {info, ..}) = [tipe info] -getClosureTypes (OtherClosure {info, ..}) = [tipe info] -getClosureTypes (UnsupportedClosure {info, ..}) = [tipe info] -getClosureTypes _ = [] - -getBitmapClosureTypes :: [BitmapPayload] -> [ClosureType] -getBitmapClosureTypes bps = - reverse $ - foldl - ( \acc p -> case p of - (Closure c) -> getClosureTypes c ++ acc - (Primitive _) -> acc - ) - [] - bps ===================================== libraries/ghc-heap/tests/stack_lib.c ===================================== @@ -87,6 +87,7 @@ ClosureTypeList *foldLargeBitmapToList(StgPtr spBottom, StgPtr payload, for (; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1) { if ((bitmap & 1) == 0) { StgClosure *c = (StgClosure *)payload[i]; + c = UNTAG_CONST_CLOSURE(c); list = add(list, get_itbl(c)->type); } // TODO: Primitives are ignored here. @@ -114,7 +115,7 @@ ClosureTypeList *foldStackToList(StgStack *stack) { } case UPDATE_FRAME: { StgUpdateFrame *f = (StgUpdateFrame *)sp; - result = add(result, get_itbl(f->updatee)->type); + result = add(result, get_itbl(UNTAG_CONST_CLOSURE(f->updatee))->type); continue; } case CATCH_FRAME: { @@ -127,14 +128,14 @@ ClosureTypeList *foldStackToList(StgStack *stack) { } case CATCH_STM_FRAME: { StgCatchSTMFrame *f = (StgCatchSTMFrame *)sp; - result = add(result, get_itbl(f->code)->type); - result = add(result, get_itbl(f->handler)->type); + result = add(result, get_itbl(UNTAG_CONST_CLOSURE(f->code))->type); + result = add(result, get_itbl(UNTAG_CONST_CLOSURE(f->handler))->type); continue; } case ATOMICALLY_FRAME: { StgAtomicallyFrame *f = (StgAtomicallyFrame *)sp; - result = add(result, get_itbl(f->code)->type); - result = add(result, get_itbl(f->result)->type); + result = add(result, get_itbl(UNTAG_CONST_CLOSURE(f->code))->type); + result = add(result, get_itbl(UNTAG_CONST_CLOSURE(f->result))->type); continue; } case RET_SMALL: { ===================================== libraries/ghc-heap/tests/stack_stm_frames.hs ===================================== @@ -9,18 +9,21 @@ import TestUtils main :: IO () main = do - decodedStack <- + (stackSnapshot, decodedStack) <- atomically $ catchSTM @SomeException (unsafeIOToSTM getDecodedStack) throwSTM - assertStackInvariants decodedStack + assertStackInvariants stackSnapshot decodedStack assertThat "Stack contains one catch stm frame" (== 1) (length $ filter isCatchStmFrame decodedStack) -getDecodedStack :: IO [StackFrame] -getDecodedStack = cloneMyStack >>= decodeStack +getDecodedStack :: IO (StackSnapshot, [StackFrame]) +getDecodedStack = do + s <-cloneMyStack + fs <- decodeStack s + pure (s, fs) isCatchStmFrame :: StackFrame -> Bool isCatchStmFrame (CatchStmFrame _ _) = True ===================================== libraries/ghc-heap/tests/stack_underflow.hs ===================================== @@ -20,7 +20,7 @@ getStack = do !decodedStack <- decodeStack s -- Uncomment to see the frames (for debugging purposes) -- hPutStrLn stderr $ "Stack frames : " ++ show decodedStack - assertStackInvariants decodedStack + assertStackInvariants s decodedStack assertThat "Stack contains underflow frames" (== True) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/989cebf1929949435251e4c22986e6fb512d7f3a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/989cebf1929949435251e4c22986e6fb512d7f3a You're receiving 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 Dec 4 12:53:05 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sun, 04 Dec 2022 07:53:05 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/epa-bufspan Message-ID: <638c983171225_17512e64b9d709655f2@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/epa-bufspan at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/epa-bufspan You're receiving 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 Dec 4 15:59:03 2022 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Sun, 04 Dec 2022 10:59:03 -0500 Subject: [Git][ghc/ghc][wip/T22166] linker: Fix BFD import libraries Message-ID: <638cc3c744a09_17512e52be8984437@gitlab.mail> Tamar Christina pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: f296eae7 by Tamar Christina at 2022-12-04T15:55:43+00:00 linker: Fix BFD import libraries - - - - - 5 changed files: - rts/Linker.c - rts/LinkerInternals.h - rts/linker/PEi386.c - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/ghci/linking/dyn/all.T Changes: ===================================== rts/Linker.c ===================================== @@ -228,7 +228,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key, static const char * symbolTypeString (SymType type) { - switch (type) { + switch (type & ~SYM_TYPE_DUP_DISCARD) { case SYM_TYPE_CODE: return "code"; case SYM_TYPE_DATA: return "data"; case SYM_TYPE_INDIRECT_DATA: return "indirect-data"; @@ -277,14 +277,19 @@ int ghciInsertSymbolTable( insertStrHashTable(table, key, pinfo); return 1; } - else if (pinfo->type != type) + else if (pinfo->type ^ type) { - debugBelch("Symbol type mismatch.\n"); - debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", - key, obj_name, symbolTypeString(type)); - debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", - pinfo->owner ? pinfo->owner->fileName : WSTR(""), - symbolTypeString(pinfo->type)); + /* We were asked to discard the symbol on duplicates, do so quietly. */ + if (!(type & SYM_TYPE_DUP_DISCARD)) + { + DebugBreak (); + debugBelch("Symbol type mismatch.\n"); + debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", + key, obj_name, symbolTypeString(type)); + debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", + pinfo->owner ? pinfo->owner->fileName : WSTR(""), + symbolTypeString(pinfo->type)); + } return 1; } else if (pinfo->strength == STRENGTH_STRONG) ===================================== rts/LinkerInternals.h ===================================== @@ -54,9 +54,12 @@ typedef struct _Section Section; /* What kind of thing a symbol identifies. We need to know this to determine how * to process overflowing relocations. See Note [Processing overflowed relocations]. */ typedef enum _SymType { - SYM_TYPE_CODE, /* the symbol is a function and can be relocated via a jump island */ - SYM_TYPE_DATA, /* the symbol is data */ - SYM_TYPE_INDIRECT_DATA, /* see Note [_iob_func symbol] */ + SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */ + SYM_TYPE_DATA = 1 << 1, /* the symbol is data */ + SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */ + SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library + however if a duplicate is found with a mismatching + SymType then discard this one. */ } SymType; ===================================== rts/linker/PEi386.c ===================================== @@ -261,6 +261,54 @@ .asciiz "libfoo_data" + Note [GHC Linking model and import libraries] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The above describes how import libraries work for static linking. + Fundamentally this does not apply to Dynamic linknig as we do in GHC. + The issue is two folds: + + 1. In the linking model above it is expected that the .idata sections be + materialized into PLTs during linking. However in GHC we never create + PLTs, but have out own mechanism for this which is the jump island + machinery. This is required for efficiency. For one materializing the + idata sections would result in wasting pages. We'd use one page for + every ~100 bytes. This is extremely wasteful and also fragments the + memory. Secondly the dynamic linker is lazy. We only perform the final + loading if the symbol is used, however with an import library we can + discard the actual OC immediately after reading it. This prevents us from + keeping ~1k in memory per symbol for no reason. + + 2. GHC itself does not observ symbol visibility correctly during NGC. This + in itself isn't an academic exercise. The issue stems from GHC using one + mechanism for providing two incompatible linking modes: + a) The first mode is generating Haskell shared libraries which are + intended to be used by other Haskell code. This requires us to + export the info, data and closures. For this GHC just re-exports + all symbols. But it doesn't correcly mark data/code. Symbol + visibility is overwritten by telling the linker to export all + symbols. + b) The second code is producing code that's supposed to be call-able + through a C insterface. This in reality does not require the + export of closures and info tables. But also does not require the + inclusion of the RTS inside the DLL. Hover this is done today + because we don't properly have the RTS as a dynamic library. + i.e. GHC does not only export symbols denoted by foreign export. + Also GHC should depend on an RTS library, but at the moment it + cannot because of TNTC is incompatible with dynamic linking. + + These two issues mean that for GHC we need to take a different approach + to handling import libraries. For normal C libraries we have proper + differentiation between CODE and DATA. For GHC produced import libraries + we do not. As such the SYM_TYPE_DUP_DISCARD tells the linker that if a + duplictae symbol is found, and we were going to discard it anyway, just do + so quitely. This works because the RTS symbols themselves are provided by + the currently loaded RTS as built-in symbols. + + Secondly we cannot rely on a text symbol being available. As such we + should only depend on the symbols as definited in the .idata sections, + otherwise we would not be able to correctly link against GHC produced + import libraries. + Note [Memory allocation] ~~~~~~~~~~~~~~~~~~~~~~~~ The loading of an object begins in `preloadObjectFile`, which allocates a buffer, @@ -1700,7 +1748,10 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if ( secNumber != IMAGE_SYM_UNDEFINED && secNumber > 0 && section - && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY) { + /* Skip all BFD import sections. */ + && section->kind != SECTIONKIND_IMPORT + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY_HEAD) { /* This symbol is global and defined, viz, exported */ /* for IMAGE_SYMCLASS_EXTERNAL && !IMAGE_SYM_UNDEFINED, @@ -1733,12 +1784,49 @@ ocGetNames_PEi386 ( ObjectCode* oc ) IF_DEBUG(linker_verbose, debugBelch("bss symbol @ %p %u\n", addr, symValue)); } else if (section && section->kind == SECTIONKIND_BFD_IMPORT_LIBRARY) { - setImportSymbol(oc, sname); + /* Disassembly of section .idata$5: + + 0000000000000000 <__imp_Insert>: + ... + 0: IMAGE_REL_AMD64_ADDR32NB .idata$6 + + The first two bytes contain the ordinal of the function + in the format of lowpart highpart. The two bytes combined + for the total range of 16 bits which is the function export limit + of DLLs. See note [GHC Linking model and import libraries]. */ + sname = (SymbolName*)section->start+2; + COFF_symbol* sym = &oc->info->symbols[info->numberOfSymbols-1]; + addr = get_sym_name( getSymShortName (info, sym), oc); + + IF_DEBUG(linker, + debugBelch("addImportSymbol `%s' => `%s'\n", + sname, (char*)addr)); + /* We're going to free the any data associated with the import + library without copying the sections. So we have to duplicate + the symbol name and values before the pointers become invalid. */ + sname = strdup (sname); + addr = strdup (addr); + type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA; + type |= SYM_TYPE_DUP_DISCARD; + if (!ghciInsertSymbolTable(oc->fileName, symhash, sname, + addr, false, type, oc)) { + releaseOcInfo (oc); + stgFree (oc->image); + oc->image = NULL; + return false; + } + setImportSymbol (oc, sname); + + /* Don't process this oc any further. Just exit. */ + oc->n_symbols = 0; + oc->symbols = NULL; + stgFree (oc->image); + oc->image = NULL; + releaseOcInfo (oc); // There is nothing that we need to resolve in this object since we // will never call the import stubs in its text section oc->status = OBJECT_DONT_RESOLVE; - - IF_DEBUG(linker_verbose, debugBelch("import symbol %s\n", sname)); + return true; } else if (secNumber > 0 && section ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -88,10 +88,6 @@ compile_libAB_dyn: .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: - rm -rf bin_impl_gcc - mkdir bin_impl_gcc - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_impl_gcc" -shared A.c -o "bin_impl_gcc/$(call DLL,ASimpL)" - mv bin_impl_gcc/libASimpL.dll.a bin_impl_gcc/libASx.dll.a echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T11072.hs -lASx -L./bin_impl_gcc .PHONY: compile_libAS_impl_msvc ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -33,9 +33,9 @@ test('T10458', extra_hc_opts('-L"$PWD/T10458dir" -lAS')], ghci_script, ['T10458.script']) -test('T11072gcc', [extra_files(['A.c', 'T11072.hs']), - expect_broken(18718), - unless(doing_ghci, skip), unless(opsys('mingw32'), skip)], +test('T11072gcc', [extra_files(['A.c', 'T11072.hs', 'bin_impl_gcc/']), + unless(doing_ghci, skip), unless(opsys('mingw32'), skip), + unless(arch('x86_64'), skip)], makefile_test, ['compile_libAS_impl_gcc']) test('T11072msvc', [extra_files(['A.c', 'T11072.hs', 'libAS.def', 'i686/', 'x86_64/']), View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f296eae73fbca3c53a510fec667e2732a009bc1f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f296eae73fbca3c53a510fec667e2732a009bc1f You're receiving 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 Dec 4 16:24:24 2022 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Sun, 04 Dec 2022 11:24:24 -0500 Subject: [Git][ghc/ghc][wip/T22166] 364 commits: Add native delimited continuations to the RTS Message-ID: <638cc9b8b0f9f_17512e64b9d709904d0@gitlab.mail> Tamar Christina pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by M Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 37ddc65a by Ryan Scott at 2022-12-04T16:23:48+00:00 Draft: Windows: Remove mingwex dependency TODO: Write a commit message explaining why this is necessary. The proximal reason is to make GHC's Clang toolchain work when `LIBRARY_PATH=/mingw64/lib` is set, although I don't quite understand how everything interacts with each other. TODO: This isn't quite done yet, since running a test case involving Template Haskell still results in some failures with `LIBRARY_PATH=/mingw64/lib` set: ``` $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe [1 of 2] Compiling Main ( Bug.hs, Bug.o ) ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info' ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above. <no location info>: error: GHC.ByteCode.Linker.lookupCE During interactive linking, GHCi couldn't find the following symbol: templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` I haven't been able to figure out why yet, but I'm pushing the current state of the work so that Phyx can look at it. TODO: Cite T22166 [ci skip] - - - - - 3a21290e by Tamar Christina at 2022-12-04T16:24:00+00:00 linker: Fix BFD import libraries - - - - - 19 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - CODEOWNERS - README.md - − appveyor.yml - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f296eae73fbca3c53a510fec667e2732a009bc1f...3a21290e230520b342a301c1e8a9aad6c312c45a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f296eae73fbca3c53a510fec667e2732a009bc1f...3a21290e230520b342a301c1e8a9aad6c312c45a You're receiving 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 Dec 4 16:29:37 2022 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Sun, 04 Dec 2022 11:29:37 -0500 Subject: [Git][ghc/ghc][wip/T22166] 2 commits: Windows: Remove mingwex dependency Message-ID: <638ccaf187a14_17512e52be899084a@gitlab.mail> Tamar Christina pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: 56dadd26 by Ryan Scott at 2022-12-04T16:28:58+00:00 Windows: Remove mingwex dependency TODO: Write a commit message explaining why this is necessary. The proximal reason is to make GHC's Clang toolchain work when `LIBRARY_PATH=/mingw64/lib` is set, although I don't quite understand how everything interacts with each other. TODO: This isn't quite done yet, since running a test case involving Template Haskell still results in some failures with `LIBRARY_PATH=/mingw64/lib` set: ``` $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe [1 of 2] Compiling Main ( Bug.hs, Bug.o ) ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info' ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above. <no location info>: error: GHC.ByteCode.Linker.lookupCE During interactive linking, GHCi couldn't find the following symbol: templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` I haven't been able to figure out why yet, but I'm pushing the current state of the work so that Phyx can look at it. TODO: Cite T22166 [ci skip] - - - - - 3e8ae3f8 by Tamar Christina at 2022-12-04T16:29:22+00:00 linker: Fix BFD import libraries - - - - - 28 changed files: - configure.ac - hadrian/cfg/system.config.in - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Packages.hs - libraries/Cabal - libraries/Win32 - libraries/array - libraries/base/System/Posix/Internals.hs - libraries/base/base.cabal - libraries/base/configure.ac - libraries/base/include/HsBase.h - libraries/deepseq - libraries/filepath - libraries/ghc-bignum/gmp/gmp-tarballs - libraries/ghc-prim/ghc-prim.cabal - libraries/haskeline - libraries/process - libraries/text - libraries/unix - rts/Linker.c - rts/LinkerInternals.h - rts/RtsSymbols.c - rts/linker/PEi386.c - rts/package.conf.in - rts/rts.cabal.in - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/ghci/linking/dyn/all.T - utils/haddock Changes: ===================================== configure.ac ===================================== @@ -927,17 +927,6 @@ AC_CHECK_DECLS([program_invocation_short_name], , , [#define _GNU_SOURCE 1 #include ]) -dnl ** check for mingwex library -AC_CHECK_LIB( - [mingwex], - [closedir], - [AC_SUBST([HaveLibMingwEx],[YES])] [AC_SUBST([CabalMingwex],[True])], - [AC_SUBST([HaveLibMingwEx],[NO])] [AC_SUBST([CabalMingwex],[False])]) - -if test $HaveLibMingwEx = YES ; then - AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.]) -fi - dnl ** check for math library dnl Keep that check as early as possible. dnl as we need to know whether we need libm ===================================== hadrian/cfg/system.config.in ===================================== @@ -204,7 +204,6 @@ libnuma-lib-dir = @LibNumaLibDir@ use-lib-dw = @UseLibdw@ use-lib-numa = @UseLibNuma@ -use-lib-mingw-ex = @HaveLibMingwEx@ use-lib-m = @UseLibm@ use-lib-rt = @UseLibrt@ use-lib-dl = @UseLibdl@ ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -33,7 +33,6 @@ data Flag = ArSupportsAtFile | UseLibffiForAdjustors | UseLibdw | UseLibnuma - | UseLibmingwex | UseLibm | UseLibrt | UseLibdl @@ -63,7 +62,6 @@ flag f = do UseLibffiForAdjustors -> "use-libffi-for-adjustors" UseLibdw -> "use-lib-dw" UseLibnuma -> "use-lib-numa" - UseLibmingwex -> "use-lib-mingw-ex" UseLibm -> "use-lib-m" UseLibrt -> "use-lib-rt" UseLibdl -> "use-lib-dl" ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -404,7 +404,6 @@ rtsPackageArgs = package rts ? do [ "-DTOP=" ++ show top ] , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" - , builder HsCpp ? flag UseLibmingwex ? arg "-DHAVE_LIBMINGWEX" ] -- Compile various performance-critical pieces *without* -fPIC -dynamic -- even when building a shared library. If we don't do this, then the ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit 410f871df899e5af0847089354e0031fe051551d +Subproject commit dac10555299fa0d750838529a67598821264e5e3 ===================================== libraries/Win32 ===================================== @@ -1 +1 @@ -Subproject commit 931497f7052f63cb5cfd4494a94e572c5c570642 +Subproject commit e6c0c0f44f6dfc2f8255fc4a5017f4ab67cd0242 ===================================== libraries/array ===================================== @@ -1 +1 @@ -Subproject commit acd92ba77c205a039d9c6eaabb3e35d09e330160 +Subproject commit 77990b2132ba688f6282822891da2b9455e33c2f ===================================== libraries/base/System/Posix/Internals.hs ===================================== @@ -452,7 +452,6 @@ foreign import ccall unsafe "HsBase.h __hscore_fstat" foreign import ccall unsafe "HsBase.h __hscore_lstat" lstat :: CFilePath -> Ptr CStat -> IO CInt - #endif #if defined(js_HOST_ARCH) @@ -592,83 +591,74 @@ foreign import javascript unsafe "(($1,$2,$3_1,$3_2) => { return h$base_c_fcntl_ #else -{- Note: Win32 POSIX functions -Functions that are not part of the POSIX standards were -at some point deprecated by Microsoft. This deprecation -was performed by renaming the functions according to the -C++ ABI Section 17.6.4.3.2b. This was done to free up the -namespace of normal Windows programs since Windows isn't -POSIX compliant anyway. +#if defined(mingw32_HOST_OS) +-- See Note: Windows types +foreign import capi unsafe "HsBase.h _read" + c_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt -These were working before since the RTS was re-exporting -these symbols under the undeprecated names. This is no longer -being done. See #11223 +-- See Note: Windows types +foreign import capi safe "HsBase.h _read" + c_safe_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt -See https://msdn.microsoft.com/en-us/library/ms235384.aspx -for more. +foreign import ccall unsafe "HsBase.h _umask" + c_umask :: CMode -> IO CMode -However since we can't hope to get people to support Windows -packages we should support the deprecated names. See #12497 --} -foreign import capi unsafe "unistd.h lseek" - c_lseek :: CInt -> COff -> CInt -> IO COff +-- See Note: Windows types +foreign import capi unsafe "HsBase.h _write" + c_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt -foreign import ccall unsafe "HsBase.h access" +-- See Note: Windows types +foreign import capi safe "HsBase.h _write" + c_safe_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt + +foreign import ccall unsafe "HsBase.h _pipe" + c_pipe :: Ptr CInt -> IO CInt + +foreign import capi unsafe "HsBase.h _lseeki64" + c_lseek :: CInt -> Int64 -> CInt -> IO Int64 + +foreign import capi unsafe "HsBase.h _access" c_access :: CString -> CInt -> IO CInt #if !defined(HAVE_CHMOD) c_chmod :: CString -> CMode -> IO CInt -c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "chmod") +c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "_chmod") #else -foreign import ccall unsafe "HsBase.h chmod" +foreign import ccall unsafe "HsBase.h _chmod" c_chmod :: CString -> CMode -> IO CInt #endif -foreign import ccall unsafe "HsBase.h close" +foreign import capi unsafe "HsBase.h _close" c_close :: CInt -> IO CInt -foreign import ccall unsafe "HsBase.h creat" +foreign import capi unsafe "HsBase.h _creat" c_creat :: CString -> CMode -> IO CInt #if !defined(HAVE_DUP) c_dup :: CInt -> IO CInt -c_dup _ = ioError (ioeSetLocation unsupportedOperation "dup") +c_dup _ = ioError (ioeSetLocation unsupportedOperation "_dup") c_dup2 :: CInt -> CInt -> IO CInt -c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "dup2") +c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "_dup2") #else -foreign import ccall unsafe "HsBase.h dup" +foreign import ccall unsafe "HsBase.h _dup" c_dup :: CInt -> IO CInt -foreign import ccall unsafe "HsBase.h dup2" +foreign import ccall unsafe "HsBase.h _dup2" c_dup2 :: CInt -> CInt -> IO CInt #endif -foreign import ccall unsafe "HsBase.h isatty" +foreign import capi unsafe "HsBase.h _isatty" c_isatty :: CInt -> IO CInt -#if defined(mingw32_HOST_OS) --- See Note: Windows types -foreign import capi unsafe "HsBase.h _read" - c_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt - --- See Note: Windows types -foreign import capi safe "HsBase.h _read" - c_safe_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt - -foreign import ccall unsafe "HsBase.h _umask" - c_umask :: CMode -> IO CMode - --- See Note: Windows types -foreign import capi unsafe "HsBase.h _write" - c_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt +foreign import capi unsafe "HsBase.h _unlink" + c_unlink :: CString -> IO CInt --- See Note: Windows types -foreign import capi safe "HsBase.h _write" - c_safe_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt +foreign import capi unsafe "HsBase.h _utime" + c_utime :: CString -> Ptr CUtimbuf -> IO CInt -foreign import ccall unsafe "HsBase.h _pipe" - c_pipe :: Ptr CInt -> IO CInt +foreign import capi unsafe "HsBase.h _getpid" + c_getpid :: IO CPid #else -- We use CAPI as on some OSs (eg. Linux) this is wrapped by a macro -- which redirects to the 64-bit-off_t versions when large file @@ -700,8 +690,44 @@ c_pipe _ = ioError (ioeSetLocation unsupportedOperation "pipe") foreign import ccall unsafe "HsBase.h pipe" c_pipe :: Ptr CInt -> IO CInt #endif + +foreign import capi unsafe "unistd.h lseek" + c_lseek :: CInt -> COff -> CInt -> IO COff + +foreign import ccall unsafe "HsBase.h access" + c_access :: CString -> CInt -> IO CInt + +#if !defined(HAVE_CHMOD) +c_chmod :: CString -> CMode -> IO CInt +c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "chmod") +#else +foreign import ccall unsafe "HsBase.h chmod" + c_chmod :: CString -> CMode -> IO CInt #endif +foreign import ccall unsafe "HsBase.h close" + c_close :: CInt -> IO CInt + +foreign import ccall unsafe "HsBase.h creat" + c_creat :: CString -> CMode -> IO CInt + +#if !defined(HAVE_DUP) +c_dup :: CInt -> IO CInt +c_dup _ = ioError (ioeSetLocation unsupportedOperation "dup") + +c_dup2 :: CInt -> CInt -> IO CInt +c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "dup2") +#else +foreign import ccall unsafe "HsBase.h dup" + c_dup :: CInt -> IO CInt + +foreign import ccall unsafe "HsBase.h dup2" + c_dup2 :: CInt -> CInt -> IO CInt +#endif + +foreign import ccall unsafe "HsBase.h isatty" + c_isatty :: CInt -> IO CInt + foreign import ccall unsafe "HsBase.h unlink" c_unlink :: CString -> IO CInt @@ -715,6 +741,7 @@ c_getpid = pure 1 foreign import ccall unsafe "HsBase.h getpid" c_getpid :: IO CPid #endif +#endif #if !defined(js_HOST_ARCH) foreign import ccall unsafe "HsBase.h __hscore_stat" ===================================== libraries/base/base.cabal ===================================== @@ -396,7 +396,6 @@ Library if os(windows) -- Windows requires some extra libraries for linking because the RTS -- is no longer re-exporting them. - -- mingwex: provides C99 compatibility. libm is a stub on MingW. -- mingw32: Unfortunately required because of a resource leak between -- mingwex and mingw32. the __math_err symbol is defined in -- mingw32 which is required by mingwex. @@ -409,7 +408,7 @@ Library -- advapi32: provides advanced kernel functions extra-libraries: wsock32, user32, shell32, mingw32, kernel32, advapi32, - mingwex, ws2_32, shlwapi, ole32, rpcrt4, ntdll + ws2_32, shlwapi, ole32, rpcrt4, ntdll -- Minimum supported Windows version. -- These numbers can be found at: -- https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx ===================================== libraries/base/configure.ac ===================================== @@ -39,7 +39,7 @@ AC_CHECK_LIB([rt], [clock_gettime]) AC_CHECK_FUNCS([clock_gettime]) AC_CHECK_DECLS([CLOCK_PROCESS_CPUTIME_ID], [], [], [[#include ]]) AC_CHECK_FUNCS([getclock getrusage times]) -AC_CHECK_FUNCS([_chsize ftruncate]) +AC_CHECK_FUNCS([_chsize_s ftruncate]) # event-related fun # The line below already defines HAVE_KQUEUE and HAVE_POLL, so technically some of the ===================================== libraries/base/include/HsBase.h ===================================== @@ -280,15 +280,12 @@ __hscore_o_nonblock( void ) INLINE int __hscore_ftruncate( int fd, off_t where ) { -#if defined(HAVE_FTRUNCATE) +#if defined(HAVE__CHSIZE_S) + return _chsize_s(fd,where); +#elif defined(HAVE_FTRUNCATE) return ftruncate(fd,where); -#elif defined(HAVE__CHSIZE) - return _chsize(fd,where); #else -// ToDo: we should use _chsize_s() on Windows which allows a 64-bit -// offset, but it doesn't seem to be available from mingw at this time -// --SDM (01/2008) -#error at least ftruncate or _chsize functions are required to build +#error at least _chsize_s or ftruncate functions are required to build #endif } ===================================== libraries/deepseq ===================================== @@ -1 +1 @@ -Subproject commit 28f4d5b00448239581ead0de9140ff4a6847c806 +Subproject commit 38ab699cd5e08a85fdc9ac27f1612ce130e98a5a ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit 872e19fce06ddd40bd0771dbd3cad2c3c6ed5e7d +Subproject commit 4d7092ad3a8357b18a8fcbeb6fcf38045460eb98 ===================================== libraries/ghc-bignum/gmp/gmp-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 6bbea995472b6f4db172c3cd50aa3f515ddd221c +Subproject commit 31f9909680ba8fe00d27fd8a6f5d198a0a96c1ac ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -66,15 +66,14 @@ Library if os(windows) -- Windows requires some extra libraries for linking because the RTS -- is no longer re-exporting them (see #11223) - -- msvcrt: standard C library. The RTS will automatically include this, - -- but is added for completeness. - -- mingwex: provides C99 compatibility. libm is a stub on MingW. + -- ucrt: standard C library. The RTS will automatically include this, + -- but is added for completeness. -- mingw32: Unfortunately required because of a resource leak between -- mingwex and mingw32. the __math_err symbol is defined in -- mingw32 which is required by mingwex. -- user32: provides access to apis to modify user components (UI etc) -- on Windows. Required because of mingw32. - extra-libraries: user32, mingw32, mingwex, ucrt + extra-libraries: user32, mingw32, ucrt if os(linux) -- we need libm, but for musl and other's we might need libc, as libm ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit d4f343509e905a717ea463ad84462c126d8990d8 +Subproject commit aae0bfeec7ae767e3c30844ca2f99b6825185467 ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit cb89d5079d29c38683bcb6feec7dc53ad3836ed0 +Subproject commit 2ac3ff366631a36d84101000045abbefa4415b15 ===================================== libraries/text ===================================== @@ -1 +1 @@ -Subproject commit 5558730e76923f2d5d7fbc8783ab1ecc25bfe15d +Subproject commit fdb06ff327519f3c0fc6cc9997b7cb7fe8ab8178 ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 3be0223cee7395410915a127eba3acae5ff0b2f2 +Subproject commit 2a6079a2b76adf29d3e3ff213dffe66cabcb76c3 ===================================== rts/Linker.c ===================================== @@ -135,7 +135,8 @@ extern void iconv(); This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will never use. This is especially painful on Windows, where the number of - libraries required to link things like mingwex grows to be quite high. + libraries required to link things like mingwex (TODO: We no longer depend + on mingwex, so think of a different example here) grows to be quite high. We proceed through these stages as follows, @@ -193,7 +194,8 @@ extern void iconv(); 1) Dependency chains, if A.o required a .o in libB but A.o isn't required to link then we don't need to load libB. This means the dependency chain for libraries - such as mingw32 and mingwex can be broken down. + such as mingw32 and mingwex (TODO: We no longer depend on mingwex, so think of + a different example here) can be broken down. 2) The number of duplicate symbols, since now only symbols that are true duplicates will display the error. @@ -226,7 +228,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key, static const char * symbolTypeString (SymType type) { - switch (type) { + switch (type & ~SYM_TYPE_DUP_DISCARD) { case SYM_TYPE_CODE: return "code"; case SYM_TYPE_DATA: return "data"; case SYM_TYPE_INDIRECT_DATA: return "indirect-data"; @@ -275,14 +277,19 @@ int ghciInsertSymbolTable( insertStrHashTable(table, key, pinfo); return 1; } - else if (pinfo->type != type) + else if (pinfo->type ^ type) { - debugBelch("Symbol type mismatch.\n"); - debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", - key, obj_name, symbolTypeString(type)); - debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", - pinfo->owner ? pinfo->owner->fileName : WSTR(""), - symbolTypeString(pinfo->type)); + /* We were asked to discard the symbol on duplicates, do so quietly. */ + if (!(type & SYM_TYPE_DUP_DISCARD)) + { + DebugBreak (); + debugBelch("Symbol type mismatch.\n"); + debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", + key, obj_name, symbolTypeString(type)); + debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", + pinfo->owner ? pinfo->owner->fileName : WSTR(""), + symbolTypeString(pinfo->type)); + } return 1; } else if (pinfo->strength == STRENGTH_STRONG) ===================================== rts/LinkerInternals.h ===================================== @@ -56,9 +56,12 @@ typedef struct _Section Section; /* What kind of thing a symbol identifies. We need to know this to determine how * to process overflowing relocations. See Note [Processing overflowed relocations]. */ typedef enum _SymType { - SYM_TYPE_CODE, /* the symbol is a function and can be relocated via a jump island */ - SYM_TYPE_DATA, /* the symbol is data */ - SYM_TYPE_INDIRECT_DATA, /* see Note [_iob_func symbol] */ + SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */ + SYM_TYPE_DATA = 1 << 1, /* the symbol is data */ + SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */ + SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library + however if a duplicate is found with a mismatching + SymType then discard this one. */ } SymType; ===================================== rts/RtsSymbols.c ===================================== @@ -113,26 +113,6 @@ extern char **environ; * by the RtsSymbols entry. To avoid this we introduce a horrible special case * in `ghciInsertSymbolTable`, ensure that `atexit` is never overridden. */ -/* - * Note [Symbols for MinGW's printf] - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * The printf offered by Microsoft's libc implementation, msvcrt, is quite - * incomplete, lacking support for even %ull. Consequently mingw-w64 offers its - * own implementation which we enable. However, to be thread-safe the - * implementation uses _lock_file. This would be fine except msvcrt.dll doesn't - * export _lock_file, only numbered versions do (e.g. msvcrt90.dll). - * - * To work around this mingw-w64 packages a static archive of msvcrt which - * includes their own implementation of _lock_file. However, this means that - * the archive contains things which the dynamic library does not; consequently - * we need to ensure that the runtime linker provides this symbol. - * - * It's all just so terrible. - * - * See also: - * https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ - * https://sourceforge.net/p/mingw-w64/discussion/723797/thread/55520785/ - */ /* Note [_iob_func symbol] * ~~~~~~~~~~~~~~~~~~~~~~~ * Microsoft in VS2013 to VS2015 transition made a backwards incompatible change @@ -170,12 +150,6 @@ extern char **environ; SymI_NeedsProto(__mingw_module_is_dll) \ RTS_WIN32_ONLY(SymI_NeedsProto(___chkstk_ms)) \ RTS_WIN64_ONLY(SymI_NeedsProto(___chkstk_ms)) \ - RTS_WIN64_ONLY(SymI_HasProto(__stdio_common_vswprintf_s)) \ - RTS_WIN64_ONLY(SymI_HasProto(__stdio_common_vswprintf)) \ - RTS_WIN64_ONLY(SymI_HasProto(_errno)) \ - /* see Note [Symbols for MinGW's printf] */ \ - SymI_HasProto(_lock_file) \ - SymI_HasProto(_unlock_file) \ SymI_HasProto(__mingw_vsnwprintf) \ /* ^^ Need to figure out why this is needed. */ \ /* See Note [_iob_func symbol] */ \ @@ -187,120 +161,8 @@ extern char **environ; /* ^^ 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 \ - SymI_HasProto_deprecated(access) \ - SymI_HasProto_deprecated(cabs) \ - SymI_HasProto_deprecated(cgets) \ - SymI_HasProto_deprecated(chdir) \ - SymI_HasProto_deprecated(chmod) \ - SymI_HasProto_deprecated(chsize) \ - SymI_HasProto_deprecated(close) \ - SymI_HasProto_deprecated(cprintf) \ - SymI_HasProto_deprecated(cputs) \ - SymI_HasProto_deprecated(creat) \ - SymI_HasProto_deprecated(cscanf) \ - SymI_HasProto_deprecated(cwait) \ - SymI_HasProto_deprecated(dup) \ - SymI_HasProto_deprecated(dup2) \ - SymI_HasProto_deprecated(ecvt) \ - SymI_HasProto_deprecated(eof) \ - SymI_HasProto_deprecated(execl) \ - SymI_HasProto_deprecated(execle) \ - SymI_HasProto_deprecated(execlp) \ - SymI_HasProto_deprecated(execlpe) \ - SymI_HasProto_deprecated(execv) \ - SymI_HasProto_deprecated(execve) \ - SymI_HasProto_deprecated(execvp) \ - SymI_HasProto_deprecated(execvpe) \ - SymI_HasProto_deprecated(fcloseall) \ - SymI_HasProto_deprecated(fcvt) \ - SymI_HasProto_deprecated(fdopen) \ - SymI_HasProto_deprecated(fgetchar) \ - SymI_HasProto_deprecated(filelength) \ - SymI_HasProto_deprecated(fileno) \ - SymI_HasProto_deprecated(flushall) \ - SymI_HasProto_deprecated(fputchar) \ - SymI_HasProto_deprecated(gcvt) \ - SymI_HasProto_deprecated(getch) \ - SymI_HasProto_deprecated(getche) \ - SymI_HasProto_deprecated(getcwd) \ - SymI_HasProto_deprecated(getpid) \ - SymI_HasProto_deprecated(getw) \ - SymI_HasProto_deprecated(hypot) \ - SymI_HasProto_deprecated(inp) \ - SymI_HasProto_deprecated(inpw) \ - SymI_HasProto_deprecated(isascii) \ - SymI_HasProto_deprecated(isatty) \ - SymI_HasProto_deprecated(iscsym) \ - SymI_HasProto_deprecated(iscsymf) \ - SymI_HasProto_deprecated(itoa) \ - SymI_HasProto_deprecated(j0) \ - SymI_HasProto_deprecated(j1) \ - SymI_HasProto_deprecated(jn) \ - SymI_HasProto_deprecated(kbhit) \ - SymI_HasProto_deprecated(lfind) \ - SymI_HasProto_deprecated(locking) \ - SymI_HasProto_deprecated(lsearch) \ - SymI_HasProto_deprecated(lseek) \ - SymI_HasProto_deprecated(ltoa) \ - SymI_HasProto_deprecated(memccpy) \ - SymI_HasProto_deprecated(memicmp) \ - SymI_HasProto_deprecated(mkdir) \ - SymI_HasProto_deprecated(mktemp) \ - SymI_HasProto_deprecated(open) \ - SymI_HasProto_deprecated(outp) \ - SymI_HasProto_deprecated(outpw) \ - SymI_HasProto_deprecated(putch) \ - SymI_HasProto_deprecated(putenv) \ - SymI_HasProto_deprecated(putw) \ - SymI_HasProto_deprecated(read) \ - SymI_HasProto_deprecated(rmdir) \ - SymI_HasProto_deprecated(rmtmp) \ - SymI_HasProto_deprecated(setmode) \ - SymI_HasProto_deprecated(sopen) \ - SymI_HasProto_deprecated(spawnl) \ - SymI_HasProto_deprecated(spawnle) \ - SymI_HasProto_deprecated(spawnlp) \ - SymI_HasProto_deprecated(spawnlpe) \ - SymI_HasProto_deprecated(spawnv) \ - SymI_HasProto_deprecated(spawnve) \ - SymI_HasProto_deprecated(spawnvp) \ - SymI_HasProto_deprecated(spawnvpe) \ - SymI_HasProto_deprecated(strcmpi) \ - SymI_HasProto_deprecated(strdup) \ - SymI_HasProto_deprecated(stricmp) \ - SymI_HasProto_deprecated(strlwr) \ - SymI_HasProto_deprecated(strnicmp) \ - SymI_HasProto_deprecated(strnset) \ - SymI_HasProto_deprecated(strrev) \ - SymI_HasProto_deprecated(strset) \ - SymI_HasProto_deprecated(strupr) \ - SymI_HasProto_deprecated(swab) \ - SymI_HasProto_deprecated(tell) \ - SymI_HasProto_deprecated(tempnam) \ - SymI_HasProto_deprecated(toascii) \ - SymI_HasProto_deprecated(tzset) \ - SymI_HasProto_deprecated(ultoa) \ - SymI_HasProto_deprecated(umask) \ - SymI_HasProto_deprecated(ungetch) \ - SymI_HasProto_deprecated(unlink) \ - SymI_HasProto_deprecated(wcsdup) \ - SymI_HasProto_deprecated(wcsicmp) \ - SymI_HasProto_deprecated(wcsicoll) \ - SymI_HasProto_deprecated(wcslwr) \ - SymI_HasProto_deprecated(wcsnicmp) \ - SymI_HasProto_deprecated(wcsnset) \ - SymI_HasProto_deprecated(wcsrev) \ - SymI_HasProto_deprecated(wcsset) \ - SymI_HasProto_deprecated(wcsupr) \ - SymI_HasProto_deprecated(write) \ - SymI_HasProto_deprecated(y0) \ - SymI_HasProto_deprecated(y1) \ - SymI_HasProto_deprecated(yn) #else #define RTS_MINGW_ONLY_SYMBOLS /**/ -#define RTS_MINGW_COMPAT_SYMBOLS /**/ #endif @@ -1181,7 +1043,6 @@ RtsSymbolVal rtsSyms[] = { RTS_RET_SYMBOLS RTS_POSIX_ONLY_SYMBOLS RTS_MINGW_ONLY_SYMBOLS - RTS_MINGW_COMPAT_SYMBOLS RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBGCC_SYMBOLS ===================================== rts/linker/PEi386.c ===================================== @@ -261,6 +261,54 @@ .asciiz "libfoo_data" + Note [GHC Linking model and import libraries] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The above describes how import libraries work for static linking. + Fundamentally this does not apply to Dynamic linknig as we do in GHC. + The issue is two folds: + + 1. In the linking model above it is expected that the .idata sections be + materialized into PLTs during linking. However in GHC we never create + PLTs, but have out own mechanism for this which is the jump island + machinery. This is required for efficiency. For one materializing the + idata sections would result in wasting pages. We'd use one page for + every ~100 bytes. This is extremely wasteful and also fragments the + memory. Secondly the dynamic linker is lazy. We only perform the final + loading if the symbol is used, however with an import library we can + discard the actual OC immediately after reading it. This prevents us from + keeping ~1k in memory per symbol for no reason. + + 2. GHC itself does not observ symbol visibility correctly during NGC. This + in itself isn't an academic exercise. The issue stems from GHC using one + mechanism for providing two incompatible linking modes: + a) The first mode is generating Haskell shared libraries which are + intended to be used by other Haskell code. This requires us to + export the info, data and closures. For this GHC just re-exports + all symbols. But it doesn't correcly mark data/code. Symbol + visibility is overwritten by telling the linker to export all + symbols. + b) The second code is producing code that's supposed to be call-able + through a C insterface. This in reality does not require the + export of closures and info tables. But also does not require the + inclusion of the RTS inside the DLL. Hover this is done today + because we don't properly have the RTS as a dynamic library. + i.e. GHC does not only export symbols denoted by foreign export. + Also GHC should depend on an RTS library, but at the moment it + cannot because of TNTC is incompatible with dynamic linking. + + These two issues mean that for GHC we need to take a different approach + to handling import libraries. For normal C libraries we have proper + differentiation between CODE and DATA. For GHC produced import libraries + we do not. As such the SYM_TYPE_DUP_DISCARD tells the linker that if a + duplictae symbol is found, and we were going to discard it anyway, just do + so quitely. This works because the RTS symbols themselves are provided by + the currently loaded RTS as built-in symbols. + + Secondly we cannot rely on a text symbol being available. As such we + should only depend on the symbols as definited in the .idata sections, + otherwise we would not be able to correctly link against GHC produced + import libraries. + Note [Memory allocation] ~~~~~~~~~~~~~~~~~~~~~~~~ The loading of an object begins in `preloadObjectFile`, which allocates a buffer, @@ -1658,7 +1706,10 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if ( secNumber != IMAGE_SYM_UNDEFINED && secNumber > 0 && section - && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY) { + /* Skip all BFD import sections. */ + && section->kind != SECTIONKIND_IMPORT + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY_HEAD) { /* This symbol is global and defined, viz, exported */ /* for IMAGE_SYMCLASS_EXTERNAL && !IMAGE_SYM_UNDEFINED, @@ -1691,12 +1742,49 @@ ocGetNames_PEi386 ( ObjectCode* oc ) IF_DEBUG(linker_verbose, debugBelch("bss symbol @ %p %u\n", addr, symValue)); } else if (section && section->kind == SECTIONKIND_BFD_IMPORT_LIBRARY) { - setImportSymbol(oc, sname); + /* Disassembly of section .idata$5: + + 0000000000000000 <__imp_Insert>: + ... + 0: IMAGE_REL_AMD64_ADDR32NB .idata$6 + + The first two bytes contain the ordinal of the function + in the format of lowpart highpart. The two bytes combined + for the total range of 16 bits which is the function export limit + of DLLs. See note [GHC Linking model and import libraries]. */ + sname = (SymbolName*)section->start+2; + COFF_symbol* sym = &oc->info->symbols[info->numberOfSymbols-1]; + addr = get_sym_name( getSymShortName (info, sym), oc); + + IF_DEBUG(linker, + debugBelch("addImportSymbol `%s' => `%s'\n", + sname, (char*)addr)); + /* We're going to free the any data associated with the import + library without copying the sections. So we have to duplicate + the symbol name and values before the pointers become invalid. */ + sname = strdup (sname); + addr = strdup (addr); + type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA; + type |= SYM_TYPE_DUP_DISCARD; + if (!ghciInsertSymbolTable(oc->fileName, symhash, sname, + addr, false, type, oc)) { + releaseOcInfo (oc); + stgFree (oc->image); + oc->image = NULL; + return false; + } + setImportSymbol (oc, sname); + + /* Don't process this oc any further. Just exit. */ + oc->n_symbols = 0; + oc->symbols = NULL; + stgFree (oc->image); + oc->image = NULL; + releaseOcInfo (oc); // There is nothing that we need to resolve in this object since we // will never call the import stubs in its text section oc->status = OBJECT_DONT_RESOLVE; - - IF_DEBUG(linker_verbose, debugBelch("import symbol %s\n", sname)); + return true; } else if (secNumber > 0 && section ===================================== rts/package.conf.in ===================================== @@ -54,11 +54,6 @@ extra-libraries: #if defined(DEBUG) && defined(HAVE_LIBBFD) ,"bfd", "iberty" /* for debugging */ #endif -#if defined(HAVE_LIBMINGWEX) -# if !defined(INSTALLING) /* Bundled Mingw is behind */ - ,"mingwex" -# endif -#endif #if USE_LIBDW , "elf" , "dw" /* for backtraces */ ===================================== rts/rts.cabal.in ===================================== @@ -24,8 +24,6 @@ flag need-pthread default: @CabalNeedLibpthread@ flag libbfd default: @CabalHaveLibbfd@ -flag mingwex - default: @CabalMingwex@ flag need-atomic default: @CabalNeedLibatomic@ flag libdw @@ -68,7 +66,6 @@ library exposed: True exposed-modules: - if os(ghcjs) include-dirs: include @@ -194,8 +191,6 @@ library if flag(libbfd) -- for debugging extra-libraries: bfd iberty - if flag(mingwex) - extra-libraries: mingwex if flag(libdw) -- for backtraces extra-libraries: elf dw ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -88,10 +88,6 @@ compile_libAB_dyn: .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: - rm -rf bin_impl_gcc - mkdir bin_impl_gcc - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_impl_gcc" -shared A.c -o "bin_impl_gcc/$(call DLL,ASimpL)" - mv bin_impl_gcc/libASimpL.dll.a bin_impl_gcc/libASx.dll.a echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T11072.hs -lASx -L./bin_impl_gcc .PHONY: compile_libAS_impl_msvc ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -41,9 +41,9 @@ test('T10458', extra_hc_opts('-L"$PWD/T10458dir" -lAS')], ghci_script, ['T10458.script']) -test('T11072gcc', [extra_files(['A.c', 'T11072.hs']), - expect_broken(18718), - unless(doing_ghci, skip), unless(opsys('mingw32'), skip)], +test('T11072gcc', [extra_files(['A.c', 'T11072.hs', 'bin_impl_gcc/']), + unless(doing_ghci, skip), unless(opsys('mingw32'), skip), + unless(arch('x86_64'), skip)], makefile_test, ['compile_libAS_impl_gcc']) test('T11072msvc', [extra_files(['A.c', 'T11072.hs', 'libAS.def', 'i686/', 'x86_64/']), ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit edc72530978d8a9ec92f51d288484986ec0051e3 +Subproject commit a9a312991e55ab99a8dee36a6747f4fc5d5b7c67 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3a21290e230520b342a301c1e8a9aad6c312c45a...3e8ae3f83f6047ef5de9bee1d288810672f9c80f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3a21290e230520b342a301c1e8a9aad6c312c45a...3e8ae3f83f6047ef5de9bee1d288810672f9c80f You're receiving 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 Dec 4 16:57:34 2022 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Sun, 04 Dec 2022 11:57:34 -0500 Subject: [Git][ghc/ghc][wip/T22166] linker: Fix BFD import libraries Message-ID: <638cd17e583e_17512e240afea0100401@gitlab.mail> Tamar Christina pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: 50953eea by Tamar Christina at 2022-12-04T16:57:00+00:00 linker: Fix BFD import libraries - - - - - 6 changed files: - hadrian/src/Settings/Packages.hs - rts/Linker.c - rts/LinkerInternals.h - rts/linker/PEi386.c - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/ghci/linking/dyn/all.T Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -403,7 +403,7 @@ rtsPackageArgs = package rts ? do , builder HsCpp ? pure [ "-DTOP=" ++ show top ] - , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" + , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" ] -- Compile various performance-critical pieces *without* -fPIC -dynamic -- even when building a shared library. If we don't do this, then the ===================================== rts/Linker.c ===================================== @@ -228,7 +228,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key, static const char * symbolTypeString (SymType type) { - switch (type) { + switch (type & ~SYM_TYPE_DUP_DISCARD) { case SYM_TYPE_CODE: return "code"; case SYM_TYPE_DATA: return "data"; case SYM_TYPE_INDIRECT_DATA: return "indirect-data"; @@ -277,14 +277,19 @@ int ghciInsertSymbolTable( insertStrHashTable(table, key, pinfo); return 1; } - else if (pinfo->type != type) + else if (pinfo->type ^ type) { - debugBelch("Symbol type mismatch.\n"); - debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", - key, obj_name, symbolTypeString(type)); - debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", - pinfo->owner ? pinfo->owner->fileName : WSTR(""), - symbolTypeString(pinfo->type)); + /* We were asked to discard the symbol on duplicates, do so quietly. */ + if (!(type & SYM_TYPE_DUP_DISCARD)) + { + DebugBreak (); + debugBelch("Symbol type mismatch.\n"); + debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", + key, obj_name, symbolTypeString(type)); + debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", + pinfo->owner ? pinfo->owner->fileName : WSTR(""), + symbolTypeString(pinfo->type)); + } return 1; } else if (pinfo->strength == STRENGTH_STRONG) ===================================== rts/LinkerInternals.h ===================================== @@ -56,9 +56,12 @@ typedef struct _Section Section; /* What kind of thing a symbol identifies. We need to know this to determine how * to process overflowing relocations. See Note [Processing overflowed relocations]. */ typedef enum _SymType { - SYM_TYPE_CODE, /* the symbol is a function and can be relocated via a jump island */ - SYM_TYPE_DATA, /* the symbol is data */ - SYM_TYPE_INDIRECT_DATA, /* see Note [_iob_func symbol] */ + SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */ + SYM_TYPE_DATA = 1 << 1, /* the symbol is data */ + SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */ + SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library + however if a duplicate is found with a mismatching + SymType then discard this one. */ } SymType; ===================================== rts/linker/PEi386.c ===================================== @@ -261,6 +261,54 @@ .asciiz "libfoo_data" + Note [GHC Linking model and import libraries] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The above describes how import libraries work for static linking. + Fundamentally this does not apply to Dynamic linknig as we do in GHC. + The issue is two folds: + + 1. In the linking model above it is expected that the .idata sections be + materialized into PLTs during linking. However in GHC we never create + PLTs, but have out own mechanism for this which is the jump island + machinery. This is required for efficiency. For one materializing the + idata sections would result in wasting pages. We'd use one page for + every ~100 bytes. This is extremely wasteful and also fragments the + memory. Secondly the dynamic linker is lazy. We only perform the final + loading if the symbol is used, however with an import library we can + discard the actual OC immediately after reading it. This prevents us from + keeping ~1k in memory per symbol for no reason. + + 2. GHC itself does not observ symbol visibility correctly during NGC. This + in itself isn't an academic exercise. The issue stems from GHC using one + mechanism for providing two incompatible linking modes: + a) The first mode is generating Haskell shared libraries which are + intended to be used by other Haskell code. This requires us to + export the info, data and closures. For this GHC just re-exports + all symbols. But it doesn't correcly mark data/code. Symbol + visibility is overwritten by telling the linker to export all + symbols. + b) The second code is producing code that's supposed to be call-able + through a C insterface. This in reality does not require the + export of closures and info tables. But also does not require the + inclusion of the RTS inside the DLL. Hover this is done today + because we don't properly have the RTS as a dynamic library. + i.e. GHC does not only export symbols denoted by foreign export. + Also GHC should depend on an RTS library, but at the moment it + cannot because of TNTC is incompatible with dynamic linking. + + These two issues mean that for GHC we need to take a different approach + to handling import libraries. For normal C libraries we have proper + differentiation between CODE and DATA. For GHC produced import libraries + we do not. As such the SYM_TYPE_DUP_DISCARD tells the linker that if a + duplictae symbol is found, and we were going to discard it anyway, just do + so quitely. This works because the RTS symbols themselves are provided by + the currently loaded RTS as built-in symbols. + + Secondly we cannot rely on a text symbol being available. As such we + should only depend on the symbols as definited in the .idata sections, + otherwise we would not be able to correctly link against GHC produced + import libraries. + Note [Memory allocation] ~~~~~~~~~~~~~~~~~~~~~~~~ The loading of an object begins in `preloadObjectFile`, which allocates a buffer, @@ -1658,7 +1706,10 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if ( secNumber != IMAGE_SYM_UNDEFINED && secNumber > 0 && section - && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY) { + /* Skip all BFD import sections. */ + && section->kind != SECTIONKIND_IMPORT + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY_HEAD) { /* This symbol is global and defined, viz, exported */ /* for IMAGE_SYMCLASS_EXTERNAL && !IMAGE_SYM_UNDEFINED, @@ -1691,12 +1742,49 @@ ocGetNames_PEi386 ( ObjectCode* oc ) IF_DEBUG(linker_verbose, debugBelch("bss symbol @ %p %u\n", addr, symValue)); } else if (section && section->kind == SECTIONKIND_BFD_IMPORT_LIBRARY) { - setImportSymbol(oc, sname); + /* Disassembly of section .idata$5: + + 0000000000000000 <__imp_Insert>: + ... + 0: IMAGE_REL_AMD64_ADDR32NB .idata$6 + + The first two bytes contain the ordinal of the function + in the format of lowpart highpart. The two bytes combined + for the total range of 16 bits which is the function export limit + of DLLs. See note [GHC Linking model and import libraries]. */ + sname = (SymbolName*)section->start+2; + COFF_symbol* sym = &oc->info->symbols[info->numberOfSymbols-1]; + addr = get_sym_name( getSymShortName (info, sym), oc); + + IF_DEBUG(linker, + debugBelch("addImportSymbol `%s' => `%s'\n", + sname, (char*)addr)); + /* We're going to free the any data associated with the import + library without copying the sections. So we have to duplicate + the symbol name and values before the pointers become invalid. */ + sname = strdup (sname); + addr = strdup (addr); + type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA; + type |= SYM_TYPE_DUP_DISCARD; + if (!ghciInsertSymbolTable(oc->fileName, symhash, sname, + addr, false, type, oc)) { + releaseOcInfo (oc); + stgFree (oc->image); + oc->image = NULL; + return false; + } + setImportSymbol (oc, sname); + + /* Don't process this oc any further. Just exit. */ + oc->n_symbols = 0; + oc->symbols = NULL; + stgFree (oc->image); + oc->image = NULL; + releaseOcInfo (oc); // There is nothing that we need to resolve in this object since we // will never call the import stubs in its text section oc->status = OBJECT_DONT_RESOLVE; - - IF_DEBUG(linker_verbose, debugBelch("import symbol %s\n", sname)); + return true; } else if (secNumber > 0 && section ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -88,10 +88,6 @@ compile_libAB_dyn: .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: - rm -rf bin_impl_gcc - mkdir bin_impl_gcc - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_impl_gcc" -shared A.c -o "bin_impl_gcc/$(call DLL,ASimpL)" - mv bin_impl_gcc/libASimpL.dll.a bin_impl_gcc/libASx.dll.a echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T11072.hs -lASx -L./bin_impl_gcc .PHONY: compile_libAS_impl_msvc ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -41,9 +41,9 @@ test('T10458', extra_hc_opts('-L"$PWD/T10458dir" -lAS')], ghci_script, ['T10458.script']) -test('T11072gcc', [extra_files(['A.c', 'T11072.hs']), - expect_broken(18718), - unless(doing_ghci, skip), unless(opsys('mingw32'), skip)], +test('T11072gcc', [extra_files(['A.c', 'T11072.hs', 'bin_impl_gcc/']), + unless(doing_ghci, skip), unless(opsys('mingw32'), skip), + unless(arch('x86_64'), skip)], makefile_test, ['compile_libAS_impl_gcc']) test('T11072msvc', [extra_files(['A.c', 'T11072.hs', 'libAS.def', 'i686/', 'x86_64/']), View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/50953eeadea0ef1208241fb4620a934e2ca24ef5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/50953eeadea0ef1208241fb4620a934e2ca24ef5 You're receiving 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 Dec 4 17:01:59 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sun, 04 Dec 2022 12:01:59 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/tok-where Message-ID: <638cd287a0868_17512e240afea010083be@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/tok-where at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/tok-where You're receiving 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 Dec 4 17:04:22 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sun, 04 Dec 2022 12:04:22 -0500 Subject: [Git][ghc/ghc][wip/int-index/tok-where] WIP: Use LHsToken for class, where Message-ID: <638cd316e88d5_17512e2b979994101041f@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/tok-where at Glasgow Haskell Compiler / GHC Commits: 7515ec98 by Vladislav Zavialov at 2022-12-04T20:04:07+03:00 WIP: Use LHsToken for class, where Updates the haddock submodule. - - - - - 15 changed files: - compiler/GHC/Data/Strict.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/ThToHs.hs - compiler/Language/Haskell/Syntax/Decls.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/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/DumpSemis.stderr - testsuite/tests/parser/should_compile/T20452.stderr - utils/check-exact/ExactPrint.hs - utils/haddock Changes: ===================================== compiler/GHC/Data/Strict.hs ===================================== @@ -9,6 +9,7 @@ module GHC.Data.Strict ( Maybe(Nothing, Just), fromMaybe, + isNothing, Pair(And), -- Not used at the moment: @@ -29,6 +30,10 @@ fromMaybe :: a -> Maybe a -> a fromMaybe d Nothing = d fromMaybe _ (Just x) = x +isNothing :: Maybe a -> Bool +isNothing Nothing = True +isNothing (Just _) = False + apMaybe :: Maybe (a -> b) -> Maybe a -> Maybe b apMaybe (Just f) (Just x) = Just (f x) apMaybe _ _ = Nothing ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -131,6 +131,7 @@ import GHC.Data.Bag import GHC.Data.Maybe import Data.Data (Data) import Data.Foldable (toList) +import qualified GHC.Data.Strict as Strict {- ************************************************************************ @@ -446,9 +447,11 @@ instance (OutputableBndrId p) => Outputable (TyClDecl (GhcPass p)) where ppr (ClassDecl {tcdCtxt = context, tcdLName = lclas, tcdTyVars = tyvars, tcdFixity = fixity, tcdFDs = fds, + tcdTkWhere = tkWhere, tcdSigs = sigs, tcdMeths = methods, tcdATs = ats, tcdATDefs = at_defs}) | null sigs && isEmptyBag methods && null ats && null at_defs -- No "where" part + && Strict.isNothing tkWhere = top_matter | otherwise -- Laid out ===================================== compiler/GHC/Parser.y ===================================== @@ -1244,8 +1244,8 @@ topdecl :: { LHsDecl GhcPs } -- cl_decl :: { LTyClDecl GhcPs } : 'class' tycl_hdr fds where_cls - {% (mkClassDecl (comb4 $1 $2 $3 $4) $2 $3 (sndOf3 $ unLoc $4) (thdOf3 $ unLoc $4)) - (mj AnnClass $1:(fst $ unLoc $3)++(fstOf3 $ unLoc $4)) } + {% (mkClassDecl (comb4 $1 $2 $3 $4) (hsTok $1) $2 $3 (snd $ unLoc $4)) + (mj AnnClass $1:(fst $ unLoc $3)++(fst $ unLoc $4)) } -- Type declarations (toplevel) -- @@ -1721,14 +1721,14 @@ decllist_cls -- Class body -- -where_cls :: { Located ([AddEpAnn] - ,(OrdList (LHsDecl GhcPs)) -- Reversed - ,LayoutInfo GhcPs) } +where_cls :: { Located ([AddEpAnn], PsClassWhereClause) } -- No implicit parameters -- May have type declarations : 'where' decllist_cls { sLL $1 $> (mj AnnWhere $1:(fstOf3 $ unLoc $2) - ,sndOf3 $ unLoc $2,thdOf3 $ unLoc $2) } - | {- empty -} { noLoc ([],nilOL,NoLayoutInfo) } + ,PsClassWhereClause (thdOf3 $ unLoc $2) + (Strict.Just (hsTok $1)) + (sndOf3 $ unLoc $2)) } + | {- empty -} { noLoc ([],PsClassWhereClause NoLayoutInfo Strict.Nothing nilOL) } -- Declarations in instance bodies -- ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -22,7 +22,7 @@ module GHC.Parser.PostProcess ( mkHsIntegral, mkHsFractional, mkHsIsString, mkHsDo, mkSpliceDecl, mkRoleAnnotDecl, - mkClassDecl, + PsClassWhereClause(..), mkClassDecl, mkTyData, mkDataFamInst, mkTySynonym, mkTyFamInstEqn, mkStandaloneKindSig, @@ -188,27 +188,41 @@ mkTyClD (L loc d) = L loc (TyClD noExtField d) mkInstD :: LInstDecl (GhcPass p) -> LHsDecl (GhcPass p) mkInstD (L loc d) = L loc (InstD noExtField d) +data PsClassWhereClause = + PsClassWhereClause { + pcwcLayoutInfo :: !(LayoutInfo GhcPs), + pcwcTkWhere :: !(Strict.Maybe (LHsToken "where" GhcPs)), + pcwcDecls :: !(OrdList (LHsDecl GhcPs)) -- Reversed + } + mkClassDecl :: SrcSpan + -> LHsToken "class" GhcPs -> Located (Maybe (LHsContext GhcPs), LHsType GhcPs) -> Located (a,[LHsFunDep GhcPs]) - -> OrdList (LHsDecl GhcPs) - -> LayoutInfo GhcPs + -> PsClassWhereClause -> [AddEpAnn] -> P (LTyClDecl GhcPs) -mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layoutInfo annsIn +mkClassDecl loc' tkClass (L _ (mcxt, tycl_hdr)) fds pcwc annsIn = do { let loc = noAnnSrcSpan loc' - ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs where_cls + ; let PsClassWhereClause + { pcwcLayoutInfo = layoutInfo + , pcwcTkWhere = tkWhere + , pcwcDecls = decls + } = pcwc + ; (binds, sigs, ats, at_defs, _, docs) <- cvBindsAndSigs decls ; (cls, tparams, fixity, ann) <- checkTyClHdr True tycl_hdr ; tyvars <- checkTyVars (text "class") whereDots cls tparams ; cs <- getCommentsFor (locA loc) -- Get any remaining comments ; let anns' = addAnns (EpAnn (spanAsAnchor $ locA loc) annsIn emptyComments) ann cs ; return (L loc (ClassDecl { tcdCExt = (anns', NoAnnSortKey) , tcdLayout = layoutInfo + , tcdTkClass = tkClass , tcdCtxt = mcxt , tcdLName = cls, tcdTyVars = tyvars , tcdFixity = fixity , tcdFDs = snd (unLoc fds) + , tcdTkWhere = tkWhere , tcdSigs = mkClassOpSigs sigs , tcdMeths = binds , tcdATs = ats, tcdATDefs = at_defs ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -498,8 +498,8 @@ instance HasHaddock (HsDecl GhcPs) where -- -- ^ Comment on the second method -- addHaddock (TyClD _ decl) - | ClassDecl { tcdCExt = (x, NoAnnSortKey), tcdLayout, - tcdCtxt, tcdLName, tcdTyVars, tcdFixity, tcdFDs, + | ClassDecl { tcdCExt = (x, NoAnnSortKey), tcdLayout, tcdTkClass, + tcdCtxt, tcdLName, tcdTyVars, tcdFixity, tcdFDs, tcdTkWhere, tcdSigs, tcdMeths, tcdATs, tcdATDefs } <- decl = do registerHdkA tcdLName @@ -509,8 +509,8 @@ instance HasHaddock (HsDecl GhcPs) where flattenBindsAndSigs (tcdMeths, tcdSigs, tcdATs, tcdATDefs, [], []) pure $ let (tcdMeths', tcdSigs', tcdATs', tcdATDefs', _, tcdDocs) = partitionBindsAndSigs where_cls' - decl' = ClassDecl { tcdCExt = (x, NoAnnSortKey), tcdLayout - , tcdCtxt, tcdLName, tcdTyVars, tcdFixity, tcdFDs + decl' = ClassDecl { tcdCExt = (x, NoAnnSortKey), tcdLayout, tcdTkClass + , tcdCtxt, tcdLName, tcdTyVars, tcdFixity, tcdFDs, tcdTkWhere , tcdSigs = tcdSigs' , tcdMeths = tcdMeths' , tcdATs = tcdATs' ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -1840,9 +1840,12 @@ rnTyClDecl (DataDecl , tcdDExt = rn_info }, fvs) } } rnTyClDecl (ClassDecl { tcdLayout = layout, + tcdTkClass = tkClass, tcdCtxt = context, tcdLName = lcls, tcdTyVars = tyvars, tcdFixity = fixity, - tcdFDs = fds, tcdSigs = sigs, + tcdFDs = fds, + tcdTkWhere = tkWhere, + tcdSigs = sigs, tcdMeths = mbinds, tcdATs = ats, tcdATDefs = at_defs, tcdDocs = docs}) = do { lcls' <- lookupLocatedTopConstructorRnN lcls @@ -1895,9 +1898,12 @@ rnTyClDecl (ClassDecl { tcdLayout = layout, ; let all_fvs = meth_fvs `plusFV` stuff_fvs `plusFV` fv_at_defs ; docs' <- traverse rnLDocDecl docs ; return (ClassDecl { tcdLayout = rnLayoutInfo layout, + tcdTkClass = tkClass, tcdCtxt = context', tcdLName = lcls', tcdTyVars = tyvars', tcdFixity = fixity, - tcdFDs = fds', tcdSigs = sigs', + tcdFDs = fds', + tcdTkWhere = tkWhere, + tcdSigs = sigs', tcdMeths = mbinds', tcdATs = ats', tcdATDefs = at_defs', tcdDocs = docs', tcdCExt = all_fvs }, all_fvs ) } ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -52,6 +52,7 @@ import GHC.Utils.Lexeme import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Panic +import qualified GHC.Data.Strict as Strict import Language.Haskell.Syntax.Basic (FieldLabelString(..)) @@ -321,9 +322,12 @@ cvtDec (ClassD ctxt cl tvs fds decs) (failWith $ DefaultDataInstDecl adts') ; returnJustLA $ TyClD noExtField $ ClassDecl { tcdCExt = (noAnn, NoAnnSortKey), tcdLayout = NoLayoutInfo + , tcdTkClass = noHsTok , tcdCtxt = mkHsContextMaybe cxt', tcdLName = tc', tcdTyVars = tvs' , tcdFixity = Prefix - , tcdFDs = fds', tcdSigs = Hs.mkClassOpSigs sigs' + , tcdFDs = fds' + , tcdTkWhere = Strict.Nothing + , tcdSigs = Hs.mkClassOpSigs sigs' , tcdMeths = binds' , tcdATs = fams', tcdATDefs = at_defs', tcdDocs = [] } -- no docs in TH ^^ ===================================== compiler/Language/Haskell/Syntax/Decls.hs ===================================== @@ -99,6 +99,7 @@ import Language.Haskell.Syntax.Extension import Language.Haskell.Syntax.Type import Language.Haskell.Syntax.Basic (Role) +import qualified GHC.Data.Strict as Strict import GHC.Types.Basic (TopLevelFlag, OverlapMode, RuleName, Activation) import GHC.Types.ForeignCall (CType, CCallConv, Safety, Header, CLabelString, CCallTarget, CExportSpec) import GHC.Types.Fixity (LexicalFixity) @@ -457,11 +458,13 @@ data TyClDecl pass | ClassDecl { tcdCExt :: XClassDecl pass, -- ^ Post renamer, FVs tcdLayout :: !(LayoutInfo pass), -- ^ Explicit or virtual braces -- See Note [Class LayoutInfo] + tcdTkClass :: !(LHsToken "class" pass), -- ^ The "class" token tcdCtxt :: Maybe (LHsContext pass), -- ^ Context... tcdLName :: LIdP pass, -- ^ Name of the class tcdTyVars :: LHsQTyVars pass, -- ^ Class type variables tcdFixity :: LexicalFixity, -- ^ Fixity used in the declaration tcdFDs :: [LHsFunDep pass], -- ^ Functional deps + tcdTkWhere :: !(Strict.Maybe (LHsToken "where" pass)), -- ^ The "where" token tcdSigs :: [LSig pass], -- ^ Methods' signatures tcdMeths :: LHsBinds pass, -- ^ Default methods tcdATs :: [LFamilyDecl pass], -- ^ Associated types; ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -61,6 +61,10 @@ (NoAnnSortKey)) (VirtualBraces (3)) + (L + (TokenLoc + (EpaSpan { T17544.hs:5:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:5:7-8 }) @@ -85,6 +89,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:5:12-16 })) + (HsTok))) [(L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:6:3-16 }) (ClassOpSig @@ -198,6 +207,10 @@ (NoAnnSortKey)) (VirtualBraces (3)) + (L + (TokenLoc + (EpaSpan { T17544.hs:9:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:9:7-8 }) @@ -222,6 +235,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:9:12-16 })) + (HsTok))) [(L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:10:3-16 }) (ClassOpSig @@ -333,6 +351,10 @@ (NoAnnSortKey)) (VirtualBraces (3)) + (L + (TokenLoc + (EpaSpan { T17544.hs:13:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:13:7-8 }) @@ -357,6 +379,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:13:12-16 })) + (HsTok))) [(L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:14:3-16 }) (ClassOpSig @@ -471,6 +498,10 @@ (NoAnnSortKey)) (VirtualBraces (3)) + (L + (TokenLoc + (EpaSpan { T17544.hs:17:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:17:7-8 }) @@ -495,6 +526,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:17:12-16 })) + (HsTok))) [(L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:18:3-16 }) (ClassOpSig @@ -669,6 +705,10 @@ (TokenLoc (EpaSpan { T17544.hs:22:30 })) (HsTok))) + (L + (TokenLoc + (EpaSpan { T17544.hs:22:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:22:7-8 }) @@ -693,6 +733,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:22:12-16 })) + (HsTok))) [] {Bag(LocatedA (HsBind GhcPs)): []} @@ -946,6 +991,10 @@ (TokenLoc (EpaSpan { T17544.hs:28:30 })) (HsTok))) + (L + (TokenLoc + (EpaSpan { T17544.hs:28:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:28:7-8 }) @@ -970,6 +1019,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:28:12-16 })) + (HsTok))) [] {Bag(LocatedA (HsBind GhcPs)): []} @@ -1223,6 +1277,10 @@ (TokenLoc (EpaSpan { T17544.hs:34:30 })) (HsTok))) + (L + (TokenLoc + (EpaSpan { T17544.hs:34:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:34:7-8 }) @@ -1247,6 +1305,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:34:12-16 })) + (HsTok))) [] {Bag(LocatedA (HsBind GhcPs)): []} @@ -1500,6 +1563,10 @@ (TokenLoc (EpaSpan { T17544.hs:40:30 })) (HsTok))) + (L + (TokenLoc + (EpaSpan { T17544.hs:40:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:40:7-8 }) @@ -1524,6 +1591,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:40:12-16 })) + (HsTok))) [] {Bag(LocatedA (HsBind GhcPs)): []} @@ -1777,6 +1849,10 @@ (TokenLoc (EpaSpan { T17544.hs:46:30 })) (HsTok))) + (L + (TokenLoc + (EpaSpan { T17544.hs:46:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:46:7-8 }) @@ -1801,6 +1877,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:46:12-16 })) + (HsTok))) [] {Bag(LocatedA (HsBind GhcPs)): []} @@ -2054,6 +2135,10 @@ (TokenLoc (EpaSpan { T17544.hs:52:32 })) (HsTok))) + (L + (TokenLoc + (EpaSpan { T17544.hs:52:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544.hs:52:7-9 }) @@ -2078,6 +2163,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544.hs:52:13-17 })) + (HsTok))) [] {Bag(LocatedA (HsBind GhcPs)): []} ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -281,6 +281,10 @@ (NoAnnSortKey)) (VirtualBraces (5)) + (L + (TokenLoc + (EpaSpan { T17544_kw.hs:21:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T17544_kw.hs:21:7-9 }) @@ -305,6 +309,11 @@ {OccName: a}))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T17544_kw.hs:23:3-7 })) + (HsTok))) [(L (SrcSpanAnn (EpAnnNotUsed) { T17544_kw.hs:24:5-18 }) (ClassOpSig ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -1052,6 +1052,10 @@ []} (VirtualBraces (3)) + (L + (TokenLoc + (EpaSpan { DumpRenamedAst.hs:27:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { DumpRenamedAst.hs:27:7 }) @@ -1074,6 +1078,11 @@ {Name: a})))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { DumpRenamedAst.hs:27:11-15 })) + (HsTok))) [] {Bag(LocatedA (HsBind Name)): []} ===================================== testsuite/tests/parser/should_compile/DumpSemis.stderr ===================================== @@ -1060,6 +1060,10 @@ (NoAnnSortKey)) (VirtualBraces (3)) + (L + (TokenLoc + (EpaSpan { DumpSemis.hs:28:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:28:7-19 }) @@ -1103,6 +1107,11 @@ {OccName: Type}))))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { DumpSemis.hs:28:40-44 })) + (HsTok))) [(L (SrcSpanAnn (EpAnnNotUsed) { DumpSemis.hs:29:3-23 }) (ClassOpSig ===================================== testsuite/tests/parser/should_compile/T20452.stderr ===================================== @@ -248,6 +248,10 @@ (TokenLoc (EpaSpan { T20452.hs:8:85 })) (HsTok))) + (L + (TokenLoc + (EpaSpan { T20452.hs:8:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T20452.hs:8:7-12 }) @@ -403,6 +407,11 @@ {OccName: String}))))]))))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T20452.hs:8:78-82 })) + (HsTok))) [] {Bag(LocatedA (HsBind GhcPs)): []} @@ -442,6 +451,10 @@ (TokenLoc (EpaSpan { T20452.hs:9:85 })) (HsTok))) + (L + (TokenLoc + (EpaSpan { T20452.hs:9:1-5 })) + (HsTok)) (Nothing) (L (SrcSpanAnn (EpAnnNotUsed) { T20452.hs:9:7-12 }) @@ -603,6 +616,11 @@ {OccName: String}))))]))))))]) (Prefix) [] + (Just + (L + (TokenLoc + (EpaSpan { T20452.hs:9:78-82 })) + (HsTok))) [] {Bag(LocatedA (HsBind GhcPs)): []} ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -3461,9 +3461,11 @@ instance ExactPrint (TyClDecl GhcPs) where exact (ClassDecl {tcdCExt = (an, sortKey), tcdLayout = lo, + tcdTkClass = tkClass, tcdCtxt = context, tcdLName = lclas, tcdTyVars = tyvars, tcdFixity = fixity, tcdFDs = fds, + tcdTkWhere = tkWhere, tcdSigs = sigs, tcdMeths = methods, tcdATs = ats, tcdATDefs = at_defs, tcdDocs = _docs}) @@ -3475,9 +3477,11 @@ instance ExactPrint (TyClDecl GhcPs) where an2 <- markEpAnnL an1 lidl AnnCloseC return (ClassDecl {tcdCExt = (an2, sortKey), tcdLayout = lo, + tcdTkClass = tkClass, tcdCtxt = context', tcdLName = lclas', tcdTyVars = tyvars', tcdFixity = fixity, tcdFDs = fds', + tcdTkWhere = tkWhere, tcdSigs = sigs, tcdMeths = methods, tcdATs = ats, tcdATDefs = at_defs, tcdDocs = _docs}) @@ -3502,9 +3506,11 @@ instance ExactPrint (TyClDecl GhcPs) where at_defs' = undynamic ds return (ClassDecl {tcdCExt = (an3, sortKey), tcdLayout = lo, + tcdTkClass = tkClass, tcdCtxt = context', tcdLName = lclas', tcdTyVars = tyvars', tcdFixity = fixity, tcdFDs = fds', + tcdTkWhere = tkWhere, tcdSigs = sigs', tcdMeths = methods', tcdATs = ats', tcdATDefs = at_defs', tcdDocs = _docs}) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit edc72530978d8a9ec92f51d288484986ec0051e3 +Subproject commit 0fa7dc86dccd751e06845c7ac3908230df2add7f View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7515ec98a5a04603ac366c8802ac8af813a74304 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7515ec98a5a04603ac366c8802ac8af813a74304 You're receiving 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 Dec 4 17:22:25 2022 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Sun, 04 Dec 2022 12:22:25 -0500 Subject: [Git][ghc/ghc][wip/T22166] 2 commits: Windows: Remove mingwex dependency Message-ID: <638cd751d7baa_17512e1e46a9d810111fe@gitlab.mail> Tamar Christina pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: 15b47435 by Ryan Scott at 2022-12-04T17:16:30+00:00 Windows: Remove mingwex dependency The clang based toolchain uses ucrt as its math library and so mingwex is no longer needed. In fact using mingwex will cause incompatibilities as the default routines in both have differing ULPs and string formatting modifiers. ``` $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe [1 of 2] Compiling Main ( Bug.hs, Bug.o ) ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info' ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above. <no location info>: error: GHC.ByteCode.Linker.lookupCE During interactive linking, GHCi couldn't find the following symbol: templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` - - - - - 9dd2d530 by Tamar Christina at 2022-12-04T17:22:12+00:00 linker: Fix BFD import libraries - - - - - 17 changed files: - configure.ac - hadrian/cfg/system.config.in - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Packages.hs - libraries/base/System/Posix/Internals.hs - libraries/base/base.cabal - libraries/base/configure.ac - libraries/base/include/HsBase.h - libraries/ghc-prim/ghc-prim.cabal - rts/Linker.c - rts/LinkerInternals.h - rts/RtsSymbols.c - rts/linker/PEi386.c - rts/package.conf.in - rts/rts.cabal.in - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/ghci/linking/dyn/all.T Changes: ===================================== configure.ac ===================================== @@ -927,17 +927,6 @@ AC_CHECK_DECLS([program_invocation_short_name], , , [#define _GNU_SOURCE 1 #include ]) -dnl ** check for mingwex library -AC_CHECK_LIB( - [mingwex], - [closedir], - [AC_SUBST([HaveLibMingwEx],[YES])] [AC_SUBST([CabalMingwex],[True])], - [AC_SUBST([HaveLibMingwEx],[NO])] [AC_SUBST([CabalMingwex],[False])]) - -if test $HaveLibMingwEx = YES ; then - AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.]) -fi - dnl ** check for math library dnl Keep that check as early as possible. dnl as we need to know whether we need libm ===================================== hadrian/cfg/system.config.in ===================================== @@ -204,7 +204,6 @@ libnuma-lib-dir = @LibNumaLibDir@ use-lib-dw = @UseLibdw@ use-lib-numa = @UseLibNuma@ -use-lib-mingw-ex = @HaveLibMingwEx@ use-lib-m = @UseLibm@ use-lib-rt = @UseLibrt@ use-lib-dl = @UseLibdl@ ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -33,7 +33,6 @@ data Flag = ArSupportsAtFile | UseLibffiForAdjustors | UseLibdw | UseLibnuma - | UseLibmingwex | UseLibm | UseLibrt | UseLibdl @@ -63,7 +62,6 @@ flag f = do UseLibffiForAdjustors -> "use-libffi-for-adjustors" UseLibdw -> "use-lib-dw" UseLibnuma -> "use-lib-numa" - UseLibmingwex -> "use-lib-mingw-ex" UseLibm -> "use-lib-m" UseLibrt -> "use-lib-rt" UseLibdl -> "use-lib-dl" ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -403,8 +403,7 @@ rtsPackageArgs = package rts ? do , builder HsCpp ? pure [ "-DTOP=" ++ show top ] - , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" - , builder HsCpp ? flag UseLibmingwex ? arg "-DHAVE_LIBMINGWEX" ] + , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" ] -- Compile various performance-critical pieces *without* -fPIC -dynamic -- even when building a shared library. If we don't do this, then the ===================================== libraries/base/System/Posix/Internals.hs ===================================== @@ -452,7 +452,6 @@ foreign import ccall unsafe "HsBase.h __hscore_fstat" foreign import ccall unsafe "HsBase.h __hscore_lstat" lstat :: CFilePath -> Ptr CStat -> IO CInt - #endif #if defined(js_HOST_ARCH) @@ -592,83 +591,74 @@ foreign import javascript unsafe "(($1,$2,$3_1,$3_2) => { return h$base_c_fcntl_ #else -{- Note: Win32 POSIX functions -Functions that are not part of the POSIX standards were -at some point deprecated by Microsoft. This deprecation -was performed by renaming the functions according to the -C++ ABI Section 17.6.4.3.2b. This was done to free up the -namespace of normal Windows programs since Windows isn't -POSIX compliant anyway. +#if defined(mingw32_HOST_OS) +-- See Note: Windows types +foreign import capi unsafe "HsBase.h _read" + c_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt -These were working before since the RTS was re-exporting -these symbols under the undeprecated names. This is no longer -being done. See #11223 +-- See Note: Windows types +foreign import capi safe "HsBase.h _read" + c_safe_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt -See https://msdn.microsoft.com/en-us/library/ms235384.aspx -for more. +foreign import ccall unsafe "HsBase.h _umask" + c_umask :: CMode -> IO CMode -However since we can't hope to get people to support Windows -packages we should support the deprecated names. See #12497 --} -foreign import capi unsafe "unistd.h lseek" - c_lseek :: CInt -> COff -> CInt -> IO COff +-- See Note: Windows types +foreign import capi unsafe "HsBase.h _write" + c_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt -foreign import ccall unsafe "HsBase.h access" +-- See Note: Windows types +foreign import capi safe "HsBase.h _write" + c_safe_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt + +foreign import ccall unsafe "HsBase.h _pipe" + c_pipe :: Ptr CInt -> IO CInt + +foreign import capi unsafe "HsBase.h _lseeki64" + c_lseek :: CInt -> Int64 -> CInt -> IO Int64 + +foreign import capi unsafe "HsBase.h _access" c_access :: CString -> CInt -> IO CInt #if !defined(HAVE_CHMOD) c_chmod :: CString -> CMode -> IO CInt -c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "chmod") +c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "_chmod") #else -foreign import ccall unsafe "HsBase.h chmod" +foreign import ccall unsafe "HsBase.h _chmod" c_chmod :: CString -> CMode -> IO CInt #endif -foreign import ccall unsafe "HsBase.h close" +foreign import capi unsafe "HsBase.h _close" c_close :: CInt -> IO CInt -foreign import ccall unsafe "HsBase.h creat" +foreign import capi unsafe "HsBase.h _creat" c_creat :: CString -> CMode -> IO CInt #if !defined(HAVE_DUP) c_dup :: CInt -> IO CInt -c_dup _ = ioError (ioeSetLocation unsupportedOperation "dup") +c_dup _ = ioError (ioeSetLocation unsupportedOperation "_dup") c_dup2 :: CInt -> CInt -> IO CInt -c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "dup2") +c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "_dup2") #else -foreign import ccall unsafe "HsBase.h dup" +foreign import ccall unsafe "HsBase.h _dup" c_dup :: CInt -> IO CInt -foreign import ccall unsafe "HsBase.h dup2" +foreign import ccall unsafe "HsBase.h _dup2" c_dup2 :: CInt -> CInt -> IO CInt #endif -foreign import ccall unsafe "HsBase.h isatty" +foreign import capi unsafe "HsBase.h _isatty" c_isatty :: CInt -> IO CInt -#if defined(mingw32_HOST_OS) --- See Note: Windows types -foreign import capi unsafe "HsBase.h _read" - c_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt - --- See Note: Windows types -foreign import capi safe "HsBase.h _read" - c_safe_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt - -foreign import ccall unsafe "HsBase.h _umask" - c_umask :: CMode -> IO CMode - --- See Note: Windows types -foreign import capi unsafe "HsBase.h _write" - c_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt +foreign import capi unsafe "HsBase.h _unlink" + c_unlink :: CString -> IO CInt --- See Note: Windows types -foreign import capi safe "HsBase.h _write" - c_safe_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt +foreign import capi unsafe "HsBase.h _utime" + c_utime :: CString -> Ptr CUtimbuf -> IO CInt -foreign import ccall unsafe "HsBase.h _pipe" - c_pipe :: Ptr CInt -> IO CInt +foreign import capi unsafe "HsBase.h _getpid" + c_getpid :: IO CPid #else -- We use CAPI as on some OSs (eg. Linux) this is wrapped by a macro -- which redirects to the 64-bit-off_t versions when large file @@ -700,8 +690,44 @@ c_pipe _ = ioError (ioeSetLocation unsupportedOperation "pipe") foreign import ccall unsafe "HsBase.h pipe" c_pipe :: Ptr CInt -> IO CInt #endif + +foreign import capi unsafe "unistd.h lseek" + c_lseek :: CInt -> COff -> CInt -> IO COff + +foreign import ccall unsafe "HsBase.h access" + c_access :: CString -> CInt -> IO CInt + +#if !defined(HAVE_CHMOD) +c_chmod :: CString -> CMode -> IO CInt +c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "chmod") +#else +foreign import ccall unsafe "HsBase.h chmod" + c_chmod :: CString -> CMode -> IO CInt #endif +foreign import ccall unsafe "HsBase.h close" + c_close :: CInt -> IO CInt + +foreign import ccall unsafe "HsBase.h creat" + c_creat :: CString -> CMode -> IO CInt + +#if !defined(HAVE_DUP) +c_dup :: CInt -> IO CInt +c_dup _ = ioError (ioeSetLocation unsupportedOperation "dup") + +c_dup2 :: CInt -> CInt -> IO CInt +c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "dup2") +#else +foreign import ccall unsafe "HsBase.h dup" + c_dup :: CInt -> IO CInt + +foreign import ccall unsafe "HsBase.h dup2" + c_dup2 :: CInt -> CInt -> IO CInt +#endif + +foreign import ccall unsafe "HsBase.h isatty" + c_isatty :: CInt -> IO CInt + foreign import ccall unsafe "HsBase.h unlink" c_unlink :: CString -> IO CInt @@ -715,6 +741,7 @@ c_getpid = pure 1 foreign import ccall unsafe "HsBase.h getpid" c_getpid :: IO CPid #endif +#endif #if !defined(js_HOST_ARCH) foreign import ccall unsafe "HsBase.h __hscore_stat" ===================================== libraries/base/base.cabal ===================================== @@ -396,7 +396,6 @@ Library if os(windows) -- Windows requires some extra libraries for linking because the RTS -- is no longer re-exporting them. - -- mingwex: provides C99 compatibility. libm is a stub on MingW. -- mingw32: Unfortunately required because of a resource leak between -- mingwex and mingw32. the __math_err symbol is defined in -- mingw32 which is required by mingwex. @@ -409,7 +408,7 @@ Library -- advapi32: provides advanced kernel functions extra-libraries: wsock32, user32, shell32, mingw32, kernel32, advapi32, - mingwex, ws2_32, shlwapi, ole32, rpcrt4, ntdll + ws2_32, shlwapi, ole32, rpcrt4, ntdll -- Minimum supported Windows version. -- These numbers can be found at: -- https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx ===================================== libraries/base/configure.ac ===================================== @@ -39,7 +39,7 @@ AC_CHECK_LIB([rt], [clock_gettime]) AC_CHECK_FUNCS([clock_gettime]) AC_CHECK_DECLS([CLOCK_PROCESS_CPUTIME_ID], [], [], [[#include ]]) AC_CHECK_FUNCS([getclock getrusage times]) -AC_CHECK_FUNCS([_chsize ftruncate]) +AC_CHECK_FUNCS([_chsize_s ftruncate]) # event-related fun # The line below already defines HAVE_KQUEUE and HAVE_POLL, so technically some of the ===================================== libraries/base/include/HsBase.h ===================================== @@ -280,15 +280,12 @@ __hscore_o_nonblock( void ) INLINE int __hscore_ftruncate( int fd, off_t where ) { -#if defined(HAVE_FTRUNCATE) +#if defined(HAVE__CHSIZE_S) + return _chsize_s(fd,where); +#elif defined(HAVE_FTRUNCATE) return ftruncate(fd,where); -#elif defined(HAVE__CHSIZE) - return _chsize(fd,where); #else -// ToDo: we should use _chsize_s() on Windows which allows a 64-bit -// offset, but it doesn't seem to be available from mingw at this time -// --SDM (01/2008) -#error at least ftruncate or _chsize functions are required to build +#error at least _chsize_s or ftruncate functions are required to build #endif } ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -66,15 +66,14 @@ Library if os(windows) -- Windows requires some extra libraries for linking because the RTS -- is no longer re-exporting them (see #11223) - -- msvcrt: standard C library. The RTS will automatically include this, - -- but is added for completeness. - -- mingwex: provides C99 compatibility. libm is a stub on MingW. + -- ucrt: standard C library. The RTS will automatically include this, + -- but is added for completeness. -- mingw32: Unfortunately required because of a resource leak between -- mingwex and mingw32. the __math_err symbol is defined in -- mingw32 which is required by mingwex. -- user32: provides access to apis to modify user components (UI etc) -- on Windows. Required because of mingw32. - extra-libraries: user32, mingw32, mingwex, ucrt + extra-libraries: user32, mingw32, ucrt if os(linux) -- we need libm, but for musl and other's we might need libc, as libm ===================================== rts/Linker.c ===================================== @@ -135,7 +135,7 @@ extern void iconv(); This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will never use. This is especially painful on Windows, where the number of - libraries required to link things like mingwex grows to be quite high. + libraries required to link things like QT or WxWidgets grows to be quite high. We proceed through these stages as follows, @@ -193,7 +193,7 @@ extern void iconv(); 1) Dependency chains, if A.o required a .o in libB but A.o isn't required to link then we don't need to load libB. This means the dependency chain for libraries - such as mingw32 and mingwex can be broken down. + such as ucrt can be broken down. 2) The number of duplicate symbols, since now only symbols that are true duplicates will display the error. @@ -226,7 +226,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key, static const char * symbolTypeString (SymType type) { - switch (type) { + switch (type & ~SYM_TYPE_DUP_DISCARD) { case SYM_TYPE_CODE: return "code"; case SYM_TYPE_DATA: return "data"; case SYM_TYPE_INDIRECT_DATA: return "indirect-data"; @@ -275,14 +275,19 @@ int ghciInsertSymbolTable( insertStrHashTable(table, key, pinfo); return 1; } - else if (pinfo->type != type) + else if (pinfo->type ^ type) { - debugBelch("Symbol type mismatch.\n"); - debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", - key, obj_name, symbolTypeString(type)); - debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", - pinfo->owner ? pinfo->owner->fileName : WSTR(""), - symbolTypeString(pinfo->type)); + /* We were asked to discard the symbol on duplicates, do so quietly. */ + if (!(type & SYM_TYPE_DUP_DISCARD)) + { + DebugBreak (); + debugBelch("Symbol type mismatch.\n"); + debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", + key, obj_name, symbolTypeString(type)); + debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", + pinfo->owner ? pinfo->owner->fileName : WSTR(""), + symbolTypeString(pinfo->type)); + } return 1; } else if (pinfo->strength == STRENGTH_STRONG) ===================================== rts/LinkerInternals.h ===================================== @@ -56,9 +56,12 @@ typedef struct _Section Section; /* What kind of thing a symbol identifies. We need to know this to determine how * to process overflowing relocations. See Note [Processing overflowed relocations]. */ typedef enum _SymType { - SYM_TYPE_CODE, /* the symbol is a function and can be relocated via a jump island */ - SYM_TYPE_DATA, /* the symbol is data */ - SYM_TYPE_INDIRECT_DATA, /* see Note [_iob_func symbol] */ + SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */ + SYM_TYPE_DATA = 1 << 1, /* the symbol is data */ + SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */ + SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library + however if a duplicate is found with a mismatching + SymType then discard this one. */ } SymType; ===================================== rts/RtsSymbols.c ===================================== @@ -113,26 +113,6 @@ extern char **environ; * by the RtsSymbols entry. To avoid this we introduce a horrible special case * in `ghciInsertSymbolTable`, ensure that `atexit` is never overridden. */ -/* - * Note [Symbols for MinGW's printf] - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * The printf offered by Microsoft's libc implementation, msvcrt, is quite - * incomplete, lacking support for even %ull. Consequently mingw-w64 offers its - * own implementation which we enable. However, to be thread-safe the - * implementation uses _lock_file. This would be fine except msvcrt.dll doesn't - * export _lock_file, only numbered versions do (e.g. msvcrt90.dll). - * - * To work around this mingw-w64 packages a static archive of msvcrt which - * includes their own implementation of _lock_file. However, this means that - * the archive contains things which the dynamic library does not; consequently - * we need to ensure that the runtime linker provides this symbol. - * - * It's all just so terrible. - * - * See also: - * https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ - * https://sourceforge.net/p/mingw-w64/discussion/723797/thread/55520785/ - */ /* Note [_iob_func symbol] * ~~~~~~~~~~~~~~~~~~~~~~~ * Microsoft in VS2013 to VS2015 transition made a backwards incompatible change @@ -170,12 +150,6 @@ extern char **environ; SymI_NeedsProto(__mingw_module_is_dll) \ RTS_WIN32_ONLY(SymI_NeedsProto(___chkstk_ms)) \ RTS_WIN64_ONLY(SymI_NeedsProto(___chkstk_ms)) \ - RTS_WIN64_ONLY(SymI_HasProto(__stdio_common_vswprintf_s)) \ - RTS_WIN64_ONLY(SymI_HasProto(__stdio_common_vswprintf)) \ - RTS_WIN64_ONLY(SymI_HasProto(_errno)) \ - /* see Note [Symbols for MinGW's printf] */ \ - SymI_HasProto(_lock_file) \ - SymI_HasProto(_unlock_file) \ SymI_HasProto(__mingw_vsnwprintf) \ /* ^^ Need to figure out why this is needed. */ \ /* See Note [_iob_func symbol] */ \ @@ -187,120 +161,8 @@ extern char **environ; /* ^^ 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 \ - SymI_HasProto_deprecated(access) \ - SymI_HasProto_deprecated(cabs) \ - SymI_HasProto_deprecated(cgets) \ - SymI_HasProto_deprecated(chdir) \ - SymI_HasProto_deprecated(chmod) \ - SymI_HasProto_deprecated(chsize) \ - SymI_HasProto_deprecated(close) \ - SymI_HasProto_deprecated(cprintf) \ - SymI_HasProto_deprecated(cputs) \ - SymI_HasProto_deprecated(creat) \ - SymI_HasProto_deprecated(cscanf) \ - SymI_HasProto_deprecated(cwait) \ - SymI_HasProto_deprecated(dup) \ - SymI_HasProto_deprecated(dup2) \ - SymI_HasProto_deprecated(ecvt) \ - SymI_HasProto_deprecated(eof) \ - SymI_HasProto_deprecated(execl) \ - SymI_HasProto_deprecated(execle) \ - SymI_HasProto_deprecated(execlp) \ - SymI_HasProto_deprecated(execlpe) \ - SymI_HasProto_deprecated(execv) \ - SymI_HasProto_deprecated(execve) \ - SymI_HasProto_deprecated(execvp) \ - SymI_HasProto_deprecated(execvpe) \ - SymI_HasProto_deprecated(fcloseall) \ - SymI_HasProto_deprecated(fcvt) \ - SymI_HasProto_deprecated(fdopen) \ - SymI_HasProto_deprecated(fgetchar) \ - SymI_HasProto_deprecated(filelength) \ - SymI_HasProto_deprecated(fileno) \ - SymI_HasProto_deprecated(flushall) \ - SymI_HasProto_deprecated(fputchar) \ - SymI_HasProto_deprecated(gcvt) \ - SymI_HasProto_deprecated(getch) \ - SymI_HasProto_deprecated(getche) \ - SymI_HasProto_deprecated(getcwd) \ - SymI_HasProto_deprecated(getpid) \ - SymI_HasProto_deprecated(getw) \ - SymI_HasProto_deprecated(hypot) \ - SymI_HasProto_deprecated(inp) \ - SymI_HasProto_deprecated(inpw) \ - SymI_HasProto_deprecated(isascii) \ - SymI_HasProto_deprecated(isatty) \ - SymI_HasProto_deprecated(iscsym) \ - SymI_HasProto_deprecated(iscsymf) \ - SymI_HasProto_deprecated(itoa) \ - SymI_HasProto_deprecated(j0) \ - SymI_HasProto_deprecated(j1) \ - SymI_HasProto_deprecated(jn) \ - SymI_HasProto_deprecated(kbhit) \ - SymI_HasProto_deprecated(lfind) \ - SymI_HasProto_deprecated(locking) \ - SymI_HasProto_deprecated(lsearch) \ - SymI_HasProto_deprecated(lseek) \ - SymI_HasProto_deprecated(ltoa) \ - SymI_HasProto_deprecated(memccpy) \ - SymI_HasProto_deprecated(memicmp) \ - SymI_HasProto_deprecated(mkdir) \ - SymI_HasProto_deprecated(mktemp) \ - SymI_HasProto_deprecated(open) \ - SymI_HasProto_deprecated(outp) \ - SymI_HasProto_deprecated(outpw) \ - SymI_HasProto_deprecated(putch) \ - SymI_HasProto_deprecated(putenv) \ - SymI_HasProto_deprecated(putw) \ - SymI_HasProto_deprecated(read) \ - SymI_HasProto_deprecated(rmdir) \ - SymI_HasProto_deprecated(rmtmp) \ - SymI_HasProto_deprecated(setmode) \ - SymI_HasProto_deprecated(sopen) \ - SymI_HasProto_deprecated(spawnl) \ - SymI_HasProto_deprecated(spawnle) \ - SymI_HasProto_deprecated(spawnlp) \ - SymI_HasProto_deprecated(spawnlpe) \ - SymI_HasProto_deprecated(spawnv) \ - SymI_HasProto_deprecated(spawnve) \ - SymI_HasProto_deprecated(spawnvp) \ - SymI_HasProto_deprecated(spawnvpe) \ - SymI_HasProto_deprecated(strcmpi) \ - SymI_HasProto_deprecated(strdup) \ - SymI_HasProto_deprecated(stricmp) \ - SymI_HasProto_deprecated(strlwr) \ - SymI_HasProto_deprecated(strnicmp) \ - SymI_HasProto_deprecated(strnset) \ - SymI_HasProto_deprecated(strrev) \ - SymI_HasProto_deprecated(strset) \ - SymI_HasProto_deprecated(strupr) \ - SymI_HasProto_deprecated(swab) \ - SymI_HasProto_deprecated(tell) \ - SymI_HasProto_deprecated(tempnam) \ - SymI_HasProto_deprecated(toascii) \ - SymI_HasProto_deprecated(tzset) \ - SymI_HasProto_deprecated(ultoa) \ - SymI_HasProto_deprecated(umask) \ - SymI_HasProto_deprecated(ungetch) \ - SymI_HasProto_deprecated(unlink) \ - SymI_HasProto_deprecated(wcsdup) \ - SymI_HasProto_deprecated(wcsicmp) \ - SymI_HasProto_deprecated(wcsicoll) \ - SymI_HasProto_deprecated(wcslwr) \ - SymI_HasProto_deprecated(wcsnicmp) \ - SymI_HasProto_deprecated(wcsnset) \ - SymI_HasProto_deprecated(wcsrev) \ - SymI_HasProto_deprecated(wcsset) \ - SymI_HasProto_deprecated(wcsupr) \ - SymI_HasProto_deprecated(write) \ - SymI_HasProto_deprecated(y0) \ - SymI_HasProto_deprecated(y1) \ - SymI_HasProto_deprecated(yn) #else #define RTS_MINGW_ONLY_SYMBOLS /**/ -#define RTS_MINGW_COMPAT_SYMBOLS /**/ #endif @@ -1181,7 +1043,6 @@ RtsSymbolVal rtsSyms[] = { RTS_RET_SYMBOLS RTS_POSIX_ONLY_SYMBOLS RTS_MINGW_ONLY_SYMBOLS - RTS_MINGW_COMPAT_SYMBOLS RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBGCC_SYMBOLS ===================================== rts/linker/PEi386.c ===================================== @@ -261,6 +261,54 @@ .asciiz "libfoo_data" + Note [GHC Linking model and import libraries] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The above describes how import libraries work for static linking. + Fundamentally this does not apply to dynamic linking as we do in GHC. + The issue is two-folds: + + 1. In the linking model above it is expected that the .idata sections be + materialized into PLTs during linking. However in GHC we never create + PLTs, but have out own mechanism for this which is the jump island + machinery. This is required for efficiency. For one materializing the + .idata sections would result in wasting pages. We'd use one page for + every ~100 bytes. This is extremely wasteful and also fragments the + memory. Secondly the dynamic linker is lazy. We only perform the final + loading if the symbol is used, however with an import library we can + discard the actual OC immediately after reading it. This prevents us from + keeping ~1k in memory per symbol for no reason. + + 2. GHC itself does not observe symbol visibility correctly during NGC. This + in itself isn't an academic exercise. The issue stems from GHC using one + mechanism for providing two incompatible linking modes: + a) The first mode is generating Haskell shared libraries which are + intended to be used by other Haskell code. This requires us to + export the info, data and closures. For this GHC just re-exports + all symbols. But it doesn't correcly mark data/code. Symbol + visibility is overwritten by telling the linker to export all + symbols. + b) The second code is producing code that's supposed to be call-able + through a C insterface. This in reality does not require the + export of closures and info tables. But also does not require the + inclusion of the RTS inside the DLL. Hover this is done today + because we don't properly have the RTS as a dynamic library. + i.e. GHC does not only export symbols denoted by foreign export. + Also GHC should depend on an RTS library, but at the moment it + cannot because of TNTC is incompatible with dynamic linking. + + These two issues mean that for GHC we need to take a different approach + to handling import libraries. For normal C libraries we have proper + differentiation between CODE and DATA. For GHC produced import libraries + we do not. As such the SYM_TYPE_DUP_DISCARD tells the linker that if a + duplicate symbol is found, and we were going to discard it anyway, just do + so quitely. This works because the RTS symbols themselves are provided by + the currently loaded RTS as built-in symbols. + + Secondly we cannot rely on a text symbol being available. As such we + should only depend on the symbols as defined in the .idata sections, + otherwise we would not be able to correctly link against GHC produced + import libraries. + Note [Memory allocation] ~~~~~~~~~~~~~~~~~~~~~~~~ The loading of an object begins in `preloadObjectFile`, which allocates a buffer, @@ -1658,7 +1706,10 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if ( secNumber != IMAGE_SYM_UNDEFINED && secNumber > 0 && section - && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY) { + /* Skip all BFD import sections. */ + && section->kind != SECTIONKIND_IMPORT + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY_HEAD) { /* This symbol is global and defined, viz, exported */ /* for IMAGE_SYMCLASS_EXTERNAL && !IMAGE_SYM_UNDEFINED, @@ -1691,12 +1742,49 @@ ocGetNames_PEi386 ( ObjectCode* oc ) IF_DEBUG(linker_verbose, debugBelch("bss symbol @ %p %u\n", addr, symValue)); } else if (section && section->kind == SECTIONKIND_BFD_IMPORT_LIBRARY) { - setImportSymbol(oc, sname); + /* Disassembly of section .idata$5: + + 0000000000000000 <__imp_Insert>: + ... + 0: IMAGE_REL_AMD64_ADDR32NB .idata$6 + + The first two bytes contain the ordinal of the function + in the format of lowpart highpart. The two bytes combined + for the total range of 16 bits which is the function export limit + of DLLs. See note [GHC Linking model and import libraries]. */ + sname = (SymbolName*)section->start+2; + COFF_symbol* sym = &oc->info->symbols[info->numberOfSymbols-1]; + addr = get_sym_name( getSymShortName (info, sym), oc); + + IF_DEBUG(linker, + debugBelch("addImportSymbol `%s' => `%s'\n", + sname, (char*)addr)); + /* We're going to free the any data associated with the import + library without copying the sections. So we have to duplicate + the symbol name and values before the pointers become invalid. */ + sname = strdup (sname); + addr = strdup (addr); + type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA; + type |= SYM_TYPE_DUP_DISCARD; + if (!ghciInsertSymbolTable(oc->fileName, symhash, sname, + addr, false, type, oc)) { + releaseOcInfo (oc); + stgFree (oc->image); + oc->image = NULL; + return false; + } + setImportSymbol (oc, sname); + + /* Don't process this oc any further. Just exit. */ + oc->n_symbols = 0; + oc->symbols = NULL; + stgFree (oc->image); + oc->image = NULL; + releaseOcInfo (oc); // There is nothing that we need to resolve in this object since we // will never call the import stubs in its text section oc->status = OBJECT_DONT_RESOLVE; - - IF_DEBUG(linker_verbose, debugBelch("import symbol %s\n", sname)); + return true; } else if (secNumber > 0 && section ===================================== rts/package.conf.in ===================================== @@ -54,11 +54,6 @@ extra-libraries: #if defined(DEBUG) && defined(HAVE_LIBBFD) ,"bfd", "iberty" /* for debugging */ #endif -#if defined(HAVE_LIBMINGWEX) -# if !defined(INSTALLING) /* Bundled Mingw is behind */ - ,"mingwex" -# endif -#endif #if USE_LIBDW , "elf" , "dw" /* for backtraces */ ===================================== rts/rts.cabal.in ===================================== @@ -24,8 +24,6 @@ flag need-pthread default: @CabalNeedLibpthread@ flag libbfd default: @CabalHaveLibbfd@ -flag mingwex - default: @CabalMingwex@ flag need-atomic default: @CabalNeedLibatomic@ flag libdw @@ -68,7 +66,6 @@ library exposed: True exposed-modules: - if os(ghcjs) include-dirs: include @@ -194,8 +191,6 @@ library if flag(libbfd) -- for debugging extra-libraries: bfd iberty - if flag(mingwex) - extra-libraries: mingwex if flag(libdw) -- for backtraces extra-libraries: elf dw ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -88,10 +88,6 @@ compile_libAB_dyn: .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: - rm -rf bin_impl_gcc - mkdir bin_impl_gcc - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_impl_gcc" -shared A.c -o "bin_impl_gcc/$(call DLL,ASimpL)" - mv bin_impl_gcc/libASimpL.dll.a bin_impl_gcc/libASx.dll.a echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T11072.hs -lASx -L./bin_impl_gcc .PHONY: compile_libAS_impl_msvc ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -41,9 +41,9 @@ test('T10458', extra_hc_opts('-L"$PWD/T10458dir" -lAS')], ghci_script, ['T10458.script']) -test('T11072gcc', [extra_files(['A.c', 'T11072.hs']), - expect_broken(18718), - unless(doing_ghci, skip), unless(opsys('mingw32'), skip)], +test('T11072gcc', [extra_files(['A.c', 'T11072.hs', 'bin_impl_gcc/']), + unless(doing_ghci, skip), unless(opsys('mingw32'), skip), + unless(arch('x86_64'), skip)], makefile_test, ['compile_libAS_impl_gcc']) test('T11072msvc', [extra_files(['A.c', 'T11072.hs', 'libAS.def', 'i686/', 'x86_64/']), View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/50953eeadea0ef1208241fb4620a934e2ca24ef5...9dd2d530a2db524b498917a992dbeadbcb89e03e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/50953eeadea0ef1208241fb4620a934e2ca24ef5...9dd2d530a2db524b498917a992dbeadbcb89e03e You're receiving 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 Dec 4 17:26:08 2022 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Sun, 04 Dec 2022 12:26:08 -0500 Subject: [Git][ghc/ghc][wip/T22166] linker: Fix BFD import libraries Message-ID: <638cd83051d49_17512e1e46a9d81011664@gitlab.mail> Tamar Christina pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: 3703b7b5 by Tamar Christina at 2022-12-04T17:25:53+00:00 linker: Fix BFD import libraries - - - - - 8 changed files: - hadrian/src/Settings/Packages.hs - rts/Linker.c - rts/LinkerInternals.h - rts/linker/PEi386.c - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/ghci/linking/dyn/all.T - + testsuite/tests/ghci/linking/dyn/bin_impl_gcc/ASimpL.dll - + testsuite/tests/ghci/linking/dyn/bin_impl_gcc/libASx.dll.a Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -403,7 +403,7 @@ rtsPackageArgs = package rts ? do , builder HsCpp ? pure [ "-DTOP=" ++ show top ] - , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" + , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" ] -- Compile various performance-critical pieces *without* -fPIC -dynamic -- even when building a shared library. If we don't do this, then the ===================================== rts/Linker.c ===================================== @@ -135,8 +135,7 @@ extern void iconv(); This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will never use. This is especially painful on Windows, where the number of - libraries required to link things like mingwex (TODO: We no longer depend - on mingwex, so think of a different example here) grows to be quite high. + libraries required to link things like QT or WxWidgets grows to be quite high. We proceed through these stages as follows, @@ -194,8 +193,7 @@ extern void iconv(); 1) Dependency chains, if A.o required a .o in libB but A.o isn't required to link then we don't need to load libB. This means the dependency chain for libraries - such as mingw32 and mingwex (TODO: We no longer depend on mingwex, so think of - a different example here) can be broken down. + such as ucrt can be broken down. 2) The number of duplicate symbols, since now only symbols that are true duplicates will display the error. @@ -228,7 +226,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key, static const char * symbolTypeString (SymType type) { - switch (type) { + switch (type & ~SYM_TYPE_DUP_DISCARD) { case SYM_TYPE_CODE: return "code"; case SYM_TYPE_DATA: return "data"; case SYM_TYPE_INDIRECT_DATA: return "indirect-data"; @@ -277,14 +275,19 @@ int ghciInsertSymbolTable( insertStrHashTable(table, key, pinfo); return 1; } - else if (pinfo->type != type) + else if (pinfo->type ^ type) { - debugBelch("Symbol type mismatch.\n"); - debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", - key, obj_name, symbolTypeString(type)); - debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", - pinfo->owner ? pinfo->owner->fileName : WSTR(""), - symbolTypeString(pinfo->type)); + /* We were asked to discard the symbol on duplicates, do so quietly. */ + if (!(type & SYM_TYPE_DUP_DISCARD)) + { + DebugBreak (); + debugBelch("Symbol type mismatch.\n"); + debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", + key, obj_name, symbolTypeString(type)); + debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", + pinfo->owner ? pinfo->owner->fileName : WSTR(""), + symbolTypeString(pinfo->type)); + } return 1; } else if (pinfo->strength == STRENGTH_STRONG) ===================================== rts/LinkerInternals.h ===================================== @@ -56,9 +56,12 @@ typedef struct _Section Section; /* What kind of thing a symbol identifies. We need to know this to determine how * to process overflowing relocations. See Note [Processing overflowed relocations]. */ typedef enum _SymType { - SYM_TYPE_CODE, /* the symbol is a function and can be relocated via a jump island */ - SYM_TYPE_DATA, /* the symbol is data */ - SYM_TYPE_INDIRECT_DATA, /* see Note [_iob_func symbol] */ + SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */ + SYM_TYPE_DATA = 1 << 1, /* the symbol is data */ + SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */ + SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library + however if a duplicate is found with a mismatching + SymType then discard this one. */ } SymType; ===================================== rts/linker/PEi386.c ===================================== @@ -261,6 +261,54 @@ .asciiz "libfoo_data" + Note [GHC Linking model and import libraries] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The above describes how import libraries work for static linking. + Fundamentally this does not apply to dynamic linking as we do in GHC. + The issue is two-folds: + + 1. In the linking model above it is expected that the .idata sections be + materialized into PLTs during linking. However in GHC we never create + PLTs, but have out own mechanism for this which is the jump island + machinery. This is required for efficiency. For one materializing the + .idata sections would result in wasting pages. We'd use one page for + every ~100 bytes. This is extremely wasteful and also fragments the + memory. Secondly the dynamic linker is lazy. We only perform the final + loading if the symbol is used, however with an import library we can + discard the actual OC immediately after reading it. This prevents us from + keeping ~1k in memory per symbol for no reason. + + 2. GHC itself does not observe symbol visibility correctly during NGC. This + in itself isn't an academic exercise. The issue stems from GHC using one + mechanism for providing two incompatible linking modes: + a) The first mode is generating Haskell shared libraries which are + intended to be used by other Haskell code. This requires us to + export the info, data and closures. For this GHC just re-exports + all symbols. But it doesn't correcly mark data/code. Symbol + visibility is overwritten by telling the linker to export all + symbols. + b) The second code is producing code that's supposed to be call-able + through a C insterface. This in reality does not require the + export of closures and info tables. But also does not require the + inclusion of the RTS inside the DLL. Hover this is done today + because we don't properly have the RTS as a dynamic library. + i.e. GHC does not only export symbols denoted by foreign export. + Also GHC should depend on an RTS library, but at the moment it + cannot because of TNTC is incompatible with dynamic linking. + + These two issues mean that for GHC we need to take a different approach + to handling import libraries. For normal C libraries we have proper + differentiation between CODE and DATA. For GHC produced import libraries + we do not. As such the SYM_TYPE_DUP_DISCARD tells the linker that if a + duplicate symbol is found, and we were going to discard it anyway, just do + so quitely. This works because the RTS symbols themselves are provided by + the currently loaded RTS as built-in symbols. + + Secondly we cannot rely on a text symbol being available. As such we + should only depend on the symbols as defined in the .idata sections, + otherwise we would not be able to correctly link against GHC produced + import libraries. + Note [Memory allocation] ~~~~~~~~~~~~~~~~~~~~~~~~ The loading of an object begins in `preloadObjectFile`, which allocates a buffer, @@ -1658,7 +1706,10 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if ( secNumber != IMAGE_SYM_UNDEFINED && secNumber > 0 && section - && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY) { + /* Skip all BFD import sections. */ + && section->kind != SECTIONKIND_IMPORT + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY_HEAD) { /* This symbol is global and defined, viz, exported */ /* for IMAGE_SYMCLASS_EXTERNAL && !IMAGE_SYM_UNDEFINED, @@ -1691,12 +1742,49 @@ ocGetNames_PEi386 ( ObjectCode* oc ) IF_DEBUG(linker_verbose, debugBelch("bss symbol @ %p %u\n", addr, symValue)); } else if (section && section->kind == SECTIONKIND_BFD_IMPORT_LIBRARY) { - setImportSymbol(oc, sname); + /* Disassembly of section .idata$5: + + 0000000000000000 <__imp_Insert>: + ... + 0: IMAGE_REL_AMD64_ADDR32NB .idata$6 + + The first two bytes contain the ordinal of the function + in the format of lowpart highpart. The two bytes combined + for the total range of 16 bits which is the function export limit + of DLLs. See note [GHC Linking model and import libraries]. */ + sname = (SymbolName*)section->start+2; + COFF_symbol* sym = &oc->info->symbols[info->numberOfSymbols-1]; + addr = get_sym_name( getSymShortName (info, sym), oc); + + IF_DEBUG(linker, + debugBelch("addImportSymbol `%s' => `%s'\n", + sname, (char*)addr)); + /* We're going to free the any data associated with the import + library without copying the sections. So we have to duplicate + the symbol name and values before the pointers become invalid. */ + sname = strdup (sname); + addr = strdup (addr); + type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA; + type |= SYM_TYPE_DUP_DISCARD; + if (!ghciInsertSymbolTable(oc->fileName, symhash, sname, + addr, false, type, oc)) { + releaseOcInfo (oc); + stgFree (oc->image); + oc->image = NULL; + return false; + } + setImportSymbol (oc, sname); + + /* Don't process this oc any further. Just exit. */ + oc->n_symbols = 0; + oc->symbols = NULL; + stgFree (oc->image); + oc->image = NULL; + releaseOcInfo (oc); // There is nothing that we need to resolve in this object since we // will never call the import stubs in its text section oc->status = OBJECT_DONT_RESOLVE; - - IF_DEBUG(linker_verbose, debugBelch("import symbol %s\n", sname)); + return true; } else if (secNumber > 0 && section ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -88,10 +88,6 @@ compile_libAB_dyn: .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: - rm -rf bin_impl_gcc - mkdir bin_impl_gcc - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_impl_gcc" -shared A.c -o "bin_impl_gcc/$(call DLL,ASimpL)" - mv bin_impl_gcc/libASimpL.dll.a bin_impl_gcc/libASx.dll.a echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T11072.hs -lASx -L./bin_impl_gcc .PHONY: compile_libAS_impl_msvc ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -41,9 +41,9 @@ test('T10458', extra_hc_opts('-L"$PWD/T10458dir" -lAS')], ghci_script, ['T10458.script']) -test('T11072gcc', [extra_files(['A.c', 'T11072.hs']), - expect_broken(18718), - unless(doing_ghci, skip), unless(opsys('mingw32'), skip)], +test('T11072gcc', [extra_files(['A.c', 'T11072.hs', 'bin_impl_gcc/']), + unless(doing_ghci, skip), unless(opsys('mingw32'), skip), + unless(arch('x86_64'), skip)], makefile_test, ['compile_libAS_impl_gcc']) test('T11072msvc', [extra_files(['A.c', 'T11072.hs', 'libAS.def', 'i686/', 'x86_64/']), ===================================== testsuite/tests/ghci/linking/dyn/bin_impl_gcc/ASimpL.dll ===================================== Binary files /dev/null and b/testsuite/tests/ghci/linking/dyn/bin_impl_gcc/ASimpL.dll differ ===================================== testsuite/tests/ghci/linking/dyn/bin_impl_gcc/libASx.dll.a ===================================== Binary files /dev/null and b/testsuite/tests/ghci/linking/dyn/bin_impl_gcc/libASx.dll.a differ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3703b7b56b9e48b0b65b4a3ba9c2f0006c406ef8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3703b7b56b9e48b0b65b4a3ba9c2f0006c406ef8 You're receiving 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 Dec 4 17:39:08 2022 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Sun, 04 Dec 2022 12:39:08 -0500 Subject: [Git][ghc/ghc][wip/T22166] 2 commits: Windows: Remove mingwex dependency Message-ID: <638cdb3c8b4db_17512e2b97999410123fb@gitlab.mail> Tamar Christina pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: 7a5dd9b8 by Ryan Scott at 2022-12-04T17:38:37+00:00 Windows: Remove mingwex dependency The clang based toolchain uses ucrt as its math library and so mingwex is no longer needed. In fact using mingwex will cause incompatibilities as the default routines in both have differing ULPs and string formatting modifiers. ``` $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe [1 of 2] Compiling Main ( Bug.hs, Bug.o ) ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info' ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above. <no location info>: error: GHC.ByteCode.Linker.lookupCE During interactive linking, GHCi couldn't find the following symbol: templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` - - - - - ace45702 by Tamar Christina at 2022-12-04T17:38:49+00:00 linker: Fix BFD import libraries - - - - - 20 changed files: - configure.ac - hadrian/cfg/system.config.in - hadrian/src/Oracles/Flag.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Packages.hs - libraries/base/System/Posix/Internals.hs - libraries/base/base.cabal - libraries/base/configure.ac - libraries/base/include/HsBase.h - libraries/ghc-prim/ghc-prim.cabal - rts/Linker.c - rts/LinkerInternals.h - rts/RtsSymbols.c - rts/linker/PEi386.c - rts/package.conf.in - rts/rts.cabal.in - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/ghci/linking/dyn/all.T - + testsuite/tests/ghci/linking/dyn/bin_impl_gcc/ASimpL.dll - + testsuite/tests/ghci/linking/dyn/bin_impl_gcc/libASx.dll.a Changes: ===================================== configure.ac ===================================== @@ -927,17 +927,6 @@ AC_CHECK_DECLS([program_invocation_short_name], , , [#define _GNU_SOURCE 1 #include ]) -dnl ** check for mingwex library -AC_CHECK_LIB( - [mingwex], - [closedir], - [AC_SUBST([HaveLibMingwEx],[YES])] [AC_SUBST([CabalMingwex],[True])], - [AC_SUBST([HaveLibMingwEx],[NO])] [AC_SUBST([CabalMingwex],[False])]) - -if test $HaveLibMingwEx = YES ; then - AC_DEFINE([HAVE_MINGWEX], [1], [Define to 1 if you have the mingwex library.]) -fi - dnl ** check for math library dnl Keep that check as early as possible. dnl as we need to know whether we need libm ===================================== hadrian/cfg/system.config.in ===================================== @@ -204,7 +204,6 @@ libnuma-lib-dir = @LibNumaLibDir@ use-lib-dw = @UseLibdw@ use-lib-numa = @UseLibNuma@ -use-lib-mingw-ex = @HaveLibMingwEx@ use-lib-m = @UseLibm@ use-lib-rt = @UseLibrt@ use-lib-dl = @UseLibdl@ ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -33,7 +33,6 @@ data Flag = ArSupportsAtFile | UseLibffiForAdjustors | UseLibdw | UseLibnuma - | UseLibmingwex | UseLibm | UseLibrt | UseLibdl @@ -63,7 +62,6 @@ flag f = do UseLibffiForAdjustors -> "use-libffi-for-adjustors" UseLibdw -> "use-lib-dw" UseLibnuma -> "use-lib-numa" - UseLibmingwex -> "use-lib-mingw-ex" UseLibm -> "use-lib-m" UseLibrt -> "use-lib-rt" UseLibdl -> "use-lib-dl" ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -266,7 +266,6 @@ templateRules = do target_word_size <- settingWord TargetWordSize lib_dw <- flag UseLibdw lib_numa <- flag UseLibnuma - lib_mingwex <- flag UseLibmingwex lib_m <- flag UseLibm lib_rt <- flag UseLibrt lib_dl <- flag UseLibdl @@ -283,7 +282,6 @@ templateRules = do subst = replace "@ProjectVersion@" project_version . replace "@ProjectVersionMunged@" project_version_munged . replace "@Cabal64bit@" (cabal_bool (target_word_size == 8)) - . replace "@CabalMingwex@" (cabal_bool lib_mingwex) . replace "@CabalHaveLibdw@" (cabal_bool lib_dw) . replace "@CabalHaveLibm@" (cabal_bool lib_m) . replace "@CabalHaveLibrt@" (cabal_bool lib_rt) ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -403,8 +403,7 @@ rtsPackageArgs = package rts ? do , builder HsCpp ? pure [ "-DTOP=" ++ show top ] - , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" - , builder HsCpp ? flag UseLibmingwex ? arg "-DHAVE_LIBMINGWEX" ] + , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" ] -- Compile various performance-critical pieces *without* -fPIC -dynamic -- even when building a shared library. If we don't do this, then the ===================================== libraries/base/System/Posix/Internals.hs ===================================== @@ -452,7 +452,6 @@ foreign import ccall unsafe "HsBase.h __hscore_fstat" foreign import ccall unsafe "HsBase.h __hscore_lstat" lstat :: CFilePath -> Ptr CStat -> IO CInt - #endif #if defined(js_HOST_ARCH) @@ -592,83 +591,74 @@ foreign import javascript unsafe "(($1,$2,$3_1,$3_2) => { return h$base_c_fcntl_ #else -{- Note: Win32 POSIX functions -Functions that are not part of the POSIX standards were -at some point deprecated by Microsoft. This deprecation -was performed by renaming the functions according to the -C++ ABI Section 17.6.4.3.2b. This was done to free up the -namespace of normal Windows programs since Windows isn't -POSIX compliant anyway. +#if defined(mingw32_HOST_OS) +-- See Note: Windows types +foreign import capi unsafe "HsBase.h _read" + c_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt -These were working before since the RTS was re-exporting -these symbols under the undeprecated names. This is no longer -being done. See #11223 +-- See Note: Windows types +foreign import capi safe "HsBase.h _read" + c_safe_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt -See https://msdn.microsoft.com/en-us/library/ms235384.aspx -for more. +foreign import ccall unsafe "HsBase.h _umask" + c_umask :: CMode -> IO CMode -However since we can't hope to get people to support Windows -packages we should support the deprecated names. See #12497 --} -foreign import capi unsafe "unistd.h lseek" - c_lseek :: CInt -> COff -> CInt -> IO COff +-- See Note: Windows types +foreign import capi unsafe "HsBase.h _write" + c_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt -foreign import ccall unsafe "HsBase.h access" +-- See Note: Windows types +foreign import capi safe "HsBase.h _write" + c_safe_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt + +foreign import ccall unsafe "HsBase.h _pipe" + c_pipe :: Ptr CInt -> IO CInt + +foreign import capi unsafe "HsBase.h _lseeki64" + c_lseek :: CInt -> Int64 -> CInt -> IO Int64 + +foreign import capi unsafe "HsBase.h _access" c_access :: CString -> CInt -> IO CInt #if !defined(HAVE_CHMOD) c_chmod :: CString -> CMode -> IO CInt -c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "chmod") +c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "_chmod") #else -foreign import ccall unsafe "HsBase.h chmod" +foreign import ccall unsafe "HsBase.h _chmod" c_chmod :: CString -> CMode -> IO CInt #endif -foreign import ccall unsafe "HsBase.h close" +foreign import capi unsafe "HsBase.h _close" c_close :: CInt -> IO CInt -foreign import ccall unsafe "HsBase.h creat" +foreign import capi unsafe "HsBase.h _creat" c_creat :: CString -> CMode -> IO CInt #if !defined(HAVE_DUP) c_dup :: CInt -> IO CInt -c_dup _ = ioError (ioeSetLocation unsupportedOperation "dup") +c_dup _ = ioError (ioeSetLocation unsupportedOperation "_dup") c_dup2 :: CInt -> CInt -> IO CInt -c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "dup2") +c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "_dup2") #else -foreign import ccall unsafe "HsBase.h dup" +foreign import ccall unsafe "HsBase.h _dup" c_dup :: CInt -> IO CInt -foreign import ccall unsafe "HsBase.h dup2" +foreign import ccall unsafe "HsBase.h _dup2" c_dup2 :: CInt -> CInt -> IO CInt #endif -foreign import ccall unsafe "HsBase.h isatty" +foreign import capi unsafe "HsBase.h _isatty" c_isatty :: CInt -> IO CInt -#if defined(mingw32_HOST_OS) --- See Note: Windows types -foreign import capi unsafe "HsBase.h _read" - c_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt - --- See Note: Windows types -foreign import capi safe "HsBase.h _read" - c_safe_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt - -foreign import ccall unsafe "HsBase.h _umask" - c_umask :: CMode -> IO CMode - --- See Note: Windows types -foreign import capi unsafe "HsBase.h _write" - c_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt +foreign import capi unsafe "HsBase.h _unlink" + c_unlink :: CString -> IO CInt --- See Note: Windows types -foreign import capi safe "HsBase.h _write" - c_safe_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt +foreign import capi unsafe "HsBase.h _utime" + c_utime :: CString -> Ptr CUtimbuf -> IO CInt -foreign import ccall unsafe "HsBase.h _pipe" - c_pipe :: Ptr CInt -> IO CInt +foreign import capi unsafe "HsBase.h _getpid" + c_getpid :: IO CPid #else -- We use CAPI as on some OSs (eg. Linux) this is wrapped by a macro -- which redirects to the 64-bit-off_t versions when large file @@ -700,8 +690,44 @@ c_pipe _ = ioError (ioeSetLocation unsupportedOperation "pipe") foreign import ccall unsafe "HsBase.h pipe" c_pipe :: Ptr CInt -> IO CInt #endif + +foreign import capi unsafe "unistd.h lseek" + c_lseek :: CInt -> COff -> CInt -> IO COff + +foreign import ccall unsafe "HsBase.h access" + c_access :: CString -> CInt -> IO CInt + +#if !defined(HAVE_CHMOD) +c_chmod :: CString -> CMode -> IO CInt +c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "chmod") +#else +foreign import ccall unsafe "HsBase.h chmod" + c_chmod :: CString -> CMode -> IO CInt #endif +foreign import ccall unsafe "HsBase.h close" + c_close :: CInt -> IO CInt + +foreign import ccall unsafe "HsBase.h creat" + c_creat :: CString -> CMode -> IO CInt + +#if !defined(HAVE_DUP) +c_dup :: CInt -> IO CInt +c_dup _ = ioError (ioeSetLocation unsupportedOperation "dup") + +c_dup2 :: CInt -> CInt -> IO CInt +c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "dup2") +#else +foreign import ccall unsafe "HsBase.h dup" + c_dup :: CInt -> IO CInt + +foreign import ccall unsafe "HsBase.h dup2" + c_dup2 :: CInt -> CInt -> IO CInt +#endif + +foreign import ccall unsafe "HsBase.h isatty" + c_isatty :: CInt -> IO CInt + foreign import ccall unsafe "HsBase.h unlink" c_unlink :: CString -> IO CInt @@ -715,6 +741,7 @@ c_getpid = pure 1 foreign import ccall unsafe "HsBase.h getpid" c_getpid :: IO CPid #endif +#endif #if !defined(js_HOST_ARCH) foreign import ccall unsafe "HsBase.h __hscore_stat" ===================================== libraries/base/base.cabal ===================================== @@ -396,7 +396,6 @@ Library if os(windows) -- Windows requires some extra libraries for linking because the RTS -- is no longer re-exporting them. - -- mingwex: provides C99 compatibility. libm is a stub on MingW. -- mingw32: Unfortunately required because of a resource leak between -- mingwex and mingw32. the __math_err symbol is defined in -- mingw32 which is required by mingwex. @@ -409,7 +408,7 @@ Library -- advapi32: provides advanced kernel functions extra-libraries: wsock32, user32, shell32, mingw32, kernel32, advapi32, - mingwex, ws2_32, shlwapi, ole32, rpcrt4, ntdll + ws2_32, shlwapi, ole32, rpcrt4, ntdll -- Minimum supported Windows version. -- These numbers can be found at: -- https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx ===================================== libraries/base/configure.ac ===================================== @@ -39,7 +39,7 @@ AC_CHECK_LIB([rt], [clock_gettime]) AC_CHECK_FUNCS([clock_gettime]) AC_CHECK_DECLS([CLOCK_PROCESS_CPUTIME_ID], [], [], [[#include ]]) AC_CHECK_FUNCS([getclock getrusage times]) -AC_CHECK_FUNCS([_chsize ftruncate]) +AC_CHECK_FUNCS([_chsize_s ftruncate]) # event-related fun # The line below already defines HAVE_KQUEUE and HAVE_POLL, so technically some of the ===================================== libraries/base/include/HsBase.h ===================================== @@ -280,15 +280,12 @@ __hscore_o_nonblock( void ) INLINE int __hscore_ftruncate( int fd, off_t where ) { -#if defined(HAVE_FTRUNCATE) +#if defined(HAVE__CHSIZE_S) + return _chsize_s(fd,where); +#elif defined(HAVE_FTRUNCATE) return ftruncate(fd,where); -#elif defined(HAVE__CHSIZE) - return _chsize(fd,where); #else -// ToDo: we should use _chsize_s() on Windows which allows a 64-bit -// offset, but it doesn't seem to be available from mingw at this time -// --SDM (01/2008) -#error at least ftruncate or _chsize functions are required to build +#error at least _chsize_s or ftruncate functions are required to build #endif } ===================================== libraries/ghc-prim/ghc-prim.cabal ===================================== @@ -66,15 +66,14 @@ Library if os(windows) -- Windows requires some extra libraries for linking because the RTS -- is no longer re-exporting them (see #11223) - -- msvcrt: standard C library. The RTS will automatically include this, - -- but is added for completeness. - -- mingwex: provides C99 compatibility. libm is a stub on MingW. + -- ucrt: standard C library. The RTS will automatically include this, + -- but is added for completeness. -- mingw32: Unfortunately required because of a resource leak between -- mingwex and mingw32. the __math_err symbol is defined in -- mingw32 which is required by mingwex. -- user32: provides access to apis to modify user components (UI etc) -- on Windows. Required because of mingw32. - extra-libraries: user32, mingw32, mingwex, ucrt + extra-libraries: user32, mingw32, ucrt if os(linux) -- we need libm, but for musl and other's we might need libc, as libm ===================================== rts/Linker.c ===================================== @@ -135,7 +135,7 @@ extern void iconv(); This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will never use. This is especially painful on Windows, where the number of - libraries required to link things like mingwex grows to be quite high. + libraries required to link things like QT or WxWidgets grows to be quite high. We proceed through these stages as follows, @@ -193,7 +193,7 @@ extern void iconv(); 1) Dependency chains, if A.o required a .o in libB but A.o isn't required to link then we don't need to load libB. This means the dependency chain for libraries - such as mingw32 and mingwex can be broken down. + such as ucrt can be broken down. 2) The number of duplicate symbols, since now only symbols that are true duplicates will display the error. @@ -226,7 +226,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key, static const char * symbolTypeString (SymType type) { - switch (type) { + switch (type & ~SYM_TYPE_DUP_DISCARD) { case SYM_TYPE_CODE: return "code"; case SYM_TYPE_DATA: return "data"; case SYM_TYPE_INDIRECT_DATA: return "indirect-data"; @@ -275,14 +275,19 @@ int ghciInsertSymbolTable( insertStrHashTable(table, key, pinfo); return 1; } - else if (pinfo->type != type) + else if (pinfo->type ^ type) { - debugBelch("Symbol type mismatch.\n"); - debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", - key, obj_name, symbolTypeString(type)); - debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", - pinfo->owner ? pinfo->owner->fileName : WSTR(""), - symbolTypeString(pinfo->type)); + /* We were asked to discard the symbol on duplicates, do so quietly. */ + if (!(type & SYM_TYPE_DUP_DISCARD)) + { + DebugBreak (); + debugBelch("Symbol type mismatch.\n"); + debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", + key, obj_name, symbolTypeString(type)); + debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", + pinfo->owner ? pinfo->owner->fileName : WSTR(""), + symbolTypeString(pinfo->type)); + } return 1; } else if (pinfo->strength == STRENGTH_STRONG) ===================================== rts/LinkerInternals.h ===================================== @@ -56,9 +56,12 @@ typedef struct _Section Section; /* What kind of thing a symbol identifies. We need to know this to determine how * to process overflowing relocations. See Note [Processing overflowed relocations]. */ typedef enum _SymType { - SYM_TYPE_CODE, /* the symbol is a function and can be relocated via a jump island */ - SYM_TYPE_DATA, /* the symbol is data */ - SYM_TYPE_INDIRECT_DATA, /* see Note [_iob_func symbol] */ + SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */ + SYM_TYPE_DATA = 1 << 1, /* the symbol is data */ + SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */ + SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library + however if a duplicate is found with a mismatching + SymType then discard this one. */ } SymType; ===================================== rts/RtsSymbols.c ===================================== @@ -113,26 +113,6 @@ extern char **environ; * by the RtsSymbols entry. To avoid this we introduce a horrible special case * in `ghciInsertSymbolTable`, ensure that `atexit` is never overridden. */ -/* - * Note [Symbols for MinGW's printf] - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * The printf offered by Microsoft's libc implementation, msvcrt, is quite - * incomplete, lacking support for even %ull. Consequently mingw-w64 offers its - * own implementation which we enable. However, to be thread-safe the - * implementation uses _lock_file. This would be fine except msvcrt.dll doesn't - * export _lock_file, only numbered versions do (e.g. msvcrt90.dll). - * - * To work around this mingw-w64 packages a static archive of msvcrt which - * includes their own implementation of _lock_file. However, this means that - * the archive contains things which the dynamic library does not; consequently - * we need to ensure that the runtime linker provides this symbol. - * - * It's all just so terrible. - * - * See also: - * https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ - * https://sourceforge.net/p/mingw-w64/discussion/723797/thread/55520785/ - */ /* Note [_iob_func symbol] * ~~~~~~~~~~~~~~~~~~~~~~~ * Microsoft in VS2013 to VS2015 transition made a backwards incompatible change @@ -170,12 +150,6 @@ extern char **environ; SymI_NeedsProto(__mingw_module_is_dll) \ RTS_WIN32_ONLY(SymI_NeedsProto(___chkstk_ms)) \ RTS_WIN64_ONLY(SymI_NeedsProto(___chkstk_ms)) \ - RTS_WIN64_ONLY(SymI_HasProto(__stdio_common_vswprintf_s)) \ - RTS_WIN64_ONLY(SymI_HasProto(__stdio_common_vswprintf)) \ - RTS_WIN64_ONLY(SymI_HasProto(_errno)) \ - /* see Note [Symbols for MinGW's printf] */ \ - SymI_HasProto(_lock_file) \ - SymI_HasProto(_unlock_file) \ SymI_HasProto(__mingw_vsnwprintf) \ /* ^^ Need to figure out why this is needed. */ \ /* See Note [_iob_func symbol] */ \ @@ -187,120 +161,8 @@ extern char **environ; /* ^^ 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 \ - SymI_HasProto_deprecated(access) \ - SymI_HasProto_deprecated(cabs) \ - SymI_HasProto_deprecated(cgets) \ - SymI_HasProto_deprecated(chdir) \ - SymI_HasProto_deprecated(chmod) \ - SymI_HasProto_deprecated(chsize) \ - SymI_HasProto_deprecated(close) \ - SymI_HasProto_deprecated(cprintf) \ - SymI_HasProto_deprecated(cputs) \ - SymI_HasProto_deprecated(creat) \ - SymI_HasProto_deprecated(cscanf) \ - SymI_HasProto_deprecated(cwait) \ - SymI_HasProto_deprecated(dup) \ - SymI_HasProto_deprecated(dup2) \ - SymI_HasProto_deprecated(ecvt) \ - SymI_HasProto_deprecated(eof) \ - SymI_HasProto_deprecated(execl) \ - SymI_HasProto_deprecated(execle) \ - SymI_HasProto_deprecated(execlp) \ - SymI_HasProto_deprecated(execlpe) \ - SymI_HasProto_deprecated(execv) \ - SymI_HasProto_deprecated(execve) \ - SymI_HasProto_deprecated(execvp) \ - SymI_HasProto_deprecated(execvpe) \ - SymI_HasProto_deprecated(fcloseall) \ - SymI_HasProto_deprecated(fcvt) \ - SymI_HasProto_deprecated(fdopen) \ - SymI_HasProto_deprecated(fgetchar) \ - SymI_HasProto_deprecated(filelength) \ - SymI_HasProto_deprecated(fileno) \ - SymI_HasProto_deprecated(flushall) \ - SymI_HasProto_deprecated(fputchar) \ - SymI_HasProto_deprecated(gcvt) \ - SymI_HasProto_deprecated(getch) \ - SymI_HasProto_deprecated(getche) \ - SymI_HasProto_deprecated(getcwd) \ - SymI_HasProto_deprecated(getpid) \ - SymI_HasProto_deprecated(getw) \ - SymI_HasProto_deprecated(hypot) \ - SymI_HasProto_deprecated(inp) \ - SymI_HasProto_deprecated(inpw) \ - SymI_HasProto_deprecated(isascii) \ - SymI_HasProto_deprecated(isatty) \ - SymI_HasProto_deprecated(iscsym) \ - SymI_HasProto_deprecated(iscsymf) \ - SymI_HasProto_deprecated(itoa) \ - SymI_HasProto_deprecated(j0) \ - SymI_HasProto_deprecated(j1) \ - SymI_HasProto_deprecated(jn) \ - SymI_HasProto_deprecated(kbhit) \ - SymI_HasProto_deprecated(lfind) \ - SymI_HasProto_deprecated(locking) \ - SymI_HasProto_deprecated(lsearch) \ - SymI_HasProto_deprecated(lseek) \ - SymI_HasProto_deprecated(ltoa) \ - SymI_HasProto_deprecated(memccpy) \ - SymI_HasProto_deprecated(memicmp) \ - SymI_HasProto_deprecated(mkdir) \ - SymI_HasProto_deprecated(mktemp) \ - SymI_HasProto_deprecated(open) \ - SymI_HasProto_deprecated(outp) \ - SymI_HasProto_deprecated(outpw) \ - SymI_HasProto_deprecated(putch) \ - SymI_HasProto_deprecated(putenv) \ - SymI_HasProto_deprecated(putw) \ - SymI_HasProto_deprecated(read) \ - SymI_HasProto_deprecated(rmdir) \ - SymI_HasProto_deprecated(rmtmp) \ - SymI_HasProto_deprecated(setmode) \ - SymI_HasProto_deprecated(sopen) \ - SymI_HasProto_deprecated(spawnl) \ - SymI_HasProto_deprecated(spawnle) \ - SymI_HasProto_deprecated(spawnlp) \ - SymI_HasProto_deprecated(spawnlpe) \ - SymI_HasProto_deprecated(spawnv) \ - SymI_HasProto_deprecated(spawnve) \ - SymI_HasProto_deprecated(spawnvp) \ - SymI_HasProto_deprecated(spawnvpe) \ - SymI_HasProto_deprecated(strcmpi) \ - SymI_HasProto_deprecated(strdup) \ - SymI_HasProto_deprecated(stricmp) \ - SymI_HasProto_deprecated(strlwr) \ - SymI_HasProto_deprecated(strnicmp) \ - SymI_HasProto_deprecated(strnset) \ - SymI_HasProto_deprecated(strrev) \ - SymI_HasProto_deprecated(strset) \ - SymI_HasProto_deprecated(strupr) \ - SymI_HasProto_deprecated(swab) \ - SymI_HasProto_deprecated(tell) \ - SymI_HasProto_deprecated(tempnam) \ - SymI_HasProto_deprecated(toascii) \ - SymI_HasProto_deprecated(tzset) \ - SymI_HasProto_deprecated(ultoa) \ - SymI_HasProto_deprecated(umask) \ - SymI_HasProto_deprecated(ungetch) \ - SymI_HasProto_deprecated(unlink) \ - SymI_HasProto_deprecated(wcsdup) \ - SymI_HasProto_deprecated(wcsicmp) \ - SymI_HasProto_deprecated(wcsicoll) \ - SymI_HasProto_deprecated(wcslwr) \ - SymI_HasProto_deprecated(wcsnicmp) \ - SymI_HasProto_deprecated(wcsnset) \ - SymI_HasProto_deprecated(wcsrev) \ - SymI_HasProto_deprecated(wcsset) \ - SymI_HasProto_deprecated(wcsupr) \ - SymI_HasProto_deprecated(write) \ - SymI_HasProto_deprecated(y0) \ - SymI_HasProto_deprecated(y1) \ - SymI_HasProto_deprecated(yn) #else #define RTS_MINGW_ONLY_SYMBOLS /**/ -#define RTS_MINGW_COMPAT_SYMBOLS /**/ #endif @@ -1181,7 +1043,6 @@ RtsSymbolVal rtsSyms[] = { RTS_RET_SYMBOLS RTS_POSIX_ONLY_SYMBOLS RTS_MINGW_ONLY_SYMBOLS - RTS_MINGW_COMPAT_SYMBOLS RTS_DARWIN_ONLY_SYMBOLS RTS_OPENBSD_ONLY_SYMBOLS RTS_LIBGCC_SYMBOLS ===================================== rts/linker/PEi386.c ===================================== @@ -261,6 +261,54 @@ .asciiz "libfoo_data" + Note [GHC Linking model and import libraries] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The above describes how import libraries work for static linking. + Fundamentally this does not apply to dynamic linking as we do in GHC. + The issue is two-folds: + + 1. In the linking model above it is expected that the .idata sections be + materialized into PLTs during linking. However in GHC we never create + PLTs, but have out own mechanism for this which is the jump island + machinery. This is required for efficiency. For one materializing the + .idata sections would result in wasting pages. We'd use one page for + every ~100 bytes. This is extremely wasteful and also fragments the + memory. Secondly the dynamic linker is lazy. We only perform the final + loading if the symbol is used, however with an import library we can + discard the actual OC immediately after reading it. This prevents us from + keeping ~1k in memory per symbol for no reason. + + 2. GHC itself does not observe symbol visibility correctly during NGC. This + in itself isn't an academic exercise. The issue stems from GHC using one + mechanism for providing two incompatible linking modes: + a) The first mode is generating Haskell shared libraries which are + intended to be used by other Haskell code. This requires us to + export the info, data and closures. For this GHC just re-exports + all symbols. But it doesn't correcly mark data/code. Symbol + visibility is overwritten by telling the linker to export all + symbols. + b) The second code is producing code that's supposed to be call-able + through a C insterface. This in reality does not require the + export of closures and info tables. But also does not require the + inclusion of the RTS inside the DLL. Hover this is done today + because we don't properly have the RTS as a dynamic library. + i.e. GHC does not only export symbols denoted by foreign export. + Also GHC should depend on an RTS library, but at the moment it + cannot because of TNTC is incompatible with dynamic linking. + + These two issues mean that for GHC we need to take a different approach + to handling import libraries. For normal C libraries we have proper + differentiation between CODE and DATA. For GHC produced import libraries + we do not. As such the SYM_TYPE_DUP_DISCARD tells the linker that if a + duplicate symbol is found, and we were going to discard it anyway, just do + so quitely. This works because the RTS symbols themselves are provided by + the currently loaded RTS as built-in symbols. + + Secondly we cannot rely on a text symbol being available. As such we + should only depend on the symbols as defined in the .idata sections, + otherwise we would not be able to correctly link against GHC produced + import libraries. + Note [Memory allocation] ~~~~~~~~~~~~~~~~~~~~~~~~ The loading of an object begins in `preloadObjectFile`, which allocates a buffer, @@ -1658,7 +1706,10 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if ( secNumber != IMAGE_SYM_UNDEFINED && secNumber > 0 && section - && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY) { + /* Skip all BFD import sections. */ + && section->kind != SECTIONKIND_IMPORT + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY_HEAD) { /* This symbol is global and defined, viz, exported */ /* for IMAGE_SYMCLASS_EXTERNAL && !IMAGE_SYM_UNDEFINED, @@ -1691,12 +1742,49 @@ ocGetNames_PEi386 ( ObjectCode* oc ) IF_DEBUG(linker_verbose, debugBelch("bss symbol @ %p %u\n", addr, symValue)); } else if (section && section->kind == SECTIONKIND_BFD_IMPORT_LIBRARY) { - setImportSymbol(oc, sname); + /* Disassembly of section .idata$5: + + 0000000000000000 <__imp_Insert>: + ... + 0: IMAGE_REL_AMD64_ADDR32NB .idata$6 + + The first two bytes contain the ordinal of the function + in the format of lowpart highpart. The two bytes combined + for the total range of 16 bits which is the function export limit + of DLLs. See note [GHC Linking model and import libraries]. */ + sname = (SymbolName*)section->start+2; + COFF_symbol* sym = &oc->info->symbols[info->numberOfSymbols-1]; + addr = get_sym_name( getSymShortName (info, sym), oc); + + IF_DEBUG(linker, + debugBelch("addImportSymbol `%s' => `%s'\n", + sname, (char*)addr)); + /* We're going to free the any data associated with the import + library without copying the sections. So we have to duplicate + the symbol name and values before the pointers become invalid. */ + sname = strdup (sname); + addr = strdup (addr); + type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA; + type |= SYM_TYPE_DUP_DISCARD; + if (!ghciInsertSymbolTable(oc->fileName, symhash, sname, + addr, false, type, oc)) { + releaseOcInfo (oc); + stgFree (oc->image); + oc->image = NULL; + return false; + } + setImportSymbol (oc, sname); + + /* Don't process this oc any further. Just exit. */ + oc->n_symbols = 0; + oc->symbols = NULL; + stgFree (oc->image); + oc->image = NULL; + releaseOcInfo (oc); // There is nothing that we need to resolve in this object since we // will never call the import stubs in its text section oc->status = OBJECT_DONT_RESOLVE; - - IF_DEBUG(linker_verbose, debugBelch("import symbol %s\n", sname)); + return true; } else if (secNumber > 0 && section ===================================== rts/package.conf.in ===================================== @@ -54,11 +54,6 @@ extra-libraries: #if defined(DEBUG) && defined(HAVE_LIBBFD) ,"bfd", "iberty" /* for debugging */ #endif -#if defined(HAVE_LIBMINGWEX) -# if !defined(INSTALLING) /* Bundled Mingw is behind */ - ,"mingwex" -# endif -#endif #if USE_LIBDW , "elf" , "dw" /* for backtraces */ ===================================== rts/rts.cabal.in ===================================== @@ -24,8 +24,6 @@ flag need-pthread default: @CabalNeedLibpthread@ flag libbfd default: @CabalHaveLibbfd@ -flag mingwex - default: @CabalMingwex@ flag need-atomic default: @CabalNeedLibatomic@ flag libdw @@ -68,7 +66,6 @@ library exposed: True exposed-modules: - if os(ghcjs) include-dirs: include @@ -194,8 +191,6 @@ library if flag(libbfd) -- for debugging extra-libraries: bfd iberty - if flag(mingwex) - extra-libraries: mingwex if flag(libdw) -- for backtraces extra-libraries: elf dw ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -88,10 +88,6 @@ compile_libAB_dyn: .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: - rm -rf bin_impl_gcc - mkdir bin_impl_gcc - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_impl_gcc" -shared A.c -o "bin_impl_gcc/$(call DLL,ASimpL)" - mv bin_impl_gcc/libASimpL.dll.a bin_impl_gcc/libASx.dll.a echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T11072.hs -lASx -L./bin_impl_gcc .PHONY: compile_libAS_impl_msvc ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -41,9 +41,9 @@ test('T10458', extra_hc_opts('-L"$PWD/T10458dir" -lAS')], ghci_script, ['T10458.script']) -test('T11072gcc', [extra_files(['A.c', 'T11072.hs']), - expect_broken(18718), - unless(doing_ghci, skip), unless(opsys('mingw32'), skip)], +test('T11072gcc', [extra_files(['A.c', 'T11072.hs', 'bin_impl_gcc/']), + unless(doing_ghci, skip), unless(opsys('mingw32'), skip), + unless(arch('x86_64'), skip)], makefile_test, ['compile_libAS_impl_gcc']) test('T11072msvc', [extra_files(['A.c', 'T11072.hs', 'libAS.def', 'i686/', 'x86_64/']), ===================================== testsuite/tests/ghci/linking/dyn/bin_impl_gcc/ASimpL.dll ===================================== Binary files /dev/null and b/testsuite/tests/ghci/linking/dyn/bin_impl_gcc/ASimpL.dll differ ===================================== testsuite/tests/ghci/linking/dyn/bin_impl_gcc/libASx.dll.a ===================================== Binary files /dev/null and b/testsuite/tests/ghci/linking/dyn/bin_impl_gcc/libASx.dll.a differ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3703b7b56b9e48b0b65b4a3ba9c2f0006c406ef8...ace45702dcd782ed3ff6e43dab882e36a9b94f9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3703b7b56b9e48b0b65b4a3ba9c2f0006c406ef8...ace45702dcd782ed3ff6e43dab882e36a9b94f9a You're receiving 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 Dec 4 18:11:45 2022 From: gitlab at gitlab.haskell.org (Tamar Christina (@Phyx)) Date: Sun, 04 Dec 2022 13:11:45 -0500 Subject: [Git][ghc/ghc][wip/T22166] linker: Fix BFD import libraries Message-ID: <638ce2e11c132_17512e240afea010191dc@gitlab.mail> Tamar Christina pushed to branch wip/T22166 at Glasgow Haskell Compiler / GHC Commits: 457427c7 by Tamar Christina at 2022-12-04T18:11:23+00:00 linker: Fix BFD import libraries - - - - - 8 changed files: - hadrian/src/Settings/Packages.hs - rts/Linker.c - rts/LinkerInternals.h - rts/linker/PEi386.c - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/ghci/linking/dyn/all.T - + testsuite/tests/ghci/linking/dyn/bin_impl_gcc/ASimpL.dll - + testsuite/tests/ghci/linking/dyn/bin_impl_gcc/libASx.dll.a Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -403,7 +403,7 @@ rtsPackageArgs = package rts ? do , builder HsCpp ? pure [ "-DTOP=" ++ show top ] - , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" + , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" ] -- Compile various performance-critical pieces *without* -fPIC -dynamic -- even when building a shared library. If we don't do this, then the ===================================== rts/Linker.c ===================================== @@ -135,8 +135,7 @@ extern void iconv(); This is to enable lazy loading of symbols. Eager loading is problematic as it means that all symbols must be available, even those which we will never use. This is especially painful on Windows, where the number of - libraries required to link things like mingwex (TODO: We no longer depend - on mingwex, so think of a different example here) grows to be quite high. + libraries required to link things like QT or WxWidgets grows to be quite high. We proceed through these stages as follows, @@ -194,8 +193,7 @@ extern void iconv(); 1) Dependency chains, if A.o required a .o in libB but A.o isn't required to link then we don't need to load libB. This means the dependency chain for libraries - such as mingw32 and mingwex (TODO: We no longer depend on mingwex, so think of - a different example here) can be broken down. + such as ucrt can be broken down. 2) The number of duplicate symbols, since now only symbols that are true duplicates will display the error. @@ -228,7 +226,7 @@ static void ghciRemoveSymbolTable(StrHashTable *table, const SymbolName* key, static const char * symbolTypeString (SymType type) { - switch (type) { + switch (type & ~SYM_TYPE_DUP_DISCARD) { case SYM_TYPE_CODE: return "code"; case SYM_TYPE_DATA: return "data"; case SYM_TYPE_INDIRECT_DATA: return "indirect-data"; @@ -277,14 +275,18 @@ int ghciInsertSymbolTable( insertStrHashTable(table, key, pinfo); return 1; } - else if (pinfo->type != type) + else if (pinfo->type ^ type) { - debugBelch("Symbol type mismatch.\n"); - debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", - key, obj_name, symbolTypeString(type)); - debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", - pinfo->owner ? pinfo->owner->fileName : WSTR(""), - symbolTypeString(pinfo->type)); + /* We were asked to discard the symbol on duplicates, do so quietly. */ + if (!(type & SYM_TYPE_DUP_DISCARD)) + { + debugBelch("Symbol type mismatch.\n"); + debugBelch("Symbol %s was defined by %" PATH_FMT " to be a %s symbol.\n", + key, obj_name, symbolTypeString(type)); + debugBelch(" yet was defined by %" PATH_FMT " to be a %s symbol.\n", + pinfo->owner ? pinfo->owner->fileName : WSTR(""), + symbolTypeString(pinfo->type)); + } return 1; } else if (pinfo->strength == STRENGTH_STRONG) ===================================== rts/LinkerInternals.h ===================================== @@ -56,9 +56,12 @@ typedef struct _Section Section; /* What kind of thing a symbol identifies. We need to know this to determine how * to process overflowing relocations. See Note [Processing overflowed relocations]. */ typedef enum _SymType { - SYM_TYPE_CODE, /* the symbol is a function and can be relocated via a jump island */ - SYM_TYPE_DATA, /* the symbol is data */ - SYM_TYPE_INDIRECT_DATA, /* see Note [_iob_func symbol] */ + SYM_TYPE_CODE = 1 << 0, /* the symbol is a function and can be relocated via a jump island */ + SYM_TYPE_DATA = 1 << 1, /* the symbol is data */ + SYM_TYPE_INDIRECT_DATA = 1 << 2, /* see Note [_iob_func symbol] */ + SYM_TYPE_DUP_DISCARD = 1 << 3, /* the symbol is a symbol in a BFD import library + however if a duplicate is found with a mismatching + SymType then discard this one. */ } SymType; ===================================== rts/linker/PEi386.c ===================================== @@ -261,6 +261,54 @@ .asciiz "libfoo_data" + Note [GHC Linking model and import libraries] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + The above describes how import libraries work for static linking. + Fundamentally this does not apply to dynamic linking as we do in GHC. + The issue is two-folds: + + 1. In the linking model above it is expected that the .idata sections be + materialized into PLTs during linking. However in GHC we never create + PLTs, but have out own mechanism for this which is the jump island + machinery. This is required for efficiency. For one materializing the + .idata sections would result in wasting pages. We'd use one page for + every ~100 bytes. This is extremely wasteful and also fragments the + memory. Secondly the dynamic linker is lazy. We only perform the final + loading if the symbol is used, however with an import library we can + discard the actual OC immediately after reading it. This prevents us from + keeping ~1k in memory per symbol for no reason. + + 2. GHC itself does not observe symbol visibility correctly during NGC. This + in itself isn't an academic exercise. The issue stems from GHC using one + mechanism for providing two incompatible linking modes: + a) The first mode is generating Haskell shared libraries which are + intended to be used by other Haskell code. This requires us to + export the info, data and closures. For this GHC just re-exports + all symbols. But it doesn't correcly mark data/code. Symbol + visibility is overwritten by telling the linker to export all + symbols. + b) The second code is producing code that's supposed to be call-able + through a C insterface. This in reality does not require the + export of closures and info tables. But also does not require the + inclusion of the RTS inside the DLL. Hover this is done today + because we don't properly have the RTS as a dynamic library. + i.e. GHC does not only export symbols denoted by foreign export. + Also GHC should depend on an RTS library, but at the moment it + cannot because of TNTC is incompatible with dynamic linking. + + These two issues mean that for GHC we need to take a different approach + to handling import libraries. For normal C libraries we have proper + differentiation between CODE and DATA. For GHC produced import libraries + we do not. As such the SYM_TYPE_DUP_DISCARD tells the linker that if a + duplicate symbol is found, and we were going to discard it anyway, just do + so quitely. This works because the RTS symbols themselves are provided by + the currently loaded RTS as built-in symbols. + + Secondly we cannot rely on a text symbol being available. As such we + should only depend on the symbols as defined in the .idata sections, + otherwise we would not be able to correctly link against GHC produced + import libraries. + Note [Memory allocation] ~~~~~~~~~~~~~~~~~~~~~~~~ The loading of an object begins in `preloadObjectFile`, which allocates a buffer, @@ -1658,7 +1706,10 @@ ocGetNames_PEi386 ( ObjectCode* oc ) if ( secNumber != IMAGE_SYM_UNDEFINED && secNumber > 0 && section - && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY) { + /* Skip all BFD import sections. */ + && section->kind != SECTIONKIND_IMPORT + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY + && section->kind != SECTIONKIND_BFD_IMPORT_LIBRARY_HEAD) { /* This symbol is global and defined, viz, exported */ /* for IMAGE_SYMCLASS_EXTERNAL && !IMAGE_SYM_UNDEFINED, @@ -1691,12 +1742,49 @@ ocGetNames_PEi386 ( ObjectCode* oc ) IF_DEBUG(linker_verbose, debugBelch("bss symbol @ %p %u\n", addr, symValue)); } else if (section && section->kind == SECTIONKIND_BFD_IMPORT_LIBRARY) { - setImportSymbol(oc, sname); + /* Disassembly of section .idata$5: + + 0000000000000000 <__imp_Insert>: + ... + 0: IMAGE_REL_AMD64_ADDR32NB .idata$6 + + The first two bytes contain the ordinal of the function + in the format of lowpart highpart. The two bytes combined + for the total range of 16 bits which is the function export limit + of DLLs. See note [GHC Linking model and import libraries]. */ + sname = (SymbolName*)section->start+2; + COFF_symbol* sym = &oc->info->symbols[info->numberOfSymbols-1]; + addr = get_sym_name( getSymShortName (info, sym), oc); + + IF_DEBUG(linker, + debugBelch("addImportSymbol `%s' => `%s'\n", + sname, (char*)addr)); + /* We're going to free the any data associated with the import + library without copying the sections. So we have to duplicate + the symbol name and values before the pointers become invalid. */ + sname = strdup (sname); + addr = strdup (addr); + type = has_code_section ? SYM_TYPE_CODE : SYM_TYPE_DATA; + type |= SYM_TYPE_DUP_DISCARD; + if (!ghciInsertSymbolTable(oc->fileName, symhash, sname, + addr, false, type, oc)) { + releaseOcInfo (oc); + stgFree (oc->image); + oc->image = NULL; + return false; + } + setImportSymbol (oc, sname); + + /* Don't process this oc any further. Just exit. */ + oc->n_symbols = 0; + oc->symbols = NULL; + stgFree (oc->image); + oc->image = NULL; + releaseOcInfo (oc); // There is nothing that we need to resolve in this object since we // will never call the import stubs in its text section oc->status = OBJECT_DONT_RESOLVE; - - IF_DEBUG(linker_verbose, debugBelch("import symbol %s\n", sname)); + return true; } else if (secNumber > 0 && section ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -88,10 +88,6 @@ compile_libAB_dyn: .PHONY: compile_libAS_impl_gcc compile_libAS_impl_gcc: - rm -rf bin_impl_gcc - mkdir bin_impl_gcc - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_impl_gcc" -shared A.c -o "bin_impl_gcc/$(call DLL,ASimpL)" - mv bin_impl_gcc/libASimpL.dll.a bin_impl_gcc/libASx.dll.a echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) T11072.hs -lASx -L./bin_impl_gcc .PHONY: compile_libAS_impl_msvc ===================================== testsuite/tests/ghci/linking/dyn/all.T ===================================== @@ -41,9 +41,9 @@ test('T10458', extra_hc_opts('-L"$PWD/T10458dir" -lAS')], ghci_script, ['T10458.script']) -test('T11072gcc', [extra_files(['A.c', 'T11072.hs']), - expect_broken(18718), - unless(doing_ghci, skip), unless(opsys('mingw32'), skip)], +test('T11072gcc', [extra_files(['A.c', 'T11072.hs', 'bin_impl_gcc/']), + unless(doing_ghci, skip), unless(opsys('mingw32'), skip), + unless(arch('x86_64'), skip)], makefile_test, ['compile_libAS_impl_gcc']) test('T11072msvc', [extra_files(['A.c', 'T11072.hs', 'libAS.def', 'i686/', 'x86_64/']), ===================================== testsuite/tests/ghci/linking/dyn/bin_impl_gcc/ASimpL.dll ===================================== Binary files /dev/null and b/testsuite/tests/ghci/linking/dyn/bin_impl_gcc/ASimpL.dll differ ===================================== testsuite/tests/ghci/linking/dyn/bin_impl_gcc/libASx.dll.a ===================================== Binary files /dev/null and b/testsuite/tests/ghci/linking/dyn/bin_impl_gcc/libASx.dll.a differ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/457427c7b95fe6daf18f351a891515cd21b091a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/457427c7b95fe6daf18f351a891515cd21b091a9 You're receiving 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 Dec 4 18:15:23 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sun, 04 Dec 2022 13:15:23 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/hdk-register-tok Message-ID: <638ce3bb1b515_17512e1e46a9d810198d0@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/hdk-register-tok at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/hdk-register-tok You're receiving 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 Dec 4 19:06:58 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sun, 04 Dec 2022 14:06:58 -0500 Subject: [Git][ghc/ghc][wip/T22264] 35 commits: rts: Drop SM spinlock Message-ID: <638cefd29f025_17512e4d4b8e101025427@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC Commits: be9950df by Ben Gamari at 2022-11-19T20:24:58-05:00 rts: Drop SM spinlock - - - - - 8b8cd0fe by Ben Gamari at 2022-11-23T19:41:35-05:00 Various - - - - - 562dd80c by Ben Gamari at 2022-11-23T19:41:43-05:00 Take SM mutex in setNumCapabilities - - - - - 4b023123 by Ben Gamari at 2022-11-23T19:42:02-05:00 setRecentActivities - - - - - 68b4a6ab by Ben Gamari at 2022-11-23T19:42:13-05:00 Fix type issues in Sparks.h - - - - - f205a5d3 by Ben Gamari at 2022-11-23T19:42:56-05:00 locking - - - - - 07134f76 by Ben Gamari at 2022-11-23T19:43:20-05:00 Various - - - - - 2b6f9bd4 by Ben Gamari at 2022-11-23T19:43:48-05:00 C++ typing issues - - - - - dfa7f23d by Ben Gamari at 2022-11-23T19:44:18-05:00 Sanity: Look at nonmoving saved_filled lists - - - - - 6b911ba7 by Ben Gamari at 2022-11-23T19:44:39-05:00 CheckGC - - - - - a0111bbd by Ben Gamari at 2022-11-23T21:25:32-05:00 CheckGc: Refactor - - - - - da615ef3 by Ben Gamari at 2022-11-23T22:36:16-05:00 Fix it - - - - - 7850a894 by Ben Gamari at 2022-11-25T14:00:28-05:00 check-gc - - - - - be510990 by Ben Gamari at 2022-11-25T17:48:25-05:00 Check gc - - - - - cff00edb by Ben Gamari at 2022-11-25T18:52:46-05:00 Check Gc - - - - - c25eb12f by Ben Gamari at 2022-11-25T18:52:56-05:00 locking - - - - - 0ad4d2fb by Ben Gamari at 2022-11-25T20:09:30-05:00 Locking - - - - - 230d8760 by Ben Gamari at 2022-11-26T21:27:12-05:00 locking - - - - - da5bdfb6 by Ben Gamari at 2022-11-26T21:27:29-05:00 Check GC - - - - - 4dcea2c5 by Ben Gamari at 2022-11-26T21:27:46-05:00 Locking - - - - - 6ed7e21a by Ben Gamari at 2022-11-26T21:28:08-05:00 Locking - - - - - 0c097193 by Ben Gamari at 2022-11-26T21:28:20-05:00 FIX THE DAMN THING - - - - - cac0caeb by Ben Gamari at 2022-11-29T23:09:48-05:00 Evac: Squash data race in eval_selector_chain - - - - - 9fe222a6 by Ben Gamari at 2022-11-29T23:11:01-05:00 nonmoving: Paranoia - - - - - a2daf6bf by Ben Gamari at 2022-11-29T23:11:26-05:00 nonmoving: Fix weaks - - - - - 5fef104b by Ben Gamari at 2022-11-30T15:43:05-05:00 nonmoving: Fix selectors - - - - - f0161e29 by Ben Gamari at 2022-11-30T15:43:36-05:00 nonmoving: Avoid n_caps race - - - - - 3f4f06e4 by Ben Gamari at 2022-11-30T15:44:16-05:00 nonmoving: Paranoia - - - - - 571ac83f by Ben Gamari at 2022-11-30T15:44:41-05:00 nonmoving: Assert weak pointer consistency - - - - - b56776c3 by Ben Gamari at 2022-12-02T17:03:56-05:00 CheckGc: Distinguish tagged pointers - - - - - 4b2dfabe by Ben Gamari at 2022-12-02T17:04:19-05:00 CheckGc: Flush - - - - - d382a58c by Ben Gamari at 2022-12-02T17:04:48-05:00 rts/gc: Add missing write barriers in selector optimisation - - - - - 4f45b245 by Ben Gamari at 2022-12-02T17:06:42-05:00 CheckGc: Add missing SRT - - - - - fb45fba5 by Ben Gamari at 2022-12-02T17:21:32-05:00 CheckGc: Factor out constructor, fun, thunk traversal - - - - - f095454b by Ben Gamari at 2022-12-02T17:50:04-05:00 CheckGc: More sanity checking - - - - - 26 changed files: - rts/Capability.h - rts/CheckUnload.c - rts/Proftimer.c - rts/Schedule.h - rts/Sparks.h - rts/Stats.c - rts/Trace.h - rts/include/rts/storage/MBlock.h - rts/rts.cabal.in - rts/sm/BlockAlloc.c - + rts/sm/CheckGc.cpp - rts/sm/Evac.c - rts/sm/GC.c - rts/sm/GC.h - rts/sm/GCUtils.c - rts/sm/GCUtils.h - rts/sm/HeapAlloc.h - rts/sm/MarkStack.h - rts/sm/NonMoving.c - rts/sm/NonMovingMark.c - rts/sm/NonMovingMark.h - rts/sm/NonMovingShortcut.c - rts/sm/Sanity.c - rts/sm/Sanity.h - rts/sm/Scav.c - rts/sm/Storage.c Changes: ===================================== rts/Capability.h ===================================== @@ -20,10 +20,10 @@ #pragma once -#include "sm/GC.h" // for evac_fn #include "Task.h" #include "Sparks.h" -#include "sm/NonMovingMark.h" // for MarkQueue +#include "sm/GC.h" // for evac_fn +#include "sm/NonMovingMark.h" // for UpdRemSet #include "BeginPrivate.h" ===================================== rts/CheckUnload.c ===================================== @@ -15,6 +15,7 @@ #include "Hash.h" #include "LinkerInternals.h" #include "CheckUnload.h" +#include "sm/HeapAlloc.h" #include "sm/Storage.h" #include "sm/GCThread.h" #include "sm/HeapUtils.h" ===================================== rts/Proftimer.c ===================================== @@ -123,7 +123,7 @@ handleProfTick(void) if (RELAXED_LOAD_ALWAYS(&do_prof_ticks)) { uint32_t n; for (n=0; n < getNumCapabilities(); n++) { - Capability *cap = getCapbility(n); + Capability *cap = getCapability(n); cap->r.rCCCS->time_ticks++; traceProfSampleCostCentre(cap, cap->r.rCCCS, total_ticks); } ===================================== rts/Schedule.h ===================================== @@ -132,7 +132,7 @@ setRecentActivity(enum RecentActivity new_value) INLINE_HEADER enum RecentActivity getRecentActivity(void) { - return RELAXED_LOAD_ALWAYS(&recent_activity); + return (enum RecentActivity) RELAXED_LOAD_ALWAYS(&recent_activity); } /* Thread queues. ===================================== rts/Sparks.h ===================================== @@ -8,6 +8,7 @@ #pragma once +#include "sm/GC.h" // for evac_fn #include "WSDeque.h" #include "BeginPrivate.h" @@ -56,7 +57,7 @@ INLINE_HEADER long sparkPoolSize (SparkPool *pool); INLINE_HEADER StgClosure* reclaimSpark(SparkPool *pool) { - return popWSDeque(pool); + return (StgClosure*) popWSDeque(pool); } INLINE_HEADER bool looksEmpty(SparkPool* deque) @@ -89,7 +90,7 @@ INLINE_HEADER void discardSparks (SparkPool *pool) INLINE_HEADER StgClosure * tryStealSpark (SparkPool *pool) { - return stealWSDeque_(pool); + return (StgClosure *) stealWSDeque_(pool); // use the no-loopy version, stealWSDeque_(), since if we get a // spurious NULL here the caller may want to try stealing from // other pools before trying again. ===================================== rts/Stats.c ===================================== @@ -963,11 +963,6 @@ static void report_summary(const RTSSummaryStats* sum) , col_width[1], "SpinLock" , col_width[2], "Spins" , col_width[3], "Yields"); - statsPrintf("%*s" "%*s" "%*" FMT_Word64 "%*" FMT_Word64 "\n" - , col_width[0], "" - , col_width[1], "gc_alloc_block_sync" - , col_width[2], gc_alloc_block_sync.spin - , col_width[3], gc_alloc_block_sync.yield); statsPrintf("%*s" "%*s" "%*" FMT_Word64 "%*s\n" , col_width[0], "" , col_width[1], "whitehole_gc" @@ -1142,10 +1137,6 @@ static void report_machine_readable (const RTSSummaryStats * sum) // next, internal counters #if defined(PROF_SPIN) - MR_STAT("gc_alloc_block_sync_spin", FMT_Word64, gc_alloc_block_sync.spin); - MR_STAT("gc_alloc_block_sync_yield", FMT_Word64, - gc_alloc_block_sync.yield); - MR_STAT("gc_alloc_block_sync_spin", FMT_Word64, gc_alloc_block_sync.spin); MR_STAT("waitForGcThreads_spin", FMT_Word64, waitForGcThreads_spin); MR_STAT("waitForGcThreads_yield", FMT_Word64, waitForGcThreads_yield); @@ -1572,9 +1563,6 @@ SpinLock: Not all of these are actual SpinLocks, see the details below. Actual SpinLocks: -* gc_alloc_block: - This SpinLock protects the block allocator and free list manager. See - BlockAlloc.c. * gen[g].sync: These SpinLocks, one per generation, protect the generations[g] data structure during garbage collection. ===================================== rts/Trace.h ===================================== @@ -33,7 +33,9 @@ void tracingAddCapapilities (uint32_t from, uint32_t to); #endif /* TRACING */ typedef StgWord32 CapsetID; +#if !defined(__cplusplus) typedef StgWord16 CapsetType; +#endif enum CapsetType { CapsetTypeCustom = CAPSET_TYPE_CUSTOM, CapsetTypeOsProcess = CAPSET_TYPE_OSPROCESS, CapsetTypeClockdomain = CAPSET_TYPE_CLOCKDOMAIN }; ===================================== rts/include/rts/storage/MBlock.h ===================================== @@ -26,7 +26,3 @@ extern void freeAllMBlocks(void); extern void *getFirstMBlock(void **state); extern void *getNextMBlock(void **state, void *mblock); -#if defined(THREADED_RTS) -// needed for HEAP_ALLOCED below -extern SpinLock gc_alloc_block_sync; -#endif ===================================== rts/rts.cabal.in ===================================== @@ -448,6 +448,9 @@ library -- AutoApply is generated AutoApply.cmm + -- Debugging + c-sources: sm/CheckGc.cpp + -- Adjustor stuff if flag(libffi-adjustors) c-sources: adjustor/LibffiAdjustor.c ===================================== rts/sm/BlockAlloc.c ===================================== @@ -438,6 +438,7 @@ alloc_mega_group (uint32_t node, StgWord mblocks) bdescr *best, *bd; StgWord n; + ASSERT_SM_LOCK(); n = MBLOCK_GROUP_BLOCKS(mblocks); if(defer_mblock_frees) @@ -496,6 +497,7 @@ allocGroupOnNode (uint32_t node, W_ n) bdescr *bd, *rem; StgWord ln; + ASSERT_SM_LOCK(); if (n == 0) barf("allocGroup: requested zero blocks"); if (n >= BLOCKS_PER_MBLOCK) @@ -709,6 +711,7 @@ bdescr* allocLargeChunkOnNode (uint32_t node, W_ min, W_ max) { bdescr *bd; StgWord ln, lnmax; + ASSERT_SM_LOCK(); if (min >= BLOCKS_PER_MBLOCK) { return allocGroupOnNode(node,max); @@ -933,8 +936,7 @@ freeGroup(bdescr *p) StgWord ln; uint32_t node; - // not true in multithreaded GC: - // ASSERT_SM_LOCK(); + ASSERT_SM_LOCK(); ASSERT(RELAXED_LOAD(&p->free) != (P_)-1); ===================================== rts/sm/CheckGc.cpp ===================================== @@ -0,0 +1,973 @@ +extern "C" { +#include "Rts.h" +#include "StableName.h" /* for FOR_EACH_STABLE_NAME */ +#include "StablePtr.h" /* for markStablePtrTable */ +#include "Schedule.h" /* for markScheduler */ +#include "Capability.h" +#include "HeapAlloc.h" +#include "STM.h" +} + +#include +#include +#include +#include +#include +#include + +class TaggedClosurePtr { + StgClosure *ptr; +public: + TaggedClosurePtr(StgClosure* ptr) : ptr(ptr) {} + TaggedClosurePtr(StgClosure* ptr, uint8_t tag) : TaggedClosurePtr(TAG_CLOSURE(tag, ptr)) {} + + StgClosure *get_tagged() const { + return ptr; + } + StgClosure *untag() const { + return UNTAG_CLOSURE(ptr); + } + uint8_t get_tag() const { + return (StgWord) ptr & TAG_MASK; + } + + //inline StgClosure& operator->() { return *untag(); } + + friend inline bool operator==(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { + return lhs.ptr == rhs.ptr; + } + friend inline bool operator!=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs == rhs); } + friend inline bool operator< (const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { + return lhs.ptr < rhs.ptr; + } + friend inline bool operator> (const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return rhs < lhs; } + friend inline bool operator<=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs > rhs); } + friend inline bool operator>=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs < rhs); } +}; + +template<> +struct std::hash { + std::size_t operator()(TaggedClosurePtr const& p) const noexcept { + return std::hash{}(p.get_tagged()); + } +}; + +class HeapVisitor { +public: + // Visit an SRT + virtual void visit_srt(StgClosure* c); + + // Visit a normal closure + virtual void visit_closure(TaggedClosurePtr c); + + virtual void visit_thunk(StgThunk *thunk, size_t n_ptrs); + virtual void visit_fun(StgClosure *constr, size_t n_ptrs); + virtual void visit_constr(StgClosure *constr, size_t n_ptrs); + virtual void visit_array(StgMutArrPtrs *arr); + virtual void visit_small_array(StgSmallMutArrPtrs *arr); + virtual void visit_bytearray(StgArrBytes* arr); + + virtual void visit_stack(StgPtr sp, StgPtr end); + virtual void visit_tso(StgTSO* tso); + virtual void visit_weak(StgWeak* w); + virtual void visit_mvar(StgMVar* mvar); + virtual void visit_tvar(StgTVar* tvar); + virtual void visit_trec_header(StgTRecHeader *trec); + virtual void visit_trec_chunk(StgTRecChunk* tc); + virtual void visit_continuation(StgContinuation* tc); + + virtual void visit_small_bitmap(StgClosure *const *payload, StgWord bitmap, StgWord size); + virtual void visit_large_bitmap(StgClosure *const *payload, const StgLargeBitmap *bitmap, StgWord size); + void visit_pap_payload(StgClosure *fun, StgClosure **payload, StgWord n_args); + + virtual void visit_invalid(StgClosure *const c); +}; + +void HeapVisitor::visit_thunk(StgThunk *thunk, size_t n_ptrs) +{ + const StgInfoTable *info = get_itbl((StgClosure *) thunk); + const StgThunkInfoTable *thunk_info = itbl_to_thunk_itbl(info); + if (thunk_info->i.srt) { + StgClosure *srt = (StgClosure*) GET_SRT(thunk_info); + visit_srt(srt); + }; + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(thunk->payload[i]); + } +} + +void HeapVisitor::visit_fun(StgClosure *fun, size_t n_ptrs) +{ + const StgInfoTable *info = get_itbl(fun); + const StgFunInfoTable *fun_info = itbl_to_fun_itbl(info); + if (fun_info->i.srt) { + StgClosure *srt = (StgClosure*) GET_SRT(fun_info); + visit_srt(srt); + }; + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(fun->payload[i]); + } +} + +void HeapVisitor::visit_constr(StgClosure *constr, size_t n_ptrs) +{ + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(constr->payload[i]); + } +} + +void HeapVisitor::visit_srt(StgClosure* c) +{ + visit_closure(c); +} + +void HeapVisitor::visit_invalid(StgClosure *const _c) +{ + abort(); +} + +void HeapVisitor::visit_weak(StgWeak* w) +{ + visit_closure(w->key); + visit_closure(w->value); + visit_closure(w->finalizer); + visit_closure(w->cfinalizers); +} + +void HeapVisitor::visit_mvar(StgMVar* mvar) +{ + visit_closure((StgClosure*) mvar->head); + visit_closure((StgClosure*) mvar->tail); + visit_closure(mvar->value); +} + +void HeapVisitor::visit_small_array(StgSmallMutArrPtrs *arr) +{ + for (StgWord i=0; i < arr->ptrs; i++) { + visit_closure(arr->payload[i]); + } +} + +void HeapVisitor::visit_array(StgMutArrPtrs *arr) +{ + for (StgWord i=0; i < arr->ptrs; i++) { + visit_closure(arr->payload[i]); + } +} + +void HeapVisitor::visit_bytearray(StgArrBytes* _arr) { } + +void HeapVisitor::visit_tso(StgTSO *tso) +{ + if (tso->bound != NULL) { + + visit_closure((StgClosure*) tso->bound->tso); + } + if (tso->label != NULL) { + visit_closure({(StgClosure*) tso->label}); + } + visit_closure((StgClosure*) tso->blocked_exceptions); + visit_closure((StgClosure*) tso->bq); + visit_closure((StgClosure*) tso->stackobj); + visit_closure((StgClosure*) tso->_link); + visit_trec_header(tso->trec); + + switch (tso->why_blocked) { + case BlockedOnMVar: + case BlockedOnMVarRead: + case BlockedOnBlackHole: + case BlockedOnMsgThrowTo: + case NotBlocked: + visit_closure(tso->block_info.closure); + break; + default: + break; + } +} + +void HeapVisitor::visit_continuation(StgContinuation *cont) +{ + visit_stack(cont->stack, cont->stack + cont->stack_size); +} + +void HeapVisitor::visit_tvar(StgTVar *tvar) +{ + visit_closure(tvar->current_value); + visit_closure((StgClosure*) tvar->first_watch_queue_entry); +} + +void HeapVisitor::visit_trec_header(StgTRecHeader *trec) +{ + if (trec == NO_TREC) { + return; + } + visit_trec_chunk(trec->current_chunk); + visit_closure((StgClosure*) trec->enclosing_trec); +} + +void HeapVisitor::visit_trec_chunk(StgTRecChunk *tc) +{ + if (tc->prev_chunk != END_STM_CHUNK_LIST) { + visit_closure((StgClosure*) tc->prev_chunk); + } + + for (uint32_t i = 0; i < tc->next_entry_idx; i++) { + TRecEntry *e = &tc->entries[i]; + visit_closure((StgClosure*)e->tvar); + visit_closure(e->expected_value); + visit_closure(e->new_value); + } +} + +void HeapVisitor::visit_stack(StgPtr p, StgPtr stack_end) +{ + while (p < stack_end) { + const StgRetInfoTable* info = get_ret_itbl((StgClosure *) p); + + auto add_srt_ptrs = [&] () { + if (info->i.srt) { + StgClosure *srt = (StgClosure*)GET_SRT(info); + visit_srt(srt); + } + }; + + switch (info->i.type) { + + case UPDATE_FRAME: + { + StgUpdateFrame *frame = (StgUpdateFrame *)p; + visit_closure(frame->updatee); + p += sizeofW(StgUpdateFrame); + continue; + } + + case CATCH_STM_FRAME: + case CATCH_RETRY_FRAME: + case ATOMICALLY_FRAME: + case UNDERFLOW_FRAME: + case STOP_FRAME: + case CATCH_FRAME: + case RET_SMALL: + { + StgWord bitmap = BITMAP_BITS(info->i.layout.bitmap); + StgWord size = BITMAP_SIZE(info->i.layout.bitmap); + // NOTE: the payload starts immediately after the info-ptr, we + // don't have an StgHeader in the same sense as a heap closure. + p++; + visit_small_bitmap((StgClosure**) p, bitmap, size); + p += size; + add_srt_ptrs(); + continue; + } + + case RET_BCO: + { + p++; + StgBCO *bco = (StgBCO *)*p; + visit_closure((StgClosure *) bco); + p++; + StgWord size = BCO_BITMAP_SIZE(bco); + visit_large_bitmap((StgClosure**) p, BCO_BITMAP(bco), size); + p += size; + continue; + } + + case RET_BIG: + { + StgWord size = GET_LARGE_BITMAP(&info->i)->size; + p++; + visit_large_bitmap((StgClosure**) p, GET_LARGE_BITMAP(&info->i), size); + p += size; + // and don't forget to follow the SRT + add_srt_ptrs(); + break; + } + + case RET_FUN: + { + StgRetFun *ret_fun = (StgRetFun *)p; + visit_closure(ret_fun->fun); + + const StgFunInfoTable *fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + switch (fun_info->f.fun_type) { + case ARG_GEN: + { + StgWord bitmap = BITMAP_BITS(fun_info->f.b.bitmap); + StgWord size = BITMAP_SIZE(fun_info->f.b.bitmap); + visit_small_bitmap(ret_fun->payload, bitmap, size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + case ARG_GEN_BIG: + { + StgWord size = GET_FUN_LARGE_BITMAP(fun_info)->size; + visit_large_bitmap(ret_fun->payload, GET_FUN_LARGE_BITMAP(fun_info), size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + default: + { + StgWord bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); + StgWord size = BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type]); + visit_small_bitmap(ret_fun->payload, bitmap, size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + } + add_srt_ptrs(); + break; + } + default: + abort(); + } + } +} + +void HeapVisitor::visit_small_bitmap( + StgClosure *const *payload, + StgWord bitmap, + StgWord size) +{ + while (size > 0) { + if ((bitmap & 1) == 0) { + visit_closure(*payload); + } + payload++; + bitmap = bitmap >> 1; + size--; + } +} + +void HeapVisitor::visit_large_bitmap( + StgClosure *const * payload, + const StgLargeBitmap *large_bitmap, + StgWord size) +{ + // Bitmap may have more bits than `size` when scavenging PAP payloads. See + // comments around StgPAP. + ASSERT(large_bitmap->size >= size); + + uint32_t b = 0; + for (uint32_t i = 0; i < size; b++) { + StgWord bitmap = large_bitmap->bitmap[b]; + uint32_t j = stg_min(size-i, BITS_IN(W_)); + i += j; + for (; j > 0; j--, payload++) { + if ((bitmap & 1) == 0) { + visit_closure(*payload); + } + bitmap = bitmap >> 1; + } + } +} + +void HeapVisitor::visit_pap_payload( + StgClosure *fun, + StgClosure **payload, + StgWord n_args) +{ + fun = UNTAG_CLOSURE(fun); + const StgFunInfoTable *fun_info = get_fun_itbl(fun); + ASSERT(fun_info->i.type != PAP); + switch (fun_info->f.fun_type) { + case ARG_GEN: + visit_small_bitmap(payload, BITMAP_BITS(fun_info->f.b.bitmap), n_args); + break; + case ARG_GEN_BIG: + visit_large_bitmap(payload, GET_FUN_LARGE_BITMAP(fun_info), n_args); + break; + case ARG_BCO: + visit_large_bitmap(payload, BCO_BITMAP(fun), n_args); + break; + default: + { + StgWord bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); + visit_small_bitmap(payload, bitmap, n_args); + } + } +} + +void HeapVisitor::visit_closure(TaggedClosurePtr tagged) +{ + StgClosure *c = tagged.untag(); + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa || !LOOKS_LIKE_CLOSURE_PTR(c)) { + visit_invalid(c); + return; + } + + const StgInfoTable *info = get_itbl(c); + auto generic_closure = [&] () { + for (StgClosure **p = &c->payload[0]; p < &c->payload[info->layout.payload.ptrs]; p++) { + visit_closure(*p); + } + }; + + switch (info->type) { + + case MVAR_CLEAN: + case MVAR_DIRTY: + visit_mvar((StgMVar *) c); + break; + case TVAR: + visit_tvar((StgTVar *) c); + break; + + case IND: + case IND_STATIC: + visit_closure(((StgInd *) c)->indirectee); + break; + + case THUNK_0_1: + case THUNK_0_2: + visit_thunk((StgThunk*) c, 0); + break; + case THUNK_1_1: + case THUNK_1_0: + visit_thunk((StgThunk*) c, 1); + break; + case THUNK_2_0: + visit_thunk((StgThunk*) c, 2); + break; + case THUNK: + visit_thunk((StgThunk*) c, info->layout.payload.ptrs); + break; + case THUNK_STATIC: + visit_thunk((StgThunk*) c, 0); + break; + + case FUN_1_0: + visit_fun(c, 1); + break; + case FUN_0_1: + case FUN_0_2: + visit_fun(c, 0); + break; + case FUN_1_1: + visit_fun(c, 1); + break; + case FUN_2_0: + visit_fun(c, 2); + break; + case FUN: + case FUN_STATIC: + visit_fun(c, info->layout.payload.ptrs); + break; + + case CONSTR_0_1: + case CONSTR_0_2: + visit_constr(c, 0); + break; + case CONSTR_1_0: + case CONSTR_1_1: + visit_constr(c, 1); + break; + case CONSTR_2_0: + visit_constr(c, 2); + break; + case CONSTR: + case CONSTR_NOCAF: + visit_constr(c, info->layout.payload.ptrs); + break; + + case PRIM: + generic_closure(); + break; + case WEAK: + visit_weak((StgWeak*) c); + break; + case BCO: + { + StgBCO *bco = (StgBCO *)c; + visit_closure((StgClosure*) bco->instrs); + visit_closure((StgClosure*) bco->literals); + visit_closure((StgClosure*) bco->ptrs); + break; + } + case BLACKHOLE: + { + StgInd *ind = (StgInd*) c; + visit_closure(ind->indirectee); + break; + } + case MUT_VAR_CLEAN: + case MUT_VAR_DIRTY: + { + StgMutVar *mv = (StgMutVar*) c; + visit_closure(mv->var); + break; + } + case BLOCKING_QUEUE: + { + StgBlockingQueue *bq = (StgBlockingQueue *)c; + visit_closure((StgClosure*) bq->bh); + visit_closure((StgClosure*) bq->owner); + visit_closure((StgClosure*) bq->queue); + visit_closure((StgClosure*) bq->link); + break; + } + case THUNK_SELECTOR: + { + StgSelector *s = (StgSelector *)c; + visit_closure(s->selectee); + break; + } + case AP_STACK: + { + StgAP_STACK *ap = (StgAP_STACK *)c; + visit_closure(ap->fun); + visit_stack((StgPtr) ap->payload, (StgPtr) ap->payload + ap->size); + break; + } + case PAP: + { + StgPAP *pap = (StgPAP*) c; + visit_closure(pap->fun); + visit_pap_payload(pap->fun, (StgClosure**) pap->payload, pap->n_args); + break; + } + case AP: + { + StgAP *ap = (StgAP*) c; + visit_closure(ap->fun); + visit_pap_payload(ap->fun, (StgClosure**) ap->payload, ap->n_args); + break; + } + case ARR_WORDS: + visit_bytearray((StgArrBytes *) c); + break; + case MUT_ARR_PTRS_CLEAN: + case MUT_ARR_PTRS_DIRTY: + case MUT_ARR_PTRS_FROZEN_DIRTY: + case MUT_ARR_PTRS_FROZEN_CLEAN: + visit_array((StgMutArrPtrs *) c); + break; + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + visit_small_array((StgSmallMutArrPtrs *) c); + break; + case TSO: + visit_tso((StgTSO *) c); + break; + case STACK: + { + StgStack *stack = (StgStack *) c; + visit_stack(stack->sp, stack->stack + stack->stack_size); + break; + } + case MUT_PRIM: + generic_closure(); + break; + case TREC_CHUNK: + visit_trec_chunk((StgTRecChunk *) c); + break; + case CONTINUATION: + visit_continuation((StgContinuation *) c); + break; + default: + visit_invalid(c); + break; + } +} + +class PredicatedHeapVisitor : HeapVisitor { + bool should_visit(StgClosure *); + + virtual void visit_srt(StgClosure* c) { + if (should_visit(c)) { HeapVisitor::visit_srt(c); } + } + + virtual void visit_closure(TaggedClosurePtr c) { + if (should_visit(c.untag())) { HeapVisitor::visit_closure(c); } + } +}; + +// Collect direct pointers +struct CollectPointers : HeapVisitor { + std::set accum; + bool invalid; + CollectPointers() : accum(), invalid(false) {} + void visit_root(StgClosure *c) { + HeapVisitor::visit_closure(c); + } + void visit_closure(TaggedClosurePtr c) { + accum.insert(c); + } + void visit_invalid(StgClosure *const _c) { invalid = true; } +}; + +static std::set collect_pointers(StgClosure* c) +{ + CollectPointers v; + v.visit_root(c); + return v.accum; +} + + + +struct Error { + StgClosure *closure; + std::string what; + Error(StgClosure *closure, std::string what) : closure(closure), what(what) {} +}; + +static std::ostream& operator<<(std::ostream& os, const Error& err) { + os << std::hex << "0x" << (StgWord) err.closure << ": " << err.what << "\n"; + return os; +} + +class CheckVisitor : HeapVisitor { + std::vector errors; + uint8_t tag; + void visit_constr(StgClosure* c) { + const StgInfoTable *info = get_itbl(c); + if (tag != 0) { + uint8_t constr_tag = info->srt; // zero-based + if (tag != std::min(TAG_MASK, constr_tag+1)) { + errors.push_back(Error(c, "invalid tag")); + } + } + } + + void visit_closure(TaggedClosurePtr c) { } +public: + const std::vector& get_errors() const { return errors; } + + void check_closure(TaggedClosurePtr c) { + tag = c.get_tag(); + HeapVisitor::visit_closure(c); + } +}; + +struct CheckGc { + std::queue queue; + std::unordered_set enqueued; + + void enqueue(TaggedClosurePtr ptr) { + ASSERT(ptr != NULL); + if (!is_enqueued(ptr)) { + queue.push(ptr); + enqueued.insert(ptr); + } + } + + bool finished() { + return queue.empty(); + } + + TaggedClosurePtr pop() { + TaggedClosurePtr p = queue.front(); + queue.pop(); + return p; + } + + bool is_enqueued(TaggedClosurePtr ptr) { + return enqueued.find(ptr) != enqueued.end(); + } +}; + +static void enqueue_root(void *user_data, StgClosure **root) +{ + CheckGc* env = (CheckGc*) user_data; + env->enqueue(*root); +} + +static void enqueue_roots(CheckGc& env) +{ + FOR_EACH_STABLE_NAME(p, if (p->sn_obj) env.enqueue(p->sn_obj);); + markStablePtrTable(enqueue_root, &env); + for (uint32_t n = 0; n < getNumCapabilities(); n++) { + markCapability(enqueue_root, (void*) &env, getCapability(n), false/*mark sparks*/); + } + markCAFs(enqueue_root, &env); + markScheduler(enqueue_root, &env); + + for (StgWeak *w = nonmoving_weak_ptr_list; w != NULL; w = w->link) { + env.enqueue((StgClosure *) w); + } + + for (uint32_t g = 0; g <= N; g++) { + generation *gen = &generations[g]; + for (StgWeak *w = gen->weak_ptr_list; w != NULL; w = RELAXED_LOAD(&w->link)) { + env.enqueue((StgClosure *) w); + } + } +} + +extern "C" { +void check_gc(); +} + +struct NodeName { + const StgClosure *c; + NodeName(const StgClosure *c) : c(c) {} +}; + +static std::ostream& operator<<(std::ostream& os, const NodeName& n) { + os << std::hex << "\"" << n.c << "\"" << std::dec; + return os; +} + +static void dump_heap(std::ofstream& of) +{ + of << "digraph {\n"; + CheckGc env; + enqueue_roots(env); + while (!env.finished()) { + TaggedClosurePtr tagged = env.pop(); + StgClosure* c = tagged.untag(); + NodeName n(c); + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa) { + of << n << " [type=invalid];\n"; + continue; + } + + const StgInfoTable *info = get_itbl(c); + switch (info->type) { + case CONSTR: + case CONSTR_1_0: + case CONSTR_0_1: + case CONSTR_2_0: + case CONSTR_1_1: + case CONSTR_0_2: + case CONSTR_NOCAF: + { + const StgConInfoTable *con_info = get_con_itbl(c); + of << n << " [type=CONSTR constr=\"" << GET_CON_DESC(con_info) << "\"];\n"; + break; + } + case FUN: + case FUN_1_0: + case FUN_0_1: + case FUN_2_0: + case FUN_1_1: + case FUN_0_2: + of << n << " [type=FUN];\n"; + break; + case FUN_STATIC: + of << n << " [type=FUN_STATIC];\n"; + break; + case THUNK: + case THUNK_1_0: + case THUNK_0_1: + case THUNK_1_1: + case THUNK_0_2: + case THUNK_2_0: + of << n << " [type=THUNK];\n"; + break; + case THUNK_STATIC: + of << n << " [type=THUNK_STATIC];\n"; + break; + case THUNK_SELECTOR: + of << n << " [type=THUNK_SEL];\n"; + break; + case BCO: + of << n << " [type=BCO];\n"; + break; + case AP: + of << n << " [type=AP];\n"; + break; + case PAP: + of << n << " [type=PAP];\n"; + break; + case AP_STACK: + of << n << " [type=AP_STACK];\n"; + break; + case IND: + of << n << " [type=IND];\n"; + break; + case IND_STATIC: + of << n << " [type=IND_STATIC];\n"; + break; + case BLOCKING_QUEUE: + of << n << " [type=BLOCKING_QUEUE];\n"; + break; + case BLACKHOLE: + of << n << " [type=BLACKHOLE];\n"; + break; + case MVAR_CLEAN: + case MVAR_DIRTY: + of << n << " [type=MVAR];\n"; + break; + case TVAR: + of << n << " [type=TVAR];\n"; + break; + case ARR_WORDS: + of << n << " [type=ARR_WORDS];\n"; + break; + case MUT_ARR_PTRS_CLEAN: + case MUT_ARR_PTRS_DIRTY: + case MUT_ARR_PTRS_FROZEN_CLEAN: + case MUT_ARR_PTRS_FROZEN_DIRTY: + of << n << " [type=MUT_ARR_PTRS];\n"; + break; + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + of << n << " [type=SMALL_MUT_ARR_PTRS];\n"; + break; + case MUT_VAR_CLEAN: + case MUT_VAR_DIRTY: + of << n << " [type=MUT_VAR];\n"; + break; + case WEAK: + of << n << " [type=WEAK];\n"; + break; + case PRIM: + of << n << " [type=PRIM];\n"; + break; + case MUT_PRIM: + of << n << " [type=MUT_PRIM];\n"; + break; + case TSO: + of << n << " [type=TSO];\n"; + break; + case STACK: + of << n << " [type=STACK];\n"; + break; + case TREC_CHUNK: + of << n << " [type=TREC_CHUNK];\n"; + break; + case WHITEHOLE: + of << n << " [type=WHITEHOLE];\n"; + break; + case COMPACT_NFDATA: + of << n << " [type=COMPACT_NFDATA];\n"; + break; + case CONTINUATION: + of << n << " [type=CONTINUATION];\n"; + break; + default: + of << n << " [type=unknown];\n"; + break; + } + + if (!HEAP_ALLOCED((StgPtr) c)) { + of << n << " [static=yes];\n"; + } else { + bdescr *bd = Bdescr((StgPtr) c); + of << n << " [gen=" << bd->gen_no << "];\n"; + if (bd->flags & BF_EVACUATED) { + of << n << " [evacuated=yes];\n"; + } + if (bd->flags & BF_PINNED) { + of << n << " [pinned=yes];\n"; + } + if (bd->flags & BF_LARGE) { + of << n << " [large=yes];\n"; + } else if (bd->flags & BF_NONMOVING) { + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) c); + nonmoving_block_idx block_idx = nonmovingGetBlockIdx((StgPtr) c); + uint8_t mark = nonmovingGetMark(seg, block_idx); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (c > snapshot_loc) { + of << n << " [nonmoving=yes new=yes mark=" << (StgWord) mark << "];\n"; + } else { + of << n << " [nonmoving=yes mark=" << (StgWord) mark << "];\n"; + } + } else { + of << n << " [moving=yes];\n"; + } + } + for (TaggedClosurePtr p : collect_pointers(c)) { + of << n << " -> " << NodeName(p.untag()) << ";\n"; + env.enqueue(p); + } + } + of << "}\n"; +} + +void dump_heap_to(const char *fname); +void dump_heap_to(const char *fname) +{ + std::ofstream out(fname); + dump_heap(out); + out.flush(); +} + +void check_gc() +{ + CheckGc env; + enqueue_roots(env); + std::vector errors; + + while (!env.finished()) { + TaggedClosurePtr tagged = env.pop(); + StgClosure* c = tagged.untag(); + + { + CheckVisitor check; + check.check_closure(tagged); + for (const Error& e : check.get_errors()) { + errors.push_back(e); + } + } + + for (TaggedClosurePtr p : collect_pointers(c)) { + env.enqueue(p); + } + + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa) { + errors.push_back(Error(c, "is invalid closure")); + continue; + } + + const StgInfoTable *info = get_itbl(c); + if (!HEAP_ALLOCED((StgPtr) c)) { + switch (info->type) { + case THUNK_STATIC: + if (info->srt != 0) { + + } + } + } else { + bdescr *bd = Bdescr((StgPtr) c); + if (bd->gen_no < 1) { + /* nothing to check as we are focused on post nonmoving-GC checking */ + } else if (bd->flags & BF_NONMOVING && bd->flags & BF_LARGE) { + if (bd->flags & BF_NONMOVING_SWEEPING && !(bd->flags & BF_MARKED)) { + errors.push_back(Error(c, "is not marked yet being swept")); + } + } else if (bd->flags & BF_NONMOVING) { + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) c); + nonmoving_block_idx block_idx = nonmovingGetBlockIdx((StgPtr) c); + uint8_t mark = nonmovingGetMark(seg, block_idx); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (bd->flags & BF_NONMOVING_SWEEPING) { + /* in a swept segment */ + if (mark != nonmovingMarkEpoch) { + errors.push_back(Error(c, "is unmarked nonmoving object being swept")); + } + } else if (c < snapshot_loc) { + /* not in a swept segment but in the snapshot */ + if (mark != nonmovingMarkEpoch) { + errors.push_back(Error(c, "is unmarked nonmoving object in the snapshot")); + } + } else { + /* not in the snapshot; nothing to assert */ + } + } else if (bd->flags & BF_LARGE) { + if (! (bd->flags & BF_MARKED)) { + errors.push_back(Error(c, "is unmarked large object")); + } + } else { + if (!(bd->flags & BF_EVACUATED)) { + //errors.push_back(Error(c, "is in from-space block")); + } + } + } + } + + if (!errors.empty()) { + for (auto err : errors) { + std::cerr << err << "\n"; + } + dump_heap_to("heap.dot"); + abort(); + } +} + ===================================== rts/sm/Evac.c ===================================== @@ -1232,7 +1232,7 @@ unchain_thunk_selectors(StgSelector *p, StgClosure *val) -------------------------------------------------------------------------- */ static void -eval_thunk_selector (StgClosure **q, StgSelector *p, bool evac) +eval_thunk_selector (StgClosure **const q, StgSelector *p, bool evac) // NB. for legacy reasons, p & q are swapped around :( { uint32_t field; @@ -1252,13 +1252,22 @@ selector_chain: bd = Bdescr((StgPtr)p); if (HEAP_ALLOCED_GC(p)) { + const uint16_t flags = RELAXED_LOAD(&bd->flags); + + // We should never see large objects here + ASSERT(!(flags & BF_LARGE)); + // If the THUNK_SELECTOR is in to-space or in a generation that we // are not collecting, then bale out early. We won't be able to // 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 (RELAXED_LOAD(&bd->flags) & (BF_EVACUATED | BF_NONMOVING)) { + if (flags & (BF_EVACUATED | BF_NONMOVING)) { unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p); + if (flags & BF_NONMOVING) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) p); + } *q = (StgClosure *)p; // shortcut, behave as for: if (evac) evacuate(q); if (evac && bd->gen_no < gct->evac_gen_no) { @@ -1273,7 +1282,7 @@ selector_chain: // (scavenge_mark_stack doesn't deal with IND). BEWARE! This // bit is very tricky to get right. If you make changes // around here, test by compiling stage 3 with +RTS -c -RTS. - if (bd->flags & BF_MARKED) { + if (flags & BF_MARKED) { // must call evacuate() to mark this closure if evac==true *q = (StgClosure *)p; if (evac) evacuate(q); @@ -1313,6 +1322,12 @@ selector_chain: // - undo the chain we've built to point to p. SET_INFO((StgClosure *)p, (const StgInfoTable *)info_ptr); RELEASE_STORE(q, (StgClosure *) p); + if (Bdescr((StgPtr)p)->flags & BF_NONMOVING) { + // See Note [Non-moving GC: Marking evacuated objects]. + // TODO: This really shouldn't be necessary since whoever won + // the race should have pushed + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) p); + } if (evac) evacuate(q); unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p); return; @@ -1403,6 +1418,11 @@ selector_loop: case THUNK_SELECTOR: // Use payload to make a list of thunk selectors, to be // used in unchain_thunk_selectors + // + // FIXME: This seems racy; should we lock this selector to + // ensure that another thread doesn't clobber this node + // of the chain. This would result in some previous + // selectors not being updated when we unchain. RELAXED_STORE(&((StgClosure*)p)->payload[0], (StgClosure *)prev_thunk_selector); prev_thunk_selector = p; p = (StgSelector*)val; @@ -1427,6 +1447,12 @@ selector_loop: // eval_thunk_selector(), because we know val is not // a THUNK_SELECTOR. if (evac) evacuate(q); + + if (isNonmovingClosure(*q)) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) *q); + } + return; } @@ -1471,6 +1497,10 @@ selector_loop: // recurse indefinitely, so we impose a depth bound. // See Note [Selector optimisation depth limit]. if (gct->thunk_selector_depth >= MAX_THUNK_SELECTOR_DEPTH) { + if (isNonmovingClosure((StgClosure *) p)) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) p); + } goto bale_out; } @@ -1517,5 +1547,9 @@ bale_out: if (evac) { copy(q,(const StgInfoTable *)info_ptr,(StgClosure *)p,THUNK_SELECTOR_sizeW(),bd->dest_no); } + if (isNonmovingClosure(*q)) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, *q); + } unchain_thunk_selectors(prev_thunk_selector, *q); } ===================================== rts/sm/GC.c ===================================== @@ -312,8 +312,6 @@ GarbageCollect (uint32_t collect_gen, CostCentreStack *save_CCS[getNumCapabilities()]; #endif - ACQUIRE_SM_LOCK; - #if defined(RTS_USER_SIGNALS) if (RtsFlags.MiscFlags.install_signal_handlers) { // block signals @@ -591,9 +589,7 @@ GarbageCollect (uint32_t collect_gen, // the current garbage collection, so we invoke LdvCensusForDead(). if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_LDV || RtsFlags.ProfFlags.bioSelector != NULL) { - RELEASE_SM_LOCK; // LdvCensusForDead may need to take the lock LdvCensusForDead(N); - ACQUIRE_SM_LOCK; } #endif @@ -762,7 +758,7 @@ GarbageCollect (uint32_t collect_gen, } else // not compacted { - freeChain(gen->old_blocks); + freeChain_lock(gen->old_blocks); } gen->old_blocks = NULL; @@ -773,7 +769,7 @@ GarbageCollect (uint32_t collect_gen, * collection from large_objects. Any objects left on the * large_objects list are therefore dead, so we free them here. */ - freeChain(gen->large_objects); + freeChain_lock(gen->large_objects); gen->large_objects = gen->scavenged_large_objects; gen->n_large_blocks = gen->n_scavenged_large_blocks; gen->n_large_words = countOccupied(gen->large_objects); @@ -892,7 +888,7 @@ GarbageCollect (uint32_t collect_gen, if (mark_stack_top_bd != NULL) { debugTrace(DEBUG_gc, "mark stack: %d blocks", countBlocks(mark_stack_top_bd)); - freeChain(mark_stack_top_bd); + freeChain_lock(mark_stack_top_bd); } // Free any bitmaps. @@ -944,9 +940,7 @@ GarbageCollect (uint32_t collect_gen, // Start any pending finalizers. Must be after // updateStableTables() and stableUnlock() (see #4221). - RELEASE_SM_LOCK; scheduleFinalizers(cap, dead_weak_ptr_list); - ACQUIRE_SM_LOCK; // check sanity after GC // before resurrectThreads(), because that might overwrite some @@ -961,9 +955,7 @@ GarbageCollect (uint32_t collect_gen, // behind. if (do_heap_census) { debugTrace(DEBUG_sched, "performing heap census"); - RELEASE_SM_LOCK; heapCensus(mut_time); - ACQUIRE_SM_LOCK; } #if defined(TICKY_TICKY) @@ -977,14 +969,14 @@ GarbageCollect (uint32_t collect_gen, #endif // send exceptions to any threads which were about to die - RELEASE_SM_LOCK; resurrectThreads(resurrected_threads); - ACQUIRE_SM_LOCK; // Finally free the deferred mblocks by sorting the deferred free list and // merging it into the actual sorted free list. This needs to happen here so // that the `returnMemoryToOS` call down below can successfully free memory. + ACQUIRE_SM_LOCK; commitMBlockFreeing(); + RELEASE_SM_LOCK; if (major_gc) { W_ need_prealloc, need_live, need, got; @@ -1097,8 +1089,6 @@ GarbageCollect (uint32_t collect_gen, } #endif - RELEASE_SM_LOCK; - SET_GCT(saved_gct); } @@ -1148,7 +1138,7 @@ new_gc_thread (uint32_t n, gc_thread *t) // but can't, because it uses gct which isn't set up at this point. // Hence, allocate a block for todo_bd manually: { - bdescr *bd = allocBlockOnNode(capNoToNumaNode(n)); + bdescr *bd = allocBlockOnNode_lock(capNoToNumaNode(n)); // no lock, locks aren't initialised yet initBdescr(bd, ws->gen, ws->gen->to); bd->flags = BF_EVACUATED; @@ -1607,7 +1597,7 @@ static void stash_mut_list (Capability *cap, uint32_t gen_no) { cap->saved_mut_lists[gen_no] = cap->mut_lists[gen_no]; - RELEASE_STORE(&cap->mut_lists[gen_no], allocBlockOnNode_sync(cap->node)); + RELEASE_STORE(&cap->mut_lists[gen_no], allocBlockOnNode_lock(cap->node)); } /* ---------------------------------------------------------------------------- @@ -1634,9 +1624,9 @@ prepare_collected_gen (generation *gen) // a check for NULL in recordMutable(). for (i = 0; i < getNumCapabilities(); i++) { bdescr *old = RELAXED_LOAD(&getCapability(i)->mut_lists[g]); - freeChain(old); + freeChain_lock(old); - bdescr *new = allocBlockOnNode(capNoToNumaNode(i)); + bdescr *new = allocBlockOnNode_lock(capNoToNumaNode(i)); RELAXED_STORE(&getCapability(i)->mut_lists[g], new); } } @@ -1719,7 +1709,7 @@ prepare_collected_gen (generation *gen) bitmap_size = gen->n_old_blocks * BLOCK_SIZE / BITS_IN(W_); if (bitmap_size > 0) { - bitmap_bdescr = allocGroup((StgWord)BLOCK_ROUND_UP(bitmap_size) + bitmap_bdescr = allocGroup_lock((StgWord)BLOCK_ROUND_UP(bitmap_size) / BLOCK_SIZE); gen->bitmap = bitmap_bdescr; bitmap = bitmap_bdescr->start; ===================================== rts/sm/GC.h ===================================== @@ -13,8 +13,6 @@ #pragma once -#include "HeapAlloc.h" - #include "BeginPrivate.h" void GarbageCollect (uint32_t collect_gen, ===================================== rts/sm/GCUtils.c ===================================== @@ -26,38 +26,15 @@ #include "WSDeque.h" #endif -#if defined(THREADED_RTS) -SpinLock gc_alloc_block_sync; -#endif - static void push_todo_block(bdescr *bd, gen_workspace *ws); -bdescr* allocGroup_sync(uint32_t n) -{ - bdescr *bd; - uint32_t node = capNoToNumaNode(gct->thread_index); - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); - bd = allocGroupOnNode(node,n); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); - return bd; -} - -bdescr* allocGroupOnNode_sync(uint32_t node, uint32_t n) -{ - bdescr *bd; - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); - bd = allocGroupOnNode(node,n); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); - return bd; -} - static uint32_t -allocBlocks_sync(uint32_t n, bdescr **hd) +allocBlocks_lock(uint32_t n, bdescr **hd) { bdescr *bd; uint32_t i; uint32_t node = capNoToNumaNode(gct->thread_index); - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); + ACQUIRE_SM_LOCK; bd = allocLargeChunkOnNode(node,1,n); // NB. allocLargeChunk, rather than allocGroup(n), to allocate in a // fragmentation-friendly way. @@ -70,27 +47,11 @@ allocBlocks_sync(uint32_t n, bdescr **hd) bd[n-1].link = NULL; // We have to hold the lock until we've finished fiddling with the metadata, // otherwise the block allocator can get confused. - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); + RELEASE_SM_LOCK; *hd = bd; return n; } -void -freeChain_sync(bdescr *bd) -{ - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); - freeChain(bd); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); -} - -void -freeGroup_sync(bdescr *bd) -{ - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); - freeGroup(bd); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); -} - /* ----------------------------------------------------------------------------- Workspace utilities -------------------------------------------------------------------------- */ @@ -303,7 +264,7 @@ todo_block_full (uint32_t size, gen_workspace *ws) // object. However, if the object we're copying is // larger than a block, then we might have an empty // block here. - freeGroup_sync(bd); + freeGroup_lock(bd); } else { push_scanned_block(bd, ws); } @@ -343,14 +304,14 @@ alloc_todo_block (gen_workspace *ws, uint32_t size) else { if (size > BLOCK_SIZE_W) { - bd = allocGroup_sync((W_)BLOCK_ROUND_UP(size*sizeof(W_)) + bd = allocGroup_lock((W_)BLOCK_ROUND_UP(size*sizeof(W_)) / BLOCK_SIZE); } else { if (gct->free_blocks) { bd = gct->free_blocks; gct->free_blocks = bd->link; } else { - allocBlocks_sync(16, &bd); + allocBlocks_lock(16, &bd); gct->free_blocks = bd->link; } } ===================================== rts/sm/GCUtils.h ===================================== @@ -17,22 +17,6 @@ #include "BeginPrivate.h" -bdescr* allocGroup_sync(uint32_t n); -bdescr* allocGroupOnNode_sync(uint32_t node, uint32_t n); - -INLINE_HEADER bdescr *allocBlock_sync(void) -{ - return allocGroup_sync(1); -} - -INLINE_HEADER bdescr *allocBlockOnNode_sync(uint32_t node) -{ - return allocGroupOnNode_sync(node,1); -} - -void freeChain_sync(bdescr *bd); -void freeGroup_sync(bdescr *bd); - void push_scanned_block (bdescr *bd, gen_workspace *ws); StgPtr todo_block_full (uint32_t size, gen_workspace *ws); StgPtr alloc_todo_block (gen_workspace *ws, uint32_t size); @@ -62,7 +46,7 @@ recordMutableGen_GC (StgClosure *p, uint32_t gen_no) bd = gct->mut_lists[gen_no]; if (bd->free >= bd->start + BLOCK_SIZE_W) { bdescr *new_bd; - new_bd = allocBlock_sync(); + new_bd = allocBlock_lock(); new_bd->link = bd; bd = new_bd; gct->mut_lists[gen_no] = bd; ===================================== rts/sm/HeapAlloc.h ===================================== @@ -10,6 +10,8 @@ #include "BeginPrivate.h" +#include "Storage.h" + /* ----------------------------------------------------------------------------- The HEAP_ALLOCED() test. @@ -210,9 +212,9 @@ StgBool HEAP_ALLOCED_GC(const void *p) } else { // putting the rest out of line turned out to be a slight // performance improvement: - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); + ACQUIRE_SM_LOCK; // TODO: this may be too expensive b = HEAP_ALLOCED_miss(mblock,p); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); + RELEASE_SM_LOCK; return b; } } ===================================== rts/sm/MarkStack.h ===================================== @@ -32,7 +32,7 @@ push_mark_stack(StgPtr p) } else { - bd = allocBlock_sync(); + bd = allocBlock_lock(); bd->link = mark_stack_bd; bd->u.back = NULL; mark_stack_bd->u.back = bd; // double-link the new block on ===================================== rts/sm/NonMoving.c ===================================== @@ -598,14 +598,10 @@ static struct NonmovingSegment *nonmovingAllocSegment(uint32_t node) // Nothing in the free list, allocate a new segment... if (ret == NULL) { - // Take gc spinlock: another thread may be scavenging a moving - // generation and call `todo_block_full` - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); bdescr *bd = allocAlignedGroupOnNode(node, NONMOVING_SEGMENT_BLOCKS); // See Note [Live data accounting in nonmoving collector]. oldest_gen->n_blocks += bd->blocks; oldest_gen->n_words += BLOCK_SIZE_W * bd->blocks; - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); for (StgWord32 i = 0; i < bd->blocks; ++i) { initBdescr(&bd[i], oldest_gen, oldest_gen); @@ -668,7 +664,7 @@ static struct NonmovingSegment *pop_active_segment(struct NonmovingAllocator *al } } -/* Allocate a block in the nonmoving heap. Caller must hold SM_MUTEX. sz is in words */ +/* Allocate a block in the nonmoving heap. sz is in words */ GNUC_ATTR_HOT void *nonmovingAllocate(Capability *cap, StgWord sz) { @@ -708,7 +704,9 @@ void *nonmovingAllocate(Capability *cap, StgWord sz) // there are no active segments, allocate new segment if (new_current == NULL) { + ACQUIRE_SM_LOCK; new_current = nonmovingAllocSegment(cap->node); + RELEASE_SM_LOCK; nonmovingInitSegment(new_current, log_block_size); } @@ -791,14 +789,13 @@ void nonmovingExit(void) /* * Assumes that no garbage collector or mutator threads are running to safely * resize the nonmoving_allocators. - * - * Must hold sm_mutex. */ void nonmovingAddCapabilities(uint32_t new_n_caps) { unsigned int old_n_caps = nonmovingHeap.n_caps; struct NonmovingAllocator **allocs = nonmovingHeap.allocators; + ACQUIRE_SM_LOCK; for (unsigned int i = 0; i < NONMOVING_ALLOCA_CNT; i++) { struct NonmovingAllocator *old = allocs[i]; allocs[i] = alloc_nonmoving_allocator(new_n_caps); @@ -820,6 +817,7 @@ void nonmovingAddCapabilities(uint32_t new_n_caps) } } nonmovingHeap.n_caps = new_n_caps; + RELEASE_SM_LOCK; } void nonmovingClearBitmap(struct NonmovingSegment *seg) @@ -844,13 +842,14 @@ static void nonmovingPrepareMark(void) struct NonmovingAllocator *alloca = nonmovingHeap.allocators[alloca_idx]; // Update current segments' snapshot pointers - for (uint32_t cap_n = 0; cap_n < getNumCapabilities(); ++cap_n) { + for (uint32_t cap_n = 0; cap_n < nonmovingHeap.n_caps; ++cap_n) { struct NonmovingSegment *seg = alloca->current[cap_n]; nonmovingSegmentInfo(seg)->next_free_snap = seg->next_free; } // Save the filled segments for later processing during the concurrent // mark phase. + ASSERT(alloca->saved_filled == NULL); alloca->saved_filled = alloca->filled; alloca->filled = NULL; @@ -926,6 +925,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) ASSERT(n_nonmoving_marked_compact_blocks == 0); MarkQueue *mark_queue = stgMallocBytes(sizeof(MarkQueue), "mark queue"); + mark_queue->blocks = NULL; initMarkQueue(mark_queue); current_mark_queue = mark_queue; @@ -1090,6 +1090,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * seg->link = nonmovingHeap.sweep_list; nonmovingHeap.sweep_list = filled; } + nonmovingHeap.allocators[alloca_idx]->saved_filled = NULL; } // Mark Weak#s @@ -1183,7 +1184,8 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * nonmoving_old_threads = END_TSO_QUEUE; } - nonmoving_weak_ptr_list = nonmoving_old_weak_ptr_list; + // At this point point any weak that remains on nonmoving_old_weak_ptr_list + // has a dead key. nonmoving_old_weak_ptr_list = NULL; // Prune spark lists @@ -1236,6 +1238,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) && defined(NONCONCURRENT_SWEEP) #if defined(DEBUG) + check_gc(); checkNonmovingHeap(&nonmovingHeap); checkSanity(true, true); #endif @@ -1293,7 +1296,7 @@ void assert_in_nonmoving_heap(StgPtr p) for (int alloca_idx = 0; alloca_idx < NONMOVING_ALLOCA_CNT; ++alloca_idx) { struct NonmovingAllocator *alloca = nonmovingHeap.allocators[alloca_idx]; // Search current segments - for (uint32_t cap_idx = 0; cap_idx < getNumCapabilities(); ++cap_idx) { + for (uint32_t cap_idx = 0; cap_idx < nonmovingHeap.n_caps; ++cap_idx) { struct NonmovingSegment *seg = alloca->current[cap_idx]; if (p >= (P_)seg && p < (((P_)seg) + NONMOVING_SEGMENT_SIZE_W)) { return; @@ -1365,7 +1368,7 @@ void nonmovingPrintAllocator(struct NonmovingAllocator *alloc) debugBelch("%p ", (void*)seg); } debugBelch("\nCurrent segments:\n"); - for (uint32_t i = 0; i < getNumCapabilities(); ++i) { + for (uint32_t i = 0; i < nonmovingHeap.n_caps; ++i) { debugBelch("%p ", alloc->current[i]); } debugBelch("\n"); @@ -1376,7 +1379,7 @@ void locate_object(P_ obj) // Search allocators for (int alloca_idx = 0; alloca_idx < NONMOVING_ALLOCA_CNT; ++alloca_idx) { struct NonmovingAllocator *alloca = nonmovingHeap.allocators[alloca_idx]; - for (uint32_t cap = 0; cap < getNumCapabilities(); ++cap) { + for (uint32_t cap = 0; cap < nonmovingHeap.n_caps; ++cap) { struct NonmovingSegment *seg = alloca->current[cap]; if (obj >= (P_)seg && obj < (((P_)seg) + NONMOVING_SEGMENT_SIZE_W)) { debugBelch("%p is in current segment of capability %d of allocator %d at %p\n", obj, cap, alloca_idx, (void*)seg); ===================================== rts/sm/NonMovingMark.c ===================================== @@ -37,6 +37,7 @@ static void trace_PAP_payload (MarkQueue *queue, StgClosure *fun, StgClosure **payload, StgWord size); +static bool isNonmovingWeak(StgWeak *weak); // How many Array# entries to add to the mark queue at once? #define MARK_ARRAY_CHUNK_LENGTH 128 @@ -270,6 +271,7 @@ static void nonmovingAddUpdRemSetBlocks_(MarkQueue *rset) bdescr *end = start; while (end->link != NULL) end = end->link; + rset->blocks = NULL; // add the blocks to the global remembered set ACQUIRE_LOCK(&upd_rem_set_lock); @@ -291,10 +293,8 @@ static void nonmovingAddUpdRemSetBlocks_lock(MarkQueue *rset) nonmovingAddUpdRemSetBlocks_(rset); // Reset the state of the remembered set. - ACQUIRE_SM_LOCK; init_mark_queue_(rset); rset->is_upd_rem_set = true; - RELEASE_SM_LOCK; } /* @@ -468,9 +468,7 @@ push (MarkQueue *q, const MarkQueueEnt *ent) } /* A variant of push to be used by the minor GC when it encounters a reference - * to an object in the non-moving heap. In contrast to the other push - * operations this uses the gc_alloc_block_sync spinlock instead of the - * SM_LOCK to allocate new blocks in the event that the mark queue is full. + * to an object in the non-moving heap. */ void markQueuePushClosureGC (MarkQueue *q, StgClosure *p) @@ -491,13 +489,13 @@ markQueuePushClosureGC (MarkQueue *q, StgClosure *p) if (q->top->head == MARK_QUEUE_BLOCK_ENTRIES) { // Yes, this block is full. // allocate a fresh block. - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); + ACQUIRE_SM_LOCK; bdescr *bd = allocGroup(MARK_QUEUE_BLOCKS); bd->link = q->blocks; q->blocks = bd; q->top = (MarkQueueBlock *) bd->start; q->top->head = 0; - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); + RELEASE_SM_LOCK; } MarkQueueEnt ent = { @@ -647,6 +645,16 @@ void updateRemembSetPushThunkEager(Capability *cap, } break; } + case THUNK_SELECTOR: + { + StgSelector *sel = (StgSelector *) thunk; + if (check_in_nonmoving_heap(sel->selectee)) { + // Don't bother to push origin; it makes the barrier needlessly + // expensive with little benefit. + push_closure(queue, sel->selectee, NULL); + } + break; + } case AP: { StgAP *ap = (StgAP *) thunk; @@ -656,9 +664,11 @@ void updateRemembSetPushThunkEager(Capability *cap, trace_PAP_payload(queue, ap->fun, ap->payload, ap->n_args); break; } - case THUNK_SELECTOR: + // We may end up here if a thunk update races with another update. + // In this case there is nothing to do as the other thread will have + // already pushed the updated thunk's free variables to the update + // remembered set. case BLACKHOLE: - // TODO: This is right, right? break; // The selector optimization performed by the nonmoving mark may have // overwritten a thunk which we are updating with an indirection. @@ -916,7 +926,8 @@ static MarkQueueEnt markQueuePop (MarkQueue *q) /* Must hold sm_mutex. */ static void init_mark_queue_ (MarkQueue *queue) { - bdescr *bd = allocGroup(MARK_QUEUE_BLOCKS); + bdescr *bd = allocGroup_lock(MARK_QUEUE_BLOCKS); + ASSERT(queue->blocks == NULL); queue->blocks = bd; queue->top = (MarkQueueBlock *) bd->start; queue->top->head = 0; @@ -926,14 +937,12 @@ static void init_mark_queue_ (MarkQueue *queue) #endif } -/* Must hold sm_mutex. */ void initMarkQueue (MarkQueue *queue) { init_mark_queue_(queue); queue->is_upd_rem_set = false; } -/* Must hold sm_mutex. */ void nonmovingInitUpdRemSet (UpdRemSet *rset) { init_mark_queue_(&rset->queue); @@ -1522,10 +1531,12 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) break; } + case WEAK: + ASSERT(isNonmovingWeak((StgWeak*) p)); + // fallthrough gen_obj: case CONSTR: case CONSTR_NOCAF: - case WEAK: case PRIM: { for (StgWord i = 0; i < info->layout.payload.ptrs; i++) { @@ -1582,8 +1593,15 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) } case THUNK_SELECTOR: - nonmoving_eval_thunk_selector(queue, (StgSelector*)p, origin); + { + StgSelector *sel = (StgSelector *) p; + // We may be able to evaluate this selector which may render the + // selectee unreachable. However, we must mark the selectee regardless + // to satisfy the snapshot invariant. + PUSH_FIELD(sel, selectee); + nonmoving_eval_thunk_selector(queue, sel, origin); break; + } case AP_STACK: { StgAP_STACK *ap = (StgAP_STACK *)p; @@ -1915,6 +1933,17 @@ void nonmovingMarkWeakPtrList (struct MarkQueue_ *queue) } } +static bool isNonmovingWeak(StgWeak *weak) +{ + for (StgWeak *w = nonmoving_old_weak_ptr_list; w != NULL; w = w->link) { + if (w == weak) return true; + } + for (StgWeak *w = nonmoving_weak_ptr_list; w != NULL; w = w->link) { + if (w == weak) return true; + } + return false; +} + // Non-moving heap variant of `tidyWeakList` bool nonmovingTidyWeaks (struct MarkQueue_ *queue) { @@ -1947,7 +1976,7 @@ bool nonmovingTidyWeaks (struct MarkQueue_ *queue) *last_w = w->link; next_w = w->link; - // and put it on the weak ptr list + // and put it on nonmoving_weak_ptr_list w->link = nonmoving_weak_ptr_list; nonmoving_weak_ptr_list = w; } else { ===================================== rts/sm/NonMovingMark.h ===================================== @@ -9,10 +9,11 @@ #pragma once #include "Task.h" -#include "NonMoving.h" #include "BeginPrivate.h" +struct NonMovingHeap; + enum EntryType { NULL_ENTRY = 0, MARK_CLOSURE = 1, @@ -63,7 +64,7 @@ INLINE_HEADER enum EntryType nonmovingMarkQueueEntryType(MarkQueueEnt *ent) { uintptr_t tag = (uintptr_t) ent->null_entry.p & TAG_MASK; ASSERT(tag <= MARK_ARRAY); - return tag; + return (enum EntryType) tag; } typedef struct { @@ -155,7 +156,7 @@ void markQueueAddRoot(MarkQueue* q, StgClosure** root); void initMarkQueue(MarkQueue *queue); void freeMarkQueue(MarkQueue *queue); -void nonmovingMark(struct MarkQueue_ *restrict queue); +void nonmovingMark(struct MarkQueue_ *__restrict__ queue); void nonmovingMarkWeakPtrList(struct MarkQueue_ *queue); bool nonmovingTidyWeaks(struct MarkQueue_ *queue); ===================================== rts/sm/NonMovingShortcut.c ===================================== @@ -10,6 +10,7 @@ #include "Rts.h" #include "GC.h" #include "SMPClosureOps.h" +#include "NonMoving.h" #include "NonMovingMark.h" #include "NonMovingShortcut.h" #include "Printer.h" ===================================== rts/sm/Sanity.c ===================================== @@ -639,6 +639,7 @@ void checkNonmovingHeap (const struct NonmovingHeap *heap) for (unsigned int i=0; i < NONMOVING_ALLOCA_CNT; i++) { const struct NonmovingAllocator *alloc = heap->allocators[i]; checkNonmovingSegments(alloc->filled); + checkNonmovingSegments(alloc->saved_filled); checkNonmovingSegments(alloc->active); for (unsigned int cap=0; cap < getNumCapabilities(); cap++) { checkNonmovingSegments(alloc->current[cap]); @@ -1071,6 +1072,7 @@ findMemoryLeak (void) for (i = 0; i < NONMOVING_ALLOCA_CNT; i++) { struct NonmovingAllocator *alloc = nonmovingHeap.allocators[i]; markNonMovingSegments(alloc->filled); + markNonMovingSegments(alloc->saved_filled); markNonMovingSegments(alloc->active); for (j = 0; j < getNumCapabilities(); j++) { markNonMovingSegments(alloc->current[j]); ===================================== rts/sm/Sanity.h ===================================== @@ -19,6 +19,8 @@ # define MAX_SLOTS 100000 # endif +struct NonmovingHeap; + /* debugging routines */ void checkSanity ( bool after_gc, bool major_gc ); void checkNurserySanity ( nursery *nursery ); ===================================== rts/sm/Scav.c ===================================== @@ -1730,7 +1730,7 @@ scavenge_capability_mut_lists (Capability *cap) if (RtsFlags.GcFlags.useNonmoving && major_gc) { uint32_t g = oldest_gen->no; scavenge_mutable_list(cap->saved_mut_lists[g], oldest_gen); - freeChain_sync(cap->saved_mut_lists[g]); + freeChain_lock(cap->saved_mut_lists[g]); cap->saved_mut_lists[g] = NULL; return; } @@ -1743,7 +1743,7 @@ scavenge_capability_mut_lists (Capability *cap) */ for (uint32_t g = RtsFlags.GcFlags.generations-1; g > N; g--) { scavenge_mutable_list(cap->saved_mut_lists[g], &generations[g]); - freeChain_sync(cap->saved_mut_lists[g]); + freeChain_lock(cap->saved_mut_lists[g]); cap->saved_mut_lists[g] = NULL; } } ===================================== rts/sm/Storage.c ===================================== @@ -193,14 +193,13 @@ initStorage (void) initMutex(&sm_mutex); #endif - ACQUIRE_SM_LOCK; - /* allocate generation info array */ generations = (generation *)stgMallocBytes(RtsFlags.GcFlags.generations * sizeof(struct generation_), "initStorage: gens"); /* Initialise all generations */ + ACQUIRE_SM_LOCK; for(g = 0; g < RtsFlags.GcFlags.generations; g++) { initGeneration(&generations[g], g); } @@ -214,16 +213,11 @@ initStorage (void) generations[g].to = &generations[g+1]; } oldest_gen->to = oldest_gen; + RELEASE_SM_LOCK; // Nonmoving heap uses oldest_gen so initialize it after initializing oldest_gen nonmovingInit(); -#if defined(THREADED_RTS) - // nonmovingAddCapabilities allocates segments, which requires taking the gc - // sync lock, so initialize it before nonmovingAddCapabilities - initSpinLock(&gc_alloc_block_sync); -#endif - if (RtsFlags.GcFlags.useNonmoving) nonmovingAddCapabilities(getNumCapabilities()); @@ -261,8 +255,6 @@ initStorage (void) IF_DEBUG(gc, statDescribeGens()); - RELEASE_SM_LOCK; - traceInitEvent(traceHeapInfo); } @@ -314,17 +306,20 @@ void storageAddCapabilities (uint32_t from, uint32_t to) assignNurseriesToCapabilities(from,to); // allocate a block for each mut list + ACQUIRE_SM_LOCK; for (n = from; n < to; n++) { for (g = 1; g < RtsFlags.GcFlags.generations; g++) { getCapability(n)->mut_lists[g] = allocBlockOnNode(capNoToNumaNode(n)); } } + RELEASE_SM_LOCK; // Initialize NonmovingAllocators and UpdRemSets if (RtsFlags.GcFlags.useNonmoving) { nonmovingAddCapabilities(to); - for (i = 0; i < to; ++i) { + for (i = from; i < to; i++) { + getCapability(i)->upd_rem_set.queue.blocks = NULL; nonmovingInitUpdRemSet(&getCapability(i)->upd_rem_set); } } @@ -564,9 +559,7 @@ lockCAF (StgRegTable *reg, StgIndStatic *caf) // Allocate the blackhole indirection closure if (RtsFlags.GcFlags.useNonmoving) { // See Note [Static objects under the nonmoving collector]. - ACQUIRE_SM_LOCK; bh = (StgInd *)nonmovingAllocate(cap, sizeofW(*bh)); - RELEASE_SM_LOCK; recordMutableCap((StgClosure*)bh, regTableToCapability(reg), oldest_gen->no); } else { @@ -724,6 +717,7 @@ allocNursery (uint32_t node, bdescr *tail, W_ blocks) // automatic prefetching works across nursery blocks. This is a // tiny optimisation (~0.5%), but it's free. + ACQUIRE_SM_LOCK; while (blocks > 0) { n = stg_min(BLOCKS_PER_MBLOCK, blocks); // allocLargeChunk will prefer large chunks, but will pick up @@ -759,6 +753,7 @@ allocNursery (uint32_t node, bdescr *tail, W_ blocks) tail = &bd[0]; } + RELEASE_SM_LOCK; return &bd[0]; } @@ -878,7 +873,7 @@ resizeNurseriesEach (W_ blocks) next_bd = bd->link; next_bd->u.back = NULL; nursery_blocks -= bd->blocks; // might be a large block - freeGroup(bd); + freeGroup_lock(bd); bd = next_bd; } nursery->blocks = bd; @@ -1299,9 +1294,7 @@ allocatePinned (Capability *cap, W_ n /*words*/, W_ alignment /*bytes*/, W_ alig if (bd == NULL) { // The pinned block list is empty: allocate a fresh block (we can't fail // here). - ACQUIRE_SM_LOCK; bd = allocNursery(cap->node, NULL, PINNED_EMPTY_SIZE); - RELEASE_SM_LOCK; } // Bump up the nursery pointer to avoid the pathological situation View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1fdffe157170bb42741c44bb03d44f61ed5f8822...f095454b5bcf0d604e62c784931f80b5d7f0fb88 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1fdffe157170bb42741c44bb03d44f61ed5f8822...f095454b5bcf0d604e62c784931f80b5d7f0fb88 You're receiving 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 Dec 5 04:52:29 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Sun, 04 Dec 2022 23:52:29 -0500 Subject: [Git][ghc/ghc][wip/int-index/epa-bufspan] Add BufSpan to EpaLocation (#22319, #22558) Message-ID: <638d790d1c1b4_17512e2fdaf370103971@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/epa-bufspan at Glasgow Haskell Compiler / GHC Commits: e1fa730d by Vladislav Zavialov at 2022-12-05T07:49:51+03:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 11 changed files: - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/SrcLoc.hs - utils/check-exact/ExactPrint.hs - utils/check-exact/Parsers.hs - utils/check-exact/Transform.hs - utils/check-exact/Utils.hs Changes: ===================================== compiler/GHC/Hs/Dump.hs ===================================== @@ -144,7 +144,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 _ -> parens $ text "SourceText" <+> text "blanked" epaAnchor :: EpaLocation -> SDoc - epaAnchor (EpaSpan r) = parens $ text "EpaSpan" <+> realSrcSpan r + epaAnchor (EpaSpan r _) = parens $ text "EpaSpan" <+> realSrcSpan r epaAnchor (EpaDelta d cs) = case ba of NoBlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> showAstData' cs BlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> text "blanked" ===================================== compiler/GHC/Parser.y ===================================== @@ -3058,34 +3058,34 @@ tup_exprs :: { forall b. DisambECP b => PV (SumOrTuple b) } : texp commas_tup_tail { unECP $1 >>= \ $1 -> $2 >>= \ $2 -> - do { t <- amsA $1 [AddCommaAnn (EpaSpan $ rs $ fst $2)] + do { t <- amsA $1 [AddCommaAnn (srcSpan2e $ fst $2)] ; return (Tuple (Right t : snd $2)) } } | commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) (EpaSpan $ rs ll) emptyComments))) (fst $1) } + do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) (srcSpan2e ll) emptyComments))) (fst $1) } ; return (Tuple (cos ++ $2)) } } | texp bars { unECP $1 >>= \ $1 -> return $ - (Sum 1 (snd $2 + 1) $1 [] (map (EpaSpan . realSrcSpan) $ fst $2)) } + (Sum 1 (snd $2 + 1) $1 [] (map srcSpan2e $ fst $2)) } | bars texp bars0 { unECP $2 >>= \ $2 -> return $ (Sum (snd $1 + 1) (snd $1 + snd $3 + 1) $2 - (map (EpaSpan . realSrcSpan) $ fst $1) - (map (EpaSpan . realSrcSpan) $ fst $3)) } + (map srcSpan2e $ fst $1) + (map srcSpan2e $ fst $3)) } -- Always starts with commas; always follows an expr commas_tup_tail :: { forall b. DisambECP b => PV (SrcSpan,[Either (EpAnn EpaLocation) (LocatedA b)]) } commas_tup_tail : commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) (EpaSpan $ rs l) emptyComments))) (tail $ fst $1) } + do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) (srcSpan2e l) emptyComments))) (tail $ fst $1) } ; return ((head $ fst $1, cos ++ $2)) } } -- Always follows a comma tup_tail :: { forall b. DisambECP b => PV [Either (EpAnn EpaLocation) (LocatedA b)] } : texp commas_tup_tail { unECP $1 >>= \ $1 -> $2 >>= \ $2 -> - do { t <- amsA $1 [AddCommaAnn (EpaSpan $ rs $ fst $2)] + do { t <- amsA $1 [AddCommaAnn (srcSpan2e $ fst $2)] ; return (Right t : snd $2) } } | texp { unECP $1 >>= \ $1 -> return [Right $1] } @@ -3564,10 +3564,10 @@ qcon_list : qcon { sL1N $1 [$1] } sysdcon_nolist :: { LocatedN DataCon } -- Wired in data constructors : '(' ')' {% amsrn (sLL $1 $> unitDataCon) (NameAnnOnly NameParens (glAA $1) (glAA $2) []) } | '(' commas ')' {% amsrn (sLL $1 $> $ tupleDataCon Boxed (snd $2 + 1)) - (NameAnnCommas NameParens (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParens (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' '#)' {% amsrn (sLL $1 $> $ unboxedUnitDataCon) (NameAnnOnly NameParensHash (glAA $1) (glAA $2) []) } | '(#' commas '#)' {% amsrn (sLL $1 $> $ tupleDataCon Unboxed (snd $2 + 1)) - (NameAnnCommas NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } -- See Note [Empty lists] in GHC.Hs.Expr sysdcon :: { LocatedN DataCon } @@ -3601,12 +3601,12 @@ ntgtycon :: { LocatedN RdrName } -- A "general" qualified tycon, excluding unit : oqtycon { $1 } | '(' commas ')' {% amsrn (sLL $1 $> $ getRdrName (tupleTyCon Boxed (snd $2 + 1))) - (NameAnnCommas NameParens (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParens (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' commas '#)' {% amsrn (sLL $1 $> $ getRdrName (tupleTyCon Unboxed (snd $2 + 1))) - (NameAnnCommas NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' bars '#)' {% amsrn (sLL $1 $> $ getRdrName (sumTyCon (snd $2 + 1))) - (NameAnnBars NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnBars NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(' '->' ')' {% amsrn (sLL $1 $> $ getRdrName unrestrictedFunTyCon) (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } | '[' ']' {% amsrn (sLL $1 $> $ listTyCon_RDR) @@ -4210,27 +4210,27 @@ in GHC.Parser.Annotation -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself mj :: AnnKeywordId -> Located e -> AddEpAnn -mj a l = AddEpAnn a (EpaSpan $ rs $ gl l) +mj a l = AddEpAnn a (srcSpan2e $ gl l) mjN :: AnnKeywordId -> LocatedN e -> AddEpAnn -mjN a l = AddEpAnn a (EpaSpan $ rs $ glN l) +mjN a l = AddEpAnn a (srcSpan2e $ glN l) -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself, provided the span is not zero width mz :: AnnKeywordId -> Located e -> [AddEpAnn] -mz a l = if isZeroWidthSpan (gl l) then [] else [AddEpAnn a (EpaSpan $ rs $ gl l)] +mz a l = if isZeroWidthSpan (gl l) then [] else [AddEpAnn a (srcSpan2e $ gl l)] msemi :: Located e -> [TrailingAnn] -msemi l = if isZeroWidthSpan (gl l) then [] else [AddSemiAnn (EpaSpan $ rs $ gl l)] +msemi l = if isZeroWidthSpan (gl l) then [] else [AddSemiAnn (srcSpan2e $ gl l)] msemim :: Located e -> Maybe EpaLocation -msemim l = if isZeroWidthSpan (gl l) then Nothing else Just (EpaSpan $ rs $ gl l) +msemim l = if isZeroWidthSpan (gl l) then Nothing else Just (srcSpan2e $ gl l) -- |Construct an AddEpAnn from the annotation keyword and the Located Token. If -- the token has a unicode equivalent and this has been used, provide the -- unicode variant of the annotation. mu :: AnnKeywordId -> Located Token -> AddEpAnn -mu a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (EpaSpan $ rs l) +mu a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (srcSpan2e l) -- | If the 'Token' is using its unicode variant return the unicode variant of -- the annotation @@ -4253,7 +4253,7 @@ glR :: Located a -> Anchor glR la = Anchor (realSrcSpan $ getLoc la) UnchangedAnchor glAA :: Located a -> EpaLocation -glAA = EpaSpan <$> realSrcSpan . getLoc +glAA = srcSpan2e . getLoc glRR :: Located a -> RealSrcSpan glRR = realSrcSpan . getLoc @@ -4265,7 +4265,7 @@ glNR :: LocatedN a -> Anchor glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor glNRR :: LocatedN a -> EpaLocation -glNRR = EpaSpan <$> realSrcSpan . getLocA +glNRR = srcSpan2e . getLocA anc :: RealSrcSpan -> Anchor anc r = Anchor r UnchangedAnchor @@ -4395,7 +4395,7 @@ rs _ = panic "Parser should only have RealSrcSpan" hsDoAnn :: Located a -> LocatedAn t b -> AnnKeywordId -> AnnList hsDoAnn (L l _) (L ll _) kw - = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (EpaSpan $ rs l)] [] + = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (srcSpan2e l)] [] listAsAnchor :: [LocatedAn t a] -> Anchor listAsAnchor [] = spanAsAnchor noSrcSpan @@ -4435,16 +4435,16 @@ addTrailingAnnA (L (SrcSpanAnn anns l) a) ss ta = do let anns' = if isZeroWidthSpan ss then anns - else addTrailingAnnToA l (ta (EpaSpan $ rs ss)) cs anns + else addTrailingAnnToA l (ta (srcSpan2e ss)) cs anns return (L (SrcSpanAnn anns' l) a) -- ------------------------------------- addTrailingVbarL :: MonadP m => LocatedL a -> SrcSpan -> m (LocatedL a) -addTrailingVbarL la span = addTrailingAnnL la (AddVbarAnn (EpaSpan $ rs span)) +addTrailingVbarL la span = addTrailingAnnL la (AddVbarAnn (srcSpan2e span)) addTrailingCommaL :: MonadP m => LocatedL a -> SrcSpan -> m (LocatedL a) -addTrailingCommaL la span = addTrailingAnnL la (AddCommaAnn (EpaSpan $ rs span)) +addTrailingCommaL la span = addTrailingAnnL la (AddCommaAnn (srcSpan2e span)) addTrailingAnnL :: MonadP m => LocatedL a -> TrailingAnn -> m (LocatedL a) addTrailingAnnL (L (SrcSpanAnn anns l) a) ta = do @@ -4462,7 +4462,7 @@ addTrailingCommaN (L (SrcSpanAnn anns l) a) span = do -- AZ:TODO: generalise updating comments into an annotation let anns' = if isZeroWidthSpan span then anns - else addTrailingCommaToN l anns (EpaSpan $ rs span) + else addTrailingCommaToN l anns (srcSpan2e span) return (L (SrcSpanAnn anns' l) a) addTrailingCommaS :: Located StringLiteral -> EpaLocation -> Located StringLiteral ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( la2na, na2la, n2l, l2n, l2l, la2la, reLoc, reLocA, reLocL, reLocC, reLocN, - la2r, realSrcSpan, + srcSpan2e, la2e, realSrcSpan, -- ** Building up annotations extraToAnnList, reAnn, @@ -403,7 +403,7 @@ data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq) -- in the @'EpaDelta'@ variant captures any comments between the prior -- output and the thing being marked here, since we cannot otherwise -- sort the relative order. -data EpaLocation = EpaSpan !RealSrcSpan +data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] deriving (Data,Eq) @@ -447,15 +447,15 @@ getDeltaLine (DifferentLine r _) = r -- 'EpaLocation'. The parser will never insert a 'DeltaPos', so the -- partial function is safe. epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan -epaLocationRealSrcSpan (EpaSpan r) = r +epaLocationRealSrcSpan (EpaSpan r _) = r epaLocationRealSrcSpan (EpaDelta _ _) = panic "epaLocationRealSrcSpan" epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation -epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) -epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) +epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) Strict.Nothing +epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) Strict.Nothing instance Outputable EpaLocation where - ppr (EpaSpan r) = text "EpaSpan" <+> ppr r + ppr (EpaSpan r _) = text "EpaSpan" <+> ppr r ppr (EpaDelta d cs) = text "EpaDelta" <+> ppr d <+> ppr cs instance Outputable AddEpAnn where @@ -916,8 +916,12 @@ realSrcSpan _ = mkRealSrcSpan l l -- AZ temporary where l = mkRealSrcLoc (fsLit "foo") (-1) (-1) -la2r :: SrcSpanAnn' a -> RealSrcSpan -la2r l = realSrcSpan (locA l) +srcSpan2e :: SrcSpan -> EpaLocation +srcSpan2e (RealSrcSpan s mb) = EpaSpan s mb +srcSpan2e span = EpaSpan (realSrcSpan span) Strict.Nothing + +la2e :: SrcSpanAnn' a -> EpaLocation +la2e = srcSpan2e . locA extraToAnnList :: AnnList -> [AddEpAnn] -> AnnList extraToAnnList (AnnList a o c e t) as = AnnList a o c (e++as) t @@ -976,7 +980,7 @@ widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan widenSpan s as = foldl combineSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s):rest) = RealSrcSpan s Strict.Nothing : go rest + go (AddEpAnn _ (EpaSpan s mb):rest) = RealSrcSpan s mb : go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest -- | The annotations need to all come after the anchor. Make sure @@ -985,7 +989,7 @@ widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan widenRealSpan s as = foldl combineRealSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s):rest) = s : go rest + go (AddEpAnn _ (EpaSpan s _):rest) = s : go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest widenAnchor :: Anchor -> [AddEpAnn] -> Anchor ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3646,7 +3646,7 @@ warn_unknown_prag prags span buf len buf2 = do -- 'AddEpAnn' values for the opening and closing bordering on the start -- and end of the span mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) -mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo),AddEpAnn AnnCloseP (EpaSpan lc)) +mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCloseP (EpaSpan lc Strict.Nothing)) where f = srcSpanFile ss sl = srcSpanStartLine ss ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -471,13 +471,13 @@ annBinds a cs (HsIPBinds an bs) = (HsIPBinds (add_where a an cs) bs, Nothing) annBinds _ cs (EmptyLocalBinds x) = (EmptyLocalBinds x, Just cs) add_where :: AddEpAnn -> EpAnn AnnList -> EpAnnComments -> EpAnn AnnList -add_where an@(AddEpAnn _ (EpaSpan rs)) (EpAnn a (AnnList anc o c r t) cs) cs2 +add_where an@(AddEpAnn _ (EpaSpan rs _)) (EpAnn a (AnnList anc o c r t) cs) cs2 | valid_anchor (anchor a) = EpAnn (widenAnchor a [an]) (AnnList anc o c (an:r) t) (cs Semi.<> cs2) | otherwise = EpAnn (patch_anchor rs a) (AnnList (fmap (patch_anchor rs) anc) o c (an:r) t) (cs Semi.<> cs2) -add_where an@(AddEpAnn _ (EpaSpan rs)) EpAnnNotUsed cs +add_where an@(AddEpAnn _ (EpaSpan rs _)) EpAnnNotUsed cs = EpAnn (Anchor rs UnchangedAnchor) (AnnList (Just $ Anchor rs UnchangedAnchor) Nothing Nothing [an] []) cs add_where (AddEpAnn _ (EpaDelta _ _)) _ _ = panic "add_where" @@ -501,7 +501,7 @@ fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) -- | The 'Anchor' for a stmtlist is based on either the location or -- the first semicolon annotion. stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Anchor -stmtsAnchor (L l ((ConsOL (AddEpAnn _ (EpaSpan r)) _), _)) +stmtsAnchor (L l ((ConsOL (AddEpAnn _ (EpaSpan r _)) _), _)) = widenAnchorR (Anchor (realSrcSpan l) UnchangedAnchor) r stmtsAnchor (L l _) = Anchor (realSrcSpan l) UnchangedAnchor @@ -1039,13 +1039,13 @@ checkTyClHdr is_cls ty newAnns (SrcSpanAnn EpAnnNotUsed l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (realSrcSpan l) (anchor as) - an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (EpaSpan $ realSrcSpan l) c []) cs) + an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (srcSpan2e l) c []) cs) in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) newAnns _ EpAnnNotUsed = panic "missing AnnParen" newAnns (SrcSpanAnn (EpAnn ap (AnnListItem ta) csp) l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (anchor ap) (anchor as) - an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (EpaSpan $ realSrcSpan l) c ta) (csp Semi.<> cs)) + an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs)) in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) -- | Yield a parse error if we have a function applied directly to a do block @@ -2855,7 +2855,7 @@ checkImportSpec ie@(L _ specs) = mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P ([AddEpAnn], ImpExpSubSpec) mkImpExpSubSpec [] = return ([], ImpExpList []) mkImpExpSubSpec [L la ImpExpQcWildcard] = - return ([AddEpAnn AnnDotdot (EpaSpan $ la2r la)], ImpExpAll) + return ([AddEpAnn AnnDotdot (la2e la)], ImpExpAll) mkImpExpSubSpec xs = if (any (isImpExpQcWildcard . unLoc) xs) then return $ ([], ImpExpAllWith xs) @@ -3124,14 +3124,14 @@ mkMultTy pct t arr = HsExplicitMult pct t arr mkTokenLocation :: SrcSpan -> TokenLocation mkTokenLocation (UnhelpfulSpan _) = NoTokenLoc -mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) +mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) -- Precondition: the TokenLocation has EpaSpan, never EpaDelta. token_location_widenR :: TokenLocation -> SrcSpan -> TokenLocation token_location_widenR NoTokenLoc _ = NoTokenLoc token_location_widenR tl (UnhelpfulSpan _) = tl -token_location_widenR (TokenLoc (EpaSpan r1)) (RealSrcSpan r2 _) = - (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2))) +token_location_widenR (TokenLoc (EpaSpan r1 mb1)) (RealSrcSpan r2 mb2) = + (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2) (liftA2 combineBufSpans mb1 mb2))) token_location_widenR (TokenLoc (EpaDelta _ _)) _ = -- Never happens because the parser does not produce EpaDelta. panic "token_location_widenR: EpaDelta" ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -2011,14 +2011,14 @@ printMinimalImports hsc_src imports_w_usage to_ie_post_rn_var :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn_var (L l n) - | isDataOcc $ occName n = L l (IEPattern (EpaSpan $ la2r l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (la2na l) n)) + | otherwise = L l (IEName noExtField (L (la2na l) n)) to_ie_post_rn :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn (L l n) - | isTcOcc occ && isSymOcc occ = L l (IEType (EpaSpan $ la2r l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (la2na l) n)) + | otherwise = L l (IEName noExtField (L (la2na l) n)) where occ = occName n {- ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Types.SrcLoc ( BufSpan(..), getBufSpan, removeBufSpan, + combineBufSpans, -- * Located Located, ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -543,7 +543,7 @@ printStringAtAAL (EpAnn anc an cs) l str = do printStringAtAAC :: (Monad m, Monoid w) => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation -printStringAtAAC capture (EpaSpan r) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s printStringAtAAC capture (EpaDelta d cs) s = do mapM_ (printOneComment . tokComment) cs pe1 <- getPriorEndD @@ -4108,7 +4108,7 @@ printUnicode anc n = do s -> s loc <- printStringAtAAC NoCaptureComments (EpaDelta (SameLine 0) []) str case loc of - EpaSpan _ -> return anc + EpaSpan _ _ -> return anc EpaDelta dp [] -> return anc { anchor_op = MovedAnchor dp } EpaDelta _ _cs -> error "printUnicode should not capture comments" ===================================== utils/check-exact/Parsers.hs ===================================== @@ -285,7 +285,7 @@ fixModuleTrailingComments (GHC.L l p) = GHC.L l p' rebalance al cs = cs' where cs' = case GHC.al_close al of - Just (GHC.AddEpAnn _ (GHC.EpaSpan ss)) -> + Just (GHC.AddEpAnn _ (GHC.EpaSpan ss _)) -> let pc = GHC.priorComments cs fc = GHC.getFollowingComments cs ===================================== utils/check-exact/Transform.hs ===================================== @@ -213,7 +213,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H L (SrcSpanAnn EpAnnNotUsed ll) _ -> realSrcSpan ll L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor? dc' = case dca of - EpaSpan r -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) + EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) EpaDelta _ _ -> AddEpAnn kw dca -- --------------------------------- @@ -223,7 +223,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H (L (SrcSpanAnn EpAnnNotUsed ll) b) -> let op = case dca of - EpaSpan r -> MovedAnchor (ss2delta (ss2posEnd r) (realSrcSpan ll)) + EpaSpan r _ -> MovedAnchor (ss2delta (ss2posEnd r) (realSrcSpan ll)) EpaDelta _ _ -> MovedAnchor (SameLine 1) in (L (SrcSpanAnn (EpAnn (Anchor (realSrcSpan ll) op) mempty emptyComments) ll) b) (L (SrcSpanAnn (EpAnn (Anchor r op) a c) ll) b) @@ -231,7 +231,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H op' = case op of MovedAnchor _ -> op _ -> case dca of - EpaSpan dcr -> MovedAnchor (ss2delta (ss2posEnd dcr) r) + EpaSpan dcr _ -> MovedAnchor (ss2delta (ss2posEnd dcr) r) EpaDelta _ _ -> MovedAnchor (SameLine 1) in (L (SrcSpanAnn (EpAnn (Anchor r op') a c) ll) b) @@ -341,13 +341,13 @@ getEntryDP _ = SameLine 1 addEpaLocationDelta :: LayoutStartCol -> RealSrcSpan -> EpaLocation -> EpaLocation addEpaLocationDelta _off _anc (EpaDelta d cs) = EpaDelta d cs -addEpaLocationDelta off anc (EpaSpan r) +addEpaLocationDelta off anc (EpaSpan r _) = EpaDelta (adjustDeltaForOffset off (ss2deltaEnd anc r)) [] -- Set the entry DP for an element coming after an existing keyword annotation setEntryDPFromAnchor :: LayoutStartCol -> EpaLocation -> LocatedA t -> LocatedA t setEntryDPFromAnchor _off (EpaDelta _ _) (L la a) = L la a -setEntryDPFromAnchor off (EpaSpan anc) ll@(L la _) = setEntryDP ll dp' +setEntryDPFromAnchor off (EpaSpan anc _) ll@(L la _) = setEntryDP ll dp' where r = case la of (SrcSpanAnn EpAnnNotUsed l) -> realSrcSpan l @@ -944,7 +944,7 @@ instance HasDecls (LocatedA (HsExpr GhcPs)) where (L (TokenLoc l) ls, L (TokenLoc i) is) -> let off = case l of - (EpaSpan r) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan r _) -> LayoutStartCol $ snd $ ss2pos r (EpaDelta (SameLine _) _) -> LayoutStartCol 0 (EpaDelta (DifferentLine _ c) _) -> LayoutStartCol c ex'' = setEntryDPFromAnchor off i ex ===================================== utils/check-exact/Utils.hs ===================================== @@ -119,7 +119,7 @@ undelta (l,_) (DifferentLine dl dc) (LayoutStartCol co) = (fl,fc) fc = co + dc undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn -undeltaSpan anchor kw dp = AddEpAnn kw (EpaSpan sp) +undeltaSpan anchor kw dp = AddEpAnn kw (EpaSpan sp Strict.Nothing) where (l,c) = undelta (ss2pos anchor) dp (LayoutStartCol 0) len = length (keywordToString kw) @@ -256,7 +256,7 @@ sortEpaComments cs = sortBy cmp cs -- | Makes a comment which originates from a specific keyword. mkKWComment :: AnnKeywordId -> EpaLocation -> Comment -mkKWComment kw (EpaSpan ss) +mkKWComment kw (EpaSpan ss _) = Comment (keywordToString kw) (Anchor ss UnchangedAnchor) ss (Just kw) mkKWComment kw (EpaDelta dp _) = Comment (keywordToString kw) (Anchor placeholderRealSpan (MovedAnchor dp)) placeholderRealSpan (Just kw) @@ -373,7 +373,7 @@ addEpAnnLoc (AddEpAnn _ l) = l -- TODO: move this to GHC anchorToEpaLocation :: Anchor -> EpaLocation -anchorToEpaLocation (Anchor r UnchangedAnchor) = EpaSpan r +anchorToEpaLocation (Anchor r UnchangedAnchor) = EpaSpan r Strict.Nothing anchorToEpaLocation (Anchor _ (MovedAnchor dp)) = EpaDelta dp [] -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e1fa730d319fa475b4eab79d95bcbe213ff43a48 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e1fa730d319fa475b4eab79d95bcbe213ff43a48 You're receiving 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 Dec 5 07:38:27 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 05 Dec 2022 02:38:27 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Mark T16916 fragile Message-ID: <638d9ff3ad675_17512e240afea01057787@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1edc2579 by Vladislav Zavialov at 2022-12-05T02:38:05-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 27 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/SrcLoc.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - testsuite/tests/lib/base/all.T - + testsuite/tests/type-data/should_compile/TD_TH_splice.hs - testsuite/tests/type-data/should_compile/all.T - + testsuite/tests/type-data/should_run/T22500.hs - + testsuite/tests/type-data/should_run/T22500.stdout - testsuite/tests/type-data/should_run/all.T - utils/check-exact/ExactPrint.hs - utils/check-exact/Parsers.hs - utils/check-exact/Transform.hs - utils/check-exact/Utils.hs Changes: ===================================== compiler/GHC/Builtin/Names/TH.hs ===================================== @@ -69,7 +69,7 @@ templateHaskellNames = [ -- Stmt bindSName, letSName, noBindSName, parSName, recSName, -- Dec - funDName, valDName, dataDName, newtypeDName, tySynDName, + funDName, valDName, dataDName, newtypeDName, typeDataDName, tySynDName, classDName, instanceWithOverlapDName, standaloneDerivWithStrategyDName, sigDName, kiSigDName, forImpDName, pragInlDName, pragOpaqueDName, pragSpecDName, pragSpecInlDName, pragSpecInstDName, @@ -354,7 +354,7 @@ parSName = libFun (fsLit "parS") parSIdKey recSName = libFun (fsLit "recS") recSIdKey -- data Dec = ... -funDName, valDName, dataDName, newtypeDName, tySynDName, classDName, +funDName, valDName, dataDName, newtypeDName, typeDataDName, tySynDName, classDName, instanceWithOverlapDName, sigDName, kiSigDName, forImpDName, pragInlDName, pragSpecDName, pragSpecInlDName, pragSpecInstDName, pragRuleDName, pragAnnDName, standaloneDerivWithStrategyDName, defaultSigDName, defaultDName, @@ -366,6 +366,7 @@ funDName = libFun (fsLit "funD") valDName = libFun (fsLit "valD") valDIdKey dataDName = libFun (fsLit "dataD") dataDIdKey newtypeDName = libFun (fsLit "newtypeD") newtypeDIdKey +typeDataDName = libFun (fsLit "typeDataD") typeDataDIdKey tySynDName = libFun (fsLit "tySynD") tySynDIdKey classDName = libFun (fsLit "classD") classDIdKey instanceWithOverlapDName = libFun (fsLit "instanceWithOverlapD") instanceWithOverlapDIdKey @@ -888,7 +889,7 @@ funDIdKey, valDIdKey, dataDIdKey, newtypeDIdKey, tySynDIdKey, classDIdKey, newtypeInstDIdKey, tySynInstDIdKey, standaloneDerivWithStrategyDIdKey, infixLDIdKey, infixRDIdKey, infixNDIdKey, roleAnnotDIdKey, patSynDIdKey, patSynSigDIdKey, pragCompleteDIdKey, implicitParamBindDIdKey, - kiSigDIdKey, defaultDIdKey, pragOpaqueDIdKey :: Unique + kiSigDIdKey, defaultDIdKey, pragOpaqueDIdKey, typeDataDIdKey :: Unique funDIdKey = mkPreludeMiscIdUnique 320 valDIdKey = mkPreludeMiscIdUnique 321 dataDIdKey = mkPreludeMiscIdUnique 322 @@ -923,7 +924,8 @@ pragCompleteDIdKey = mkPreludeMiscIdUnique 350 implicitParamBindDIdKey = mkPreludeMiscIdUnique 351 kiSigDIdKey = mkPreludeMiscIdUnique 352 defaultDIdKey = mkPreludeMiscIdUnique 353 -pragOpaqueDIdKey = mkPreludeMiscIdUnique 354 +pragOpaqueDIdKey = mkPreludeMiscIdUnique 354 +typeDataDIdKey = mkPreludeMiscIdUnique 355 -- type Cxt = ... cxtIdKey :: Unique ===================================== compiler/GHC/Hs/Dump.hs ===================================== @@ -144,7 +144,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 _ -> parens $ text "SourceText" <+> text "blanked" epaAnchor :: EpaLocation -> SDoc - epaAnchor (EpaSpan r) = parens $ text "EpaSpan" <+> realSrcSpan r + epaAnchor (EpaSpan r _) = parens $ text "EpaSpan" <+> realSrcSpan r epaAnchor (EpaDelta d cs) = case ba of NoBlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> showAstData' cs BlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> text "blanked" ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -461,7 +461,7 @@ repTyClD (L loc (FamDecl { tcdFam = fam })) = liftM Just $ repTyClD (L loc (SynDecl { tcdLName = tc, tcdTyVars = tvs, tcdRhs = rhs })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repSynDecl tc1 bndrs rhs ; return (Just (locA loc, dec)) } @@ -469,7 +469,7 @@ repTyClD (L loc (DataDecl { tcdLName = tc , tcdTyVars = tvs , tcdDataDefn = defn })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> repDataDefn tc1 (Left bndrs) defn ; return (Just (locA loc, dec)) } @@ -478,7 +478,7 @@ repTyClD (L loc (ClassDecl { tcdCtxt = cxt, tcdLName = cls, tcdSigs = sigs, tcdMeths = meth_binds, tcdATs = ats, tcdATDefs = atds })) = do { cls1 <- lookupLOcc cls -- See Note [Binders and occurrences] - ; dec <- addQTyVarBinds tvs $ \bndrs -> + ; dec <- addQTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { cxt1 <- repLContext cxt -- See Note [Scoped type variables in quotes] ; (ss, sigs_binds) <- rep_meth_sigs_binds sigs meth_binds @@ -528,10 +528,10 @@ repDataDefn tc opts ; ksig' <- repMaybeLTy ksig ; repNewtype cxt1 tc opts ksig' con' derivs1 } - DataTypeCons _ cons -> do { ksig' <- repMaybeLTy ksig + DataTypeCons type_data cons -> do { ksig' <- repMaybeLTy ksig ; consL <- mapM repC cons ; cons1 <- coreListM conTyConName consL - ; repData cxt1 tc opts ksig' cons1 + ; repData type_data cxt1 tc opts ksig' cons1 derivs1 } } @@ -549,14 +549,11 @@ repFamilyDecl decl@(L loc (FamilyDecl { fdInfo = info , fdResultSig = L _ resultSig , fdInjectivityAnn = injectivity })) = do { tc1 <- lookupLOcc tc -- See Note [Binders and occurrences] - ; let mkHsQTvs :: [LHsTyVarBndr () GhcRn] -> LHsQTyVars GhcRn - mkHsQTvs tvs = HsQTvs { hsq_ext = [] - , hsq_explicit = tvs } - resTyVar = case resultSig of - TyVarSig _ bndr -> mkHsQTvs [bndr] - _ -> mkHsQTvs [] - ; dec <- addTyClTyVarBinds tvs $ \bndrs -> - addTyClTyVarBinds resTyVar $ \_ -> + ; let resTyVar = case resultSig of + TyVarSig _ bndr -> [hsLTyVarName bndr] + _ -> [] + ; dec <- addQTyVarBinds ReuseBoundNames tvs $ \bndrs -> + addSimpleTyVarBinds ReuseBoundNames resTyVar $ case info of ClosedTypeFamily Nothing -> notHandled (ThAbstractClosedTypeFamily decl) @@ -645,7 +642,7 @@ repClsInstD (ClsInstDecl { cid_poly_ty = ty, cid_binds = binds , cid_datafam_insts = adts , cid_overlap_mode = overlap }) - = addSimpleTyVarBinds tvs $ + = addSimpleTyVarBinds FreshNamesOnly tvs $ -- We must bring the type variables into scope, so their -- occurrences don't fail, even though the binders don't -- appear in the resulting data structure @@ -672,7 +669,7 @@ repStandaloneDerivD :: LDerivDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repStandaloneDerivD (L loc (DerivDecl { deriv_strategy = strat , deriv_type = ty })) = do { dec <- repDerivStrategy strat $ \strat' -> - addSimpleTyVarBinds tvs $ + addSimpleTyVarBinds FreshNamesOnly tvs $ do { cxt' <- repLContext cxt ; inst_ty' <- repLTy inst_ty ; repDeriv strat' cxt' inst_ty' } @@ -804,16 +801,17 @@ repDefD (L loc (DefaultDecl _ tys)) = do { tys1 <- repLTys tys repRuleD :: LRuleDecl GhcRn -> MetaM (SrcSpan, Core (M TH.Dec)) repRuleD (L loc (HsRule { rd_name = n , rd_act = act - , rd_tyvs = ty_bndrs + , rd_tyvs = m_ty_bndrs , rd_tmvs = tm_bndrs , rd_lhs = lhs , rd_rhs = rhs })) - = do { rule <- addHsTyVarBinds (fromMaybe [] ty_bndrs) $ \ ex_bndrs -> + = do { let ty_bndrs = fromMaybe [] m_ty_bndrs + ; rule <- addHsTyVarBinds FreshNamesOnly ty_bndrs $ \ ex_bndrs -> do { let tm_bndr_names = concatMap ruleBndrNames tm_bndrs ; ss <- mkGenSyms tm_bndr_names ; rule <- addBinds ss $ do { elt_ty <- wrapName tyVarBndrUnitTyConName - ; ty_bndrs' <- return $ case ty_bndrs of + ; ty_bndrs' <- return $ case m_ty_bndrs of Nothing -> coreNothing' (mkListTy elt_ty) Just _ -> coreJust' (mkListTy elt_ty) ex_bndrs ; tm_bndrs' <- repListM ruleBndrTyConName @@ -878,7 +876,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_ex_tvs = con_tvs , con_mb_cxt = mcxt , con_args = args })) - = addHsTyVarBinds con_tvs $ \ ex_bndrs -> + = addHsTyVarBinds FreshNamesOnly con_tvs $ \ ex_bndrs -> do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt @@ -1188,14 +1186,11 @@ addHsOuterFamEqnTyVarBinds outer_bndrs thing_inside = do elt_ty <- wrapName tyVarBndrUnitTyConName case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> - addTyClTyVarBinds (mk_qtvs imp_tvs []) $ \_th_exp_bndrs -> + addSimpleTyVarBinds ReuseBoundNames imp_tvs $ thing_inside $ coreNothingList elt_ty HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addTyClTyVarBinds (mk_qtvs [] exp_bndrs) $ \th_exp_bndrs -> + addHsTyVarBinds FreshNamesOnly exp_bndrs $ \th_exp_bndrs -> thing_inside $ coreJustList elt_ty th_exp_bndrs - where - mk_qtvs imp_tvs exp_tvs = HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs } addHsOuterSigTyVarBinds :: HsOuterSigTyVarBndrs GhcRn @@ -1204,9 +1199,9 @@ addHsOuterSigTyVarBinds :: addHsOuterSigTyVarBinds outer_bndrs thing_inside = case outer_bndrs of HsOuterImplicit{hso_ximplicit = imp_tvs} -> do th_nil <- coreListM tyVarBndrSpecTyConName [] - addSimpleTyVarBinds imp_tvs $ thing_inside th_nil + addSimpleTyVarBinds FreshNamesOnly imp_tvs $ thing_inside th_nil HsOuterExplicit{hso_bndrs = exp_bndrs} -> - addHsTyVarBinds exp_bndrs thing_inside + addHsTyVarBinds FreshNamesOnly exp_bndrs thing_inside -- | If a type implicitly quantifies its outermost type variables, return -- 'True' if the list of implicitly bound type variables is empty. If a type @@ -1230,69 +1225,86 @@ nullOuterExplicit (HsOuterExplicit{hso_bndrs = exp_bndrs}) = null exp_bndrs nullOuterExplicit (HsOuterImplicit{}) = True -- Vacuously true, as there is no outermost explicit quantification -addSimpleTyVarBinds :: [Name] -- the binders to be added +-- Do we want to generate fresh names for type variables +-- or reuse the ones that are already in scope? +data FreshOrReuse + = FreshNamesOnly + -- Generate fresh names for all type variables, regardless of existing + -- variables in the MetaEnv. + -- + -- This is the default strategy. + + | ReuseBoundNames + -- Generate fresh names for type variables not in the MetaEnv. + -- Where a name is already bound in the MetaEnv, use that existing binding; + -- do not create a new one with a fresh name. + -- + -- This is the strategy used for data/newtype declarations and type family + -- instances, so that the nested type variables work right: + -- + -- class C a where + -- type W a b + -- instance C (T a) where + -- type W (T a) b = blah + -- + -- The 'a' in the type instance is the one bound by the instance decl + -- + -- Test cases: TH_reifyExplicitForAllFams T9081 T9199 T10811 + +mkGenSyms' :: FreshOrReuse -> [Name] -> MetaM [GenSymBind] +mkGenSyms' FreshNamesOnly names = mkGenSyms names +mkGenSyms' ReuseBoundNames names = + -- Make fresh names for the ones that are not already in scope + -- This makes things work for associated types + do { env <- lift dsGetMetaEnv + ; mkGenSyms (filterOut (`elemNameEnv` env) names) } + +addSimpleTyVarBinds :: FreshOrReuse + -> [Name] -- the binders to be added -> MetaM (Core (M a)) -- action in the ext env -> MetaM (Core (M a)) -addSimpleTyVarBinds names thing_inside - = do { fresh_names <- mkGenSyms names +addSimpleTyVarBinds fresh_or_reuse names thing_inside + = do { fresh_names <- mkGenSyms' fresh_or_reuse names ; term <- addBinds fresh_names thing_inside ; wrapGenSyms fresh_names term } addHsTyVarBinds :: forall flag flag' a. RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addHsTyVarBinds exp_tvs thing_inside - = do { fresh_exp_names <- mkGenSyms (hsLTyVarNames exp_tvs) +addHsTyVarBinds fresh_or_reuse exp_tvs thing_inside + = do { fresh_exp_names <- mkGenSyms' fresh_or_reuse (hsLTyVarNames exp_tvs) ; term <- addBinds fresh_exp_names $ do { kbs <- repListM (tyVarBndrName @flag @flag') repTyVarBndr exp_tvs ; thing_inside kbs } ; wrapGenSyms fresh_exp_names term } -addQTyVarBinds :: LHsQTyVars GhcRn -- the binders to be added +addQTyVarBinds :: FreshOrReuse + -> LHsQTyVars GhcRn -- the binders to be added -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -addQTyVarBinds (HsQTvs { hsq_ext = imp_tvs - , hsq_explicit = exp_tvs }) - thing_inside - = addTyVarBinds exp_tvs imp_tvs thing_inside +addQTyVarBinds fresh_or_reuse qtvs thing_inside = + let HsQTvs { hsq_ext = imp_tvs + , hsq_explicit = exp_tvs } + = qtvs + in addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside addTyVarBinds :: RepTV flag flag' - => [LHsTyVarBndr flag GhcRn] -- the binders to be added + => FreshOrReuse + -> [LHsTyVarBndr flag GhcRn] -- the binders to be added -> [Name] -> (Core [(M (TH.TyVarBndr flag'))] -> MetaM (Core (M a))) -- action in the ext env -> MetaM (Core (M a)) -- gensym a list of type variables and enter them into the meta environment; -- the computations passed as the second argument is executed in that extended -- meta environment and gets the *new* names on Core-level as an argument -addTyVarBinds exp_tvs imp_tvs thing_inside - = addSimpleTyVarBinds imp_tvs $ - addHsTyVarBinds exp_tvs $ +addTyVarBinds fresh_or_reuse exp_tvs imp_tvs thing_inside + = addSimpleTyVarBinds fresh_or_reuse imp_tvs $ + addHsTyVarBinds fresh_or_reuse exp_tvs $ thing_inside -addTyClTyVarBinds :: LHsQTyVars GhcRn - -> (Core [(M (TH.TyVarBndr ()))] -> MetaM (Core (M a))) - -> MetaM (Core (M a)) --- Used for data/newtype declarations, and family instances, --- so that the nested type variables work right --- instance C (T a) where --- type W (T a) = blah --- The 'a' in the type instance is the one bound by the instance decl -addTyClTyVarBinds tvs m - = do { let tv_names = hsAllLTyVarNames tvs - ; env <- lift $ dsGetMetaEnv - ; freshNames <- mkGenSyms (filterOut (`elemNameEnv` env) tv_names) - -- Make fresh names for the ones that are not already in scope - -- This makes things work for family declarations - - ; term <- addBinds freshNames $ - do { kbs <- repListM tyVarBndrUnitTyConName repTyVarBndr - (hsQTvExplicit tvs) - ; m kbs } - - ; wrapGenSyms freshNames term } - -- | Represent a type variable binder repTyVarBndr :: RepTV flag flag' => LHsTyVarBndr flag GhcRn -> MetaM (Core (M (TH.TyVarBndr flag'))) @@ -1341,7 +1353,7 @@ repLTy ty = repTy (unLoc ty) repForallT :: HsType GhcRn -> MetaM (Core (M TH.Type)) repForallT ty | (tvs, ctxt, tau) <- splitLHsSigmaTyInvis (noLocA ty) - = addHsTyVarBinds tvs $ \bndrs -> + = addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do { ctxt1 <- repLContext ctxt ; tau1 <- repLTy tau ; repTForall bndrs ctxt1 tau1 -- forall a. C a => {...} @@ -1352,7 +1364,7 @@ repTy ty@(HsForAllTy { hst_tele = tele, hst_body = body }) = case tele of HsForAllInvis{} -> repForallT ty HsForAllVis { hsf_vis_bndrs = tvs } -> - addHsTyVarBinds tvs $ \bndrs -> + addHsTyVarBinds FreshNamesOnly tvs $ \bndrs -> do body1 <- repLTy body repTForallVis bndrs body1 repTy ty@(HsQualTy {}) = repForallT ty @@ -1606,7 +1618,7 @@ repE (RecordUpd { rupd_flds = Right _ }) panic "The impossible has happened!" repE (ExprWithTySig _ e wc_ty) - = addSimpleTyVarBinds (get_scoped_tvs_from_sig sig_ty) $ + = addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig sig_ty) $ do { e1 <- repLE e ; t1 <- rep_ty_sig' sig_ty ; repSigExp e1 t1 } @@ -2516,14 +2528,17 @@ repVal (MkC p) (MkC b) (MkC ds) = rep2 valDName [p, b, ds] repFun :: Core TH.Name -> Core [(M TH.Clause)] -> MetaM (Core (M TH.Dec)) repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] -repData :: Core (M TH.Cxt) -> Core TH.Name +repData :: Bool -- ^ @True@ for a @type data@ declaration. + -- See Note [Type data declarations] in GHC.Rename.Module + -> Core (M TH.Cxt) -> Core TH.Name -> Either (Core [(M (TH.TyVarBndr ()))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) -repData (MkC cxt) (MkC nm) (Left (MkC tvs)) (MkC ksig) (MkC cons) (MkC derivs) - = rep2 dataDName [cxt, nm, tvs, ksig, cons, derivs] -repData (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) +repData type_data (MkC cxt) (MkC nm) (Left (MkC tvs)) (MkC ksig) (MkC cons) (MkC derivs) + | type_data = rep2 typeDataDName [nm, tvs, ksig, cons] + | otherwise = rep2 dataDName [cxt, nm, tvs, ksig, cons, derivs] +repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) (MkC derivs) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] @@ -2560,7 +2575,7 @@ repDerivStrategy mds thing_inside = StockStrategy _ -> thing_inside =<< just =<< repStockStrategy AnyclassStrategy _ -> thing_inside =<< just =<< repAnyclassStrategy NewtypeStrategy _ -> thing_inside =<< just =<< repNewtypeStrategy - ViaStrategy ty -> addSimpleTyVarBinds (get_scoped_tvs_from_sig ty) $ + ViaStrategy ty -> addSimpleTyVarBinds FreshNamesOnly (get_scoped_tvs_from_sig ty) $ do ty' <- rep_ty_sig' ty via_strat <- repViaStrategy ty' m_via_strat <- just via_strat ===================================== compiler/GHC/Parser.y ===================================== @@ -3058,34 +3058,34 @@ tup_exprs :: { forall b. DisambECP b => PV (SumOrTuple b) } : texp commas_tup_tail { unECP $1 >>= \ $1 -> $2 >>= \ $2 -> - do { t <- amsA $1 [AddCommaAnn (EpaSpan $ rs $ fst $2)] + do { t <- amsA $1 [AddCommaAnn (srcSpan2e $ fst $2)] ; return (Tuple (Right t : snd $2)) } } | commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) (EpaSpan $ rs ll) emptyComments))) (fst $1) } + do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) (srcSpan2e ll) emptyComments))) (fst $1) } ; return (Tuple (cos ++ $2)) } } | texp bars { unECP $1 >>= \ $1 -> return $ - (Sum 1 (snd $2 + 1) $1 [] (map (EpaSpan . realSrcSpan) $ fst $2)) } + (Sum 1 (snd $2 + 1) $1 [] (map srcSpan2e $ fst $2)) } | bars texp bars0 { unECP $2 >>= \ $2 -> return $ (Sum (snd $1 + 1) (snd $1 + snd $3 + 1) $2 - (map (EpaSpan . realSrcSpan) $ fst $1) - (map (EpaSpan . realSrcSpan) $ fst $3)) } + (map srcSpan2e $ fst $1) + (map srcSpan2e $ fst $3)) } -- Always starts with commas; always follows an expr commas_tup_tail :: { forall b. DisambECP b => PV (SrcSpan,[Either (EpAnn EpaLocation) (LocatedA b)]) } commas_tup_tail : commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) (EpaSpan $ rs l) emptyComments))) (tail $ fst $1) } + do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) (srcSpan2e l) emptyComments))) (tail $ fst $1) } ; return ((head $ fst $1, cos ++ $2)) } } -- Always follows a comma tup_tail :: { forall b. DisambECP b => PV [Either (EpAnn EpaLocation) (LocatedA b)] } : texp commas_tup_tail { unECP $1 >>= \ $1 -> $2 >>= \ $2 -> - do { t <- amsA $1 [AddCommaAnn (EpaSpan $ rs $ fst $2)] + do { t <- amsA $1 [AddCommaAnn (srcSpan2e $ fst $2)] ; return (Right t : snd $2) } } | texp { unECP $1 >>= \ $1 -> return [Right $1] } @@ -3564,10 +3564,10 @@ qcon_list : qcon { sL1N $1 [$1] } sysdcon_nolist :: { LocatedN DataCon } -- Wired in data constructors : '(' ')' {% amsrn (sLL $1 $> unitDataCon) (NameAnnOnly NameParens (glAA $1) (glAA $2) []) } | '(' commas ')' {% amsrn (sLL $1 $> $ tupleDataCon Boxed (snd $2 + 1)) - (NameAnnCommas NameParens (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParens (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' '#)' {% amsrn (sLL $1 $> $ unboxedUnitDataCon) (NameAnnOnly NameParensHash (glAA $1) (glAA $2) []) } | '(#' commas '#)' {% amsrn (sLL $1 $> $ tupleDataCon Unboxed (snd $2 + 1)) - (NameAnnCommas NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } -- See Note [Empty lists] in GHC.Hs.Expr sysdcon :: { LocatedN DataCon } @@ -3601,12 +3601,12 @@ ntgtycon :: { LocatedN RdrName } -- A "general" qualified tycon, excluding unit : oqtycon { $1 } | '(' commas ')' {% amsrn (sLL $1 $> $ getRdrName (tupleTyCon Boxed (snd $2 + 1))) - (NameAnnCommas NameParens (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParens (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' commas '#)' {% amsrn (sLL $1 $> $ getRdrName (tupleTyCon Unboxed (snd $2 + 1))) - (NameAnnCommas NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' bars '#)' {% amsrn (sLL $1 $> $ getRdrName (sumTyCon (snd $2 + 1))) - (NameAnnBars NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnBars NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(' '->' ')' {% amsrn (sLL $1 $> $ getRdrName unrestrictedFunTyCon) (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } | '[' ']' {% amsrn (sLL $1 $> $ listTyCon_RDR) @@ -4210,27 +4210,27 @@ in GHC.Parser.Annotation -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself mj :: AnnKeywordId -> Located e -> AddEpAnn -mj a l = AddEpAnn a (EpaSpan $ rs $ gl l) +mj a l = AddEpAnn a (srcSpan2e $ gl l) mjN :: AnnKeywordId -> LocatedN e -> AddEpAnn -mjN a l = AddEpAnn a (EpaSpan $ rs $ glN l) +mjN a l = AddEpAnn a (srcSpan2e $ glN l) -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself, provided the span is not zero width mz :: AnnKeywordId -> Located e -> [AddEpAnn] -mz a l = if isZeroWidthSpan (gl l) then [] else [AddEpAnn a (EpaSpan $ rs $ gl l)] +mz a l = if isZeroWidthSpan (gl l) then [] else [AddEpAnn a (srcSpan2e $ gl l)] msemi :: Located e -> [TrailingAnn] -msemi l = if isZeroWidthSpan (gl l) then [] else [AddSemiAnn (EpaSpan $ rs $ gl l)] +msemi l = if isZeroWidthSpan (gl l) then [] else [AddSemiAnn (srcSpan2e $ gl l)] msemim :: Located e -> Maybe EpaLocation -msemim l = if isZeroWidthSpan (gl l) then Nothing else Just (EpaSpan $ rs $ gl l) +msemim l = if isZeroWidthSpan (gl l) then Nothing else Just (srcSpan2e $ gl l) -- |Construct an AddEpAnn from the annotation keyword and the Located Token. If -- the token has a unicode equivalent and this has been used, provide the -- unicode variant of the annotation. mu :: AnnKeywordId -> Located Token -> AddEpAnn -mu a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (EpaSpan $ rs l) +mu a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (srcSpan2e l) -- | If the 'Token' is using its unicode variant return the unicode variant of -- the annotation @@ -4253,7 +4253,7 @@ glR :: Located a -> Anchor glR la = Anchor (realSrcSpan $ getLoc la) UnchangedAnchor glAA :: Located a -> EpaLocation -glAA = EpaSpan <$> realSrcSpan . getLoc +glAA = srcSpan2e . getLoc glRR :: Located a -> RealSrcSpan glRR = realSrcSpan . getLoc @@ -4265,7 +4265,7 @@ glNR :: LocatedN a -> Anchor glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor glNRR :: LocatedN a -> EpaLocation -glNRR = EpaSpan <$> realSrcSpan . getLocA +glNRR = srcSpan2e . getLocA anc :: RealSrcSpan -> Anchor anc r = Anchor r UnchangedAnchor @@ -4395,7 +4395,7 @@ rs _ = panic "Parser should only have RealSrcSpan" hsDoAnn :: Located a -> LocatedAn t b -> AnnKeywordId -> AnnList hsDoAnn (L l _) (L ll _) kw - = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (EpaSpan $ rs l)] [] + = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (srcSpan2e l)] [] listAsAnchor :: [LocatedAn t a] -> Anchor listAsAnchor [] = spanAsAnchor noSrcSpan @@ -4435,16 +4435,16 @@ addTrailingAnnA (L (SrcSpanAnn anns l) a) ss ta = do let anns' = if isZeroWidthSpan ss then anns - else addTrailingAnnToA l (ta (EpaSpan $ rs ss)) cs anns + else addTrailingAnnToA l (ta (srcSpan2e ss)) cs anns return (L (SrcSpanAnn anns' l) a) -- ------------------------------------- addTrailingVbarL :: MonadP m => LocatedL a -> SrcSpan -> m (LocatedL a) -addTrailingVbarL la span = addTrailingAnnL la (AddVbarAnn (EpaSpan $ rs span)) +addTrailingVbarL la span = addTrailingAnnL la (AddVbarAnn (srcSpan2e span)) addTrailingCommaL :: MonadP m => LocatedL a -> SrcSpan -> m (LocatedL a) -addTrailingCommaL la span = addTrailingAnnL la (AddCommaAnn (EpaSpan $ rs span)) +addTrailingCommaL la span = addTrailingAnnL la (AddCommaAnn (srcSpan2e span)) addTrailingAnnL :: MonadP m => LocatedL a -> TrailingAnn -> m (LocatedL a) addTrailingAnnL (L (SrcSpanAnn anns l) a) ta = do @@ -4462,7 +4462,7 @@ addTrailingCommaN (L (SrcSpanAnn anns l) a) span = do -- AZ:TODO: generalise updating comments into an annotation let anns' = if isZeroWidthSpan span then anns - else addTrailingCommaToN l anns (EpaSpan $ rs span) + else addTrailingCommaToN l anns (srcSpan2e span) return (L (SrcSpanAnn anns' l) a) addTrailingCommaS :: Located StringLiteral -> EpaLocation -> Located StringLiteral ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( la2na, na2la, n2l, l2n, l2l, la2la, reLoc, reLocA, reLocL, reLocC, reLocN, - la2r, realSrcSpan, + srcSpan2e, la2e, realSrcSpan, -- ** Building up annotations extraToAnnList, reAnn, @@ -403,7 +403,7 @@ data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq) -- in the @'EpaDelta'@ variant captures any comments between the prior -- output and the thing being marked here, since we cannot otherwise -- sort the relative order. -data EpaLocation = EpaSpan !RealSrcSpan +data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] deriving (Data,Eq) @@ -447,15 +447,15 @@ getDeltaLine (DifferentLine r _) = r -- 'EpaLocation'. The parser will never insert a 'DeltaPos', so the -- partial function is safe. epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan -epaLocationRealSrcSpan (EpaSpan r) = r +epaLocationRealSrcSpan (EpaSpan r _) = r epaLocationRealSrcSpan (EpaDelta _ _) = panic "epaLocationRealSrcSpan" epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation -epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) -epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) +epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) Strict.Nothing +epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) Strict.Nothing instance Outputable EpaLocation where - ppr (EpaSpan r) = text "EpaSpan" <+> ppr r + ppr (EpaSpan r _) = text "EpaSpan" <+> ppr r ppr (EpaDelta d cs) = text "EpaDelta" <+> ppr d <+> ppr cs instance Outputable AddEpAnn where @@ -916,8 +916,12 @@ realSrcSpan _ = mkRealSrcSpan l l -- AZ temporary where l = mkRealSrcLoc (fsLit "foo") (-1) (-1) -la2r :: SrcSpanAnn' a -> RealSrcSpan -la2r l = realSrcSpan (locA l) +srcSpan2e :: SrcSpan -> EpaLocation +srcSpan2e (RealSrcSpan s mb) = EpaSpan s mb +srcSpan2e span = EpaSpan (realSrcSpan span) Strict.Nothing + +la2e :: SrcSpanAnn' a -> EpaLocation +la2e = srcSpan2e . locA extraToAnnList :: AnnList -> [AddEpAnn] -> AnnList extraToAnnList (AnnList a o c e t) as = AnnList a o c (e++as) t @@ -976,7 +980,7 @@ widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan widenSpan s as = foldl combineSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s):rest) = RealSrcSpan s Strict.Nothing : go rest + go (AddEpAnn _ (EpaSpan s mb):rest) = RealSrcSpan s mb : go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest -- | The annotations need to all come after the anchor. Make sure @@ -985,7 +989,7 @@ widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan widenRealSpan s as = foldl combineRealSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s):rest) = s : go rest + go (AddEpAnn _ (EpaSpan s _):rest) = s : go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest widenAnchor :: Anchor -> [AddEpAnn] -> Anchor ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3646,7 +3646,7 @@ warn_unknown_prag prags span buf len buf2 = do -- 'AddEpAnn' values for the opening and closing bordering on the start -- and end of the span mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) -mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo),AddEpAnn AnnCloseP (EpaSpan lc)) +mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCloseP (EpaSpan lc Strict.Nothing)) where f = srcSpanFile ss sl = srcSpanStartLine ss ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -471,13 +471,13 @@ annBinds a cs (HsIPBinds an bs) = (HsIPBinds (add_where a an cs) bs, Nothing) annBinds _ cs (EmptyLocalBinds x) = (EmptyLocalBinds x, Just cs) add_where :: AddEpAnn -> EpAnn AnnList -> EpAnnComments -> EpAnn AnnList -add_where an@(AddEpAnn _ (EpaSpan rs)) (EpAnn a (AnnList anc o c r t) cs) cs2 +add_where an@(AddEpAnn _ (EpaSpan rs _)) (EpAnn a (AnnList anc o c r t) cs) cs2 | valid_anchor (anchor a) = EpAnn (widenAnchor a [an]) (AnnList anc o c (an:r) t) (cs Semi.<> cs2) | otherwise = EpAnn (patch_anchor rs a) (AnnList (fmap (patch_anchor rs) anc) o c (an:r) t) (cs Semi.<> cs2) -add_where an@(AddEpAnn _ (EpaSpan rs)) EpAnnNotUsed cs +add_where an@(AddEpAnn _ (EpaSpan rs _)) EpAnnNotUsed cs = EpAnn (Anchor rs UnchangedAnchor) (AnnList (Just $ Anchor rs UnchangedAnchor) Nothing Nothing [an] []) cs add_where (AddEpAnn _ (EpaDelta _ _)) _ _ = panic "add_where" @@ -501,7 +501,7 @@ fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) -- | The 'Anchor' for a stmtlist is based on either the location or -- the first semicolon annotion. stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Anchor -stmtsAnchor (L l ((ConsOL (AddEpAnn _ (EpaSpan r)) _), _)) +stmtsAnchor (L l ((ConsOL (AddEpAnn _ (EpaSpan r _)) _), _)) = widenAnchorR (Anchor (realSrcSpan l) UnchangedAnchor) r stmtsAnchor (L l _) = Anchor (realSrcSpan l) UnchangedAnchor @@ -1039,13 +1039,13 @@ checkTyClHdr is_cls ty newAnns (SrcSpanAnn EpAnnNotUsed l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (realSrcSpan l) (anchor as) - an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (EpaSpan $ realSrcSpan l) c []) cs) + an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (srcSpan2e l) c []) cs) in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) newAnns _ EpAnnNotUsed = panic "missing AnnParen" newAnns (SrcSpanAnn (EpAnn ap (AnnListItem ta) csp) l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (anchor ap) (anchor as) - an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (EpaSpan $ realSrcSpan l) c ta) (csp Semi.<> cs)) + an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs)) in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) -- | Yield a parse error if we have a function applied directly to a do block @@ -2855,7 +2855,7 @@ checkImportSpec ie@(L _ specs) = mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P ([AddEpAnn], ImpExpSubSpec) mkImpExpSubSpec [] = return ([], ImpExpList []) mkImpExpSubSpec [L la ImpExpQcWildcard] = - return ([AddEpAnn AnnDotdot (EpaSpan $ la2r la)], ImpExpAll) + return ([AddEpAnn AnnDotdot (la2e la)], ImpExpAll) mkImpExpSubSpec xs = if (any (isImpExpQcWildcard . unLoc) xs) then return $ ([], ImpExpAllWith xs) @@ -3124,14 +3124,14 @@ mkMultTy pct t arr = HsExplicitMult pct t arr mkTokenLocation :: SrcSpan -> TokenLocation mkTokenLocation (UnhelpfulSpan _) = NoTokenLoc -mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) +mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) -- Precondition: the TokenLocation has EpaSpan, never EpaDelta. token_location_widenR :: TokenLocation -> SrcSpan -> TokenLocation token_location_widenR NoTokenLoc _ = NoTokenLoc token_location_widenR tl (UnhelpfulSpan _) = tl -token_location_widenR (TokenLoc (EpaSpan r1)) (RealSrcSpan r2 _) = - (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2))) +token_location_widenR (TokenLoc (EpaSpan r1 mb1)) (RealSrcSpan r2 mb2) = + (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2) (liftA2 combineBufSpans mb1 mb2))) token_location_widenR (TokenLoc (EpaDelta _ _)) _ = -- Never happens because the parser does not produce EpaDelta. panic "token_location_widenR: EpaDelta" ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2130,6 +2130,10 @@ The main parts of the implementation are: of the `IfDataTyCon` constructor of `IfaceConDecls` by GHC.Iface.Make.tyConToIfaceDecl. +* The Template Haskell `Dec` type has an constructor `TypeDataD` for + `type data` declarations. When these are converted back to Hs types + in a splice, the constructors are placed in the TcCls namespace. + -} warnNoDerivStrat :: Maybe (LDerivStrategy GhcRn) ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -2011,14 +2011,14 @@ printMinimalImports hsc_src imports_w_usage to_ie_post_rn_var :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn_var (L l n) - | isDataOcc $ occName n = L l (IEPattern (EpaSpan $ la2r l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (la2na l) n)) + | otherwise = L l (IEName noExtField (L (la2na l) n)) to_ie_post_rn :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn (L l n) - | isTcOcc occ && isSymOcc occ = L l (IEType (EpaSpan $ la2r l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (la2na l) n)) + | otherwise = L l (IEName noExtField (L (la2na l) n)) where occ = occName n {- ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -2681,7 +2681,7 @@ reify_tc_app tc tys | tc `hasKey` heqTyConKey = TH.EqualityT | tc `hasKey` eqPrimTyConKey = TH.EqualityT | tc `hasKey` eqReprPrimTyConKey = TH.ConT (reifyName coercibleTyCon) - | isPromotedDataCon tc = TH.PromotedT (reifyName tc) + | isDataKindsPromotedDataCon tc = TH.PromotedT (reifyName tc) | otherwise = TH.ConT (reifyName tc) -- See Note [When does a tycon application need an explicit kind ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -270,36 +270,12 @@ cvtDec (TySynD tc tvs rhs) , tcdRhs = rhs' } } cvtDec (DataD ctxt tc tvs ksig constrs derivs) - = do { let isGadtCon (GadtC _ _ _) = True - isGadtCon (RecGadtC _ _ _) = True - isGadtCon (ForallC _ _ c) = isGadtCon c - isGadtCon _ = False - isGadtDecl = all isGadtCon constrs - isH98Decl = all (not . isGadtCon) constrs - ; unless (isGadtDecl || isH98Decl) - (failWith CannotMixGADTConsWith98Cons) - ; unless (isNothing ksig || isGadtDecl) - (failWith KindSigsOnlyAllowedOnGADTs) - ; (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs - ; ksig' <- cvtKind `traverse` ksig - ; cons' <- mapM cvtConstr constrs - ; derivs' <- cvtDerivs derivs - ; let defn = HsDataDefn { dd_ext = noExtField - , dd_cType = Nothing - , dd_ctxt = mkHsContextMaybe ctxt' - , dd_kindSig = ksig' - , dd_cons = DataTypeCons False cons' - , dd_derivs = derivs' } - ; returnJustLA $ TyClD noExtField $ - DataDecl { tcdDExt = noAnn - , tcdLName = tc', tcdTyVars = tvs' - , tcdFixity = Prefix - , tcdDataDefn = defn } } + = cvtDataDec ctxt tc tvs ksig constrs derivs cvtDec (NewtypeD ctxt tc tvs ksig constr derivs) = do { (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs ; ksig' <- cvtKind `traverse` ksig - ; con' <- cvtConstr constr + ; con' <- cvtConstr cNameN constr ; derivs' <- cvtDerivs derivs ; let defn = HsDataDefn { dd_ext = noExtField , dd_cType = Nothing @@ -313,6 +289,9 @@ cvtDec (NewtypeD ctxt tc tvs ksig constr derivs) , tcdFixity = Prefix , tcdDataDefn = defn } } +cvtDec (TypeDataD tc tvs ksig constrs) + = cvtTypeDataDec tc tvs ksig constrs + cvtDec (ClassD ctxt cl tvs fds decs) = do { (cxt', tc', tvs') <- cvt_tycl_hdr ctxt cl tvs ; fds' <- mapM cvt_fundep fds @@ -368,7 +347,7 @@ cvtDec (DataFamilyD tc tvs kind) cvtDec (DataInstD ctxt bndrs tys ksig constrs derivs) = do { (ctxt', tc', bndrs', typats') <- cvt_datainst_hdr ctxt bndrs tys ; ksig' <- cvtKind `traverse` ksig - ; cons' <- mapM cvtConstr constrs + ; cons' <- mapM (cvtConstr cNameN) constrs ; derivs' <- cvtDerivs derivs ; let defn = HsDataDefn { dd_ext = noExtField , dd_cType = Nothing @@ -390,7 +369,7 @@ cvtDec (DataInstD ctxt bndrs tys ksig constrs derivs) cvtDec (NewtypeInstD ctxt bndrs tys ksig constr derivs) = do { (ctxt', tc', bndrs', typats') <- cvt_datainst_hdr ctxt bndrs tys ; ksig' <- cvtKind `traverse` ksig - ; con' <- cvtConstr constr + ; con' <- cvtConstr cNameN constr ; derivs' <- cvtDerivs derivs ; let defn = HsDataDefn { dd_ext = noExtField , dd_cType = Nothing @@ -484,6 +463,59 @@ cvtDec (TH.PatSynSigD nm ty) cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding +-- Convert a @data@ declaration. +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr ()] + -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] + -> CvtM (Maybe (LHsDecl GhcPs)) +cvtDataDec = cvtGenDataDec False + +-- Convert a @type data@ declaration. +-- These have neither contexts nor derived clauses. +-- See Note [Type data declarations] in GHC.Rename.Module. +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr ()] -> Maybe TH.Kind -> [TH.Con] + -> CvtM (Maybe (LHsDecl GhcPs)) +cvtTypeDataDec tc tvs ksig constrs + = cvtGenDataDec True [] tc tvs ksig constrs [] + +-- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). +-- See Note [Type data declarations] in GHC.Rename.Module. +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr ()] + -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] + -> CvtM (Maybe (LHsDecl GhcPs)) +cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs + = do { let isGadtCon (GadtC _ _ _) = True + isGadtCon (RecGadtC _ _ _) = True + isGadtCon (ForallC _ _ c) = isGadtCon c + isGadtCon _ = False + isGadtDecl = all isGadtCon constrs + isH98Decl = all (not . isGadtCon) constrs + -- A constructor in a @data@ or @newtype@ declaration is + -- a data constructor. A constructor in a @type data@ + -- declaration is a type constructor. + -- See Note [Type data declarations] in GHC.Rename.Module. + con_name + | type_data = tconNameN + | otherwise = cNameN + ; unless (isGadtDecl || isH98Decl) + (failWith CannotMixGADTConsWith98Cons) + ; unless (isNothing ksig || isGadtDecl) + (failWith KindSigsOnlyAllowedOnGADTs) + ; (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs + ; ksig' <- cvtKind `traverse` ksig + ; cons' <- mapM (cvtConstr con_name) constrs + ; derivs' <- cvtDerivs derivs + ; let defn = HsDataDefn { dd_ext = noExtField + , dd_cType = Nothing + , dd_ctxt = mkHsContextMaybe ctxt' + , dd_kindSig = ksig' + , dd_cons = DataTypeCons type_data cons' + , dd_derivs = derivs' } + ; returnJustLA $ TyClD noExtField $ + DataDecl { tcdDExt = noAnn + , tcdLName = tc', tcdTyVars = tvs' + , tcdFixity = Prefix + , tcdDataDefn = defn } } + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -617,30 +649,31 @@ is_ip_bind decl = Right decl -- Data types --------------------------------------------------- -cvtConstr :: TH.Con -> CvtM (LConDecl GhcPs) +cvtConstr :: (TH.Name -> CvtM (LocatedN RdrName)) -- ^ convert constructor name + -> TH.Con -> CvtM (LConDecl GhcPs) -cvtConstr (NormalC c strtys) - = do { c' <- cNameN c +cvtConstr con_name (NormalC c strtys) + = do { c' <- con_name c ; tys' <- mapM cvt_arg strtys ; returnLA $ mkConDeclH98 noAnn c' Nothing Nothing (PrefixCon noTypeArgs (map hsLinear tys')) } -cvtConstr (RecC c varstrtys) - = do { c' <- cNameN c +cvtConstr con_name (RecC c varstrtys) + = do { c' <- con_name c ; args' <- mapM cvt_id_arg varstrtys ; con_decl <- wrapParLA (mkConDeclH98 noAnn c' Nothing Nothing . RecCon) args' ; returnLA con_decl } -cvtConstr (InfixC st1 c st2) - = do { c' <- cNameN c +cvtConstr con_name (InfixC st1 c st2) + = do { c' <- con_name c ; st1' <- cvt_arg st1 ; st2' <- cvt_arg st2 ; returnLA $ mkConDeclH98 noAnn c' Nothing Nothing (InfixCon (hsLinear st1') (hsLinear st2')) } -cvtConstr (ForallC tvs ctxt con) +cvtConstr con_name (ForallC tvs ctxt con) = do { tvs' <- cvtTvs tvs ; ctxt' <- cvtContext funPrec ctxt - ; L _ con' <- cvtConstr con + ; L _ con' <- cvtConstr con_name con ; returnLA $ add_forall tvs' ctxt' con' } where add_cxt lcxt Nothing = mkHsContextMaybe lcxt @@ -668,18 +701,18 @@ cvtConstr (ForallC tvs ctxt con) where all_tvs = tvs' ++ ex_tvs -cvtConstr (GadtC c strtys ty) = case nonEmpty c of +cvtConstr con_name (GadtC c strtys ty) = case nonEmpty c of Nothing -> failWith GadtNoCons Just c -> do - { c' <- mapM cNameN c + { c' <- mapM con_name c ; args <- mapM cvt_arg strtys ; ty' <- cvtType ty ; mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'} -cvtConstr (RecGadtC c varstrtys ty) = case nonEmpty c of +cvtConstr con_name (RecGadtC c varstrtys ty) = case nonEmpty c of Nothing -> failWith RecGadtNoCons Just c -> do - { c' <- mapM cNameN c + { c' <- mapM con_name c ; ty' <- cvtType ty ; rec_flds <- mapM cvt_id_arg varstrtys ; lrec_flds <- returnLA rec_flds ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Types.SrcLoc ( BufSpan(..), getBufSpan, removeBufSpan, + combineBufSpans, -- * Located Located, ===================================== libraries/template-haskell/Language/Haskell/TH/Lib.hs ===================================== @@ -86,7 +86,7 @@ module Language.Haskell.TH.Lib ( -- *** Top Level Declarations -- **** Data - valD, funD, tySynD, dataD, newtypeD, + valD, funD, tySynD, dataD, newtypeD, typeDataD, derivClause, DerivClause(..), stockStrategy, anyclassStrategy, newtypeStrategy, viaStrategy, DerivStrategy(..), @@ -131,8 +131,8 @@ module Language.Haskell.TH.Lib ( thisModule, -- ** Documentation - withDecDoc, withDecsDoc, funD_doc, dataD_doc, newtypeD_doc, dataInstD_doc, - newtypeInstD_doc, patSynD_doc + withDecDoc, withDecsDoc, funD_doc, dataD_doc, newtypeD_doc, + typeDataD_doc, dataInstD_doc, newtypeInstD_doc, patSynD_doc ) where @@ -140,6 +140,7 @@ import Language.Haskell.TH.Lib.Internal hiding ( tySynD , dataD , newtypeD + , typeDataD , classD , pragRuleD , dataInstD @@ -212,6 +213,13 @@ newtypeD ctxt tc tvs ksig con derivs = derivs1 <- sequenceA derivs return (NewtypeD ctxt1 tc tvs ksig con1 derivs1) +typeDataD :: Quote m => Name -> [TyVarBndr ()] -> Maybe Kind -> [m Con] + -> m Dec +typeDataD tc tvs ksig cons = + do + cons1 <- sequenceA cons + return (TypeDataD tc tvs ksig cons1) + classD :: Quote m => m Cxt -> Name -> [TyVarBndr ()] -> [FunDep] -> [m Dec] -> m Dec classD ctxt cls tvs fds decs = do ===================================== libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs ===================================== @@ -441,6 +441,15 @@ newtypeD ctxt tc tvs ksig con derivs = derivs1 <- sequenceA derivs pure (NewtypeD ctxt1 tc tvs1 ksig1 con1 derivs1) +typeDataD :: Quote m => Name -> [m (TyVarBndr ())] -> Maybe (m Kind) -> [m Con] + -> m Dec +typeDataD tc tvs ksig cons = + do + tvs1 <- sequenceA tvs + ksig1 <- sequenceA ksig + cons1 <- sequenceA cons + pure (TypeDataD tc tvs1 ksig1 cons1) + classD :: Quote m => m Cxt -> Name -> [m (TyVarBndr ())] -> [FunDep] -> [m Dec] -> m Dec classD ctxt cls tvs fds decs = do @@ -1033,6 +1042,7 @@ withDecDoc doc dec = do doc_loc (ValD (VarP n) _ _) = Just $ DeclDoc n doc_loc (DataD _ n _ _ _ _) = Just $ DeclDoc n doc_loc (NewtypeD _ n _ _ _ _) = Just $ DeclDoc n + doc_loc (TypeDataD n _ _ _) = Just $ DeclDoc n doc_loc (TySynD n _ _) = Just $ DeclDoc n doc_loc (ClassD _ n _ _ _) = Just $ DeclDoc n doc_loc (SigD n _) = Just $ DeclDoc n @@ -1108,6 +1118,19 @@ newtypeD_doc ctxt tc tvs ksig con_with_docs@(con, _, _) derivs mdoc = do let dec = newtypeD ctxt tc tvs ksig con derivs maybe dec (flip withDecDoc dec) mdoc +-- | Variant of 'typeDataD' that attaches Haddock documentation. +typeDataD_doc :: Name -> [Q (TyVarBndr ())] -> Maybe (Q Kind) + -> [(Q Con, Maybe String, [Maybe String])] + -- ^ List of constructors, documentation for the constructor, and + -- documentation for the arguments + -> Maybe String + -- ^ Documentation to attach to the data declaration + -> Q Dec +typeDataD_doc tc tvs ksig cons_with_docs mdoc = do + qAddModFinalizer $ mapM_ docCons cons_with_docs + let dec = typeDataD tc tvs ksig (map (\(con, _, _) -> con) cons_with_docs) + maybe dec (flip withDecDoc dec) mdoc + -- | Variant of 'dataInstD' that attaches Haddock documentation. dataInstD_doc :: Q Cxt -> (Maybe [Q (TyVarBndr ())]) -> Q Type -> Maybe (Q Kind) -> [(Q Con, Maybe String, [Maybe String])] ===================================== libraries/template-haskell/Language/Haskell/TH/Ppr.hs ===================================== @@ -399,6 +399,8 @@ ppr_dec _ (DataD ctxt t xs ksig cs decs) = ppr_data empty ctxt (Just t) (hsep (map ppr xs)) ksig cs decs ppr_dec _ (NewtypeD ctxt t xs ksig c decs) = ppr_newtype empty ctxt (Just t) (sep (map ppr xs)) ksig c decs +ppr_dec _ (TypeDataD t xs ksig cs) + = ppr_type_data empty [] (Just t) (hsep (map ppr xs)) ksig cs [] ppr_dec _ (ClassD ctxt c xs fds ds) = text "class" <+> pprCxt ctxt <+> ppr c <+> hsep (map ppr xs) <+> ppr fds $$ where_clause ds @@ -495,6 +497,10 @@ ppr_newtype :: Doc -> Cxt -> Maybe Name -> Doc -> Maybe Kind -> Con -> [DerivCla -> Doc ppr_newtype maybeInst ctxt t argsDoc ksig c decs = ppr_typedef "newtype" maybeInst ctxt t argsDoc ksig [c] decs +ppr_type_data :: Doc -> Cxt -> Maybe Name -> Doc -> Maybe Kind -> [Con] -> [DerivClause] + -> Doc +ppr_type_data = ppr_typedef "type data" + ppr_typedef :: String -> Doc -> Cxt -> Maybe Name -> Doc -> Maybe Kind -> [Con] -> [DerivClause] -> Doc ppr_typedef data_or_newtype maybeInst ctxt t argsDoc ksig cs decs = sep [text data_or_newtype <+> maybeInst ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -2399,6 +2399,9 @@ data Dec Con [DerivClause] -- ^ @{ newtype Cxt x => T x = A (B x) -- deriving (Z,W Q) -- deriving stock Eq }@ + | TypeDataD Name [TyVarBndr ()] + (Maybe Kind) -- Kind signature (allowed only for GADTs) + [Con] -- ^ @{ type data T x = A x | B (T x) }@ | TySynD Name [TyVarBndr ()] Type -- ^ @{ type T x = (x,x) }@ | ClassD Cxt Name [TyVarBndr ()] [FunDep] [Dec] -- ^ @{ class Eq a => Ord a where ds }@ ===================================== libraries/template-haskell/changelog.md ===================================== @@ -5,6 +5,9 @@ * The `Ppr.pprInfixT` function has gained a `Precedence` argument. * The values of named precedence levels like `Ppr.appPrec` have changed. + * Add `TypeDataD` constructor to the `Dec` type for `type data` + declarations (GHC proposal #106). + ## 2.19.0.0 * Add `DefaultD` constructor to support Haskell `default` declarations. ===================================== testsuite/tests/lib/base/all.T ===================================== @@ -1,7 +1,7 @@ test('DataTypeOrd', normal, compile_and_run, ['']) test('T16586', normal, compile_and_run, ['-O2']) # Event-manager not supported on Windows -test('T16916', [when(opsys('mingw32'), skip), js_broken(22261)], compile_and_run, ['-O2 -threaded -with-rtsopts="-I0" -rtsopts']) +test('T16916', [when(opsys('mingw32'), skip), js_broken(22261), fragile(16966)], compile_and_run, ['-O2 -threaded -with-rtsopts="-I0" -rtsopts']) test('T17310', normal, compile, ['']) test('T19691', normal, compile, ['']) test('executablePath', [extra_run_opts(config.os), js_broken(22261)], compile_and_run, ['']) ===================================== testsuite/tests/type-data/should_compile/TD_TH_splice.hs ===================================== @@ -0,0 +1,18 @@ +-- Check that splicing in a quoted declaration has the same effect as +-- giving the declaration directly. +{-# LANGUAGE TemplateHaskell, TypeData, GADTs #-} + +module TD_TH_splice where + +import Data.Kind (Type) + +-- splice should be equivalent to giving the declaration directly +$( [d| type data Nat = Zero | Succ Nat |] ) + +data Vec :: Nat -> Type -> Type where + VNil :: Vec Zero a + VCons :: a -> Vec n a -> Vec (Succ n) a + +instance Functor (Vec n) where + fmap _ VNil = VNil + fmap f (VCons x xs) = VCons (f x) (fmap f xs) ===================================== testsuite/tests/type-data/should_compile/all.T ===================================== @@ -3,4 +3,5 @@ test('TDExistential', normal, compile, ['']) test('TDGADT', normal, compile, ['']) test('TDGoodConsConstraints', normal, compile, ['']) test('TDVector', normal, compile, ['']) +test('TD_TH_splice', normal, compile, ['']) test('T22315a', [extra_files(['T22315a/'])], multimod_compile, ['T22315a.Lib T22315a.Main', '-v0']) ===================================== testsuite/tests/type-data/should_run/T22500.hs ===================================== @@ -0,0 +1,9 @@ +-- Check that a quoted data type declaration is printed correctly +{-# LANGUAGE TemplateHaskellQuotes, TypeData #-} + +module Main where + +import Language.Haskell.TH +import Language.Haskell.TH.Ppr + +main = putStrLn . pprint =<< runQ [d| type data Nat = Zero | Succ Nat |] ===================================== testsuite/tests/type-data/should_run/T22500.stdout ===================================== @@ -0,0 +1,3 @@ +type data Nat_0 + = Zero_1 + | Succ_2 Nat_0 ===================================== testsuite/tests/type-data/should_run/all.T ===================================== @@ -1,2 +1,3 @@ test('T22332a', exit_code(1), compile_and_run, ['']) test('T22315b', extra_files(['T22315b.hs']), ghci_script, ['T22315b.script']) +test('T22500', normal, compile_and_run, ['']) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -543,7 +543,7 @@ printStringAtAAL (EpAnn anc an cs) l str = do printStringAtAAC :: (Monad m, Monoid w) => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation -printStringAtAAC capture (EpaSpan r) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s printStringAtAAC capture (EpaDelta d cs) s = do mapM_ (printOneComment . tokComment) cs pe1 <- getPriorEndD @@ -4108,7 +4108,7 @@ printUnicode anc n = do s -> s loc <- printStringAtAAC NoCaptureComments (EpaDelta (SameLine 0) []) str case loc of - EpaSpan _ -> return anc + EpaSpan _ _ -> return anc EpaDelta dp [] -> return anc { anchor_op = MovedAnchor dp } EpaDelta _ _cs -> error "printUnicode should not capture comments" ===================================== utils/check-exact/Parsers.hs ===================================== @@ -285,7 +285,7 @@ fixModuleTrailingComments (GHC.L l p) = GHC.L l p' rebalance al cs = cs' where cs' = case GHC.al_close al of - Just (GHC.AddEpAnn _ (GHC.EpaSpan ss)) -> + Just (GHC.AddEpAnn _ (GHC.EpaSpan ss _)) -> let pc = GHC.priorComments cs fc = GHC.getFollowingComments cs ===================================== utils/check-exact/Transform.hs ===================================== @@ -213,7 +213,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H L (SrcSpanAnn EpAnnNotUsed ll) _ -> realSrcSpan ll L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor? dc' = case dca of - EpaSpan r -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) + EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) EpaDelta _ _ -> AddEpAnn kw dca -- --------------------------------- @@ -223,7 +223,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H (L (SrcSpanAnn EpAnnNotUsed ll) b) -> let op = case dca of - EpaSpan r -> MovedAnchor (ss2delta (ss2posEnd r) (realSrcSpan ll)) + EpaSpan r _ -> MovedAnchor (ss2delta (ss2posEnd r) (realSrcSpan ll)) EpaDelta _ _ -> MovedAnchor (SameLine 1) in (L (SrcSpanAnn (EpAnn (Anchor (realSrcSpan ll) op) mempty emptyComments) ll) b) (L (SrcSpanAnn (EpAnn (Anchor r op) a c) ll) b) @@ -231,7 +231,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H op' = case op of MovedAnchor _ -> op _ -> case dca of - EpaSpan dcr -> MovedAnchor (ss2delta (ss2posEnd dcr) r) + EpaSpan dcr _ -> MovedAnchor (ss2delta (ss2posEnd dcr) r) EpaDelta _ _ -> MovedAnchor (SameLine 1) in (L (SrcSpanAnn (EpAnn (Anchor r op') a c) ll) b) @@ -341,13 +341,13 @@ getEntryDP _ = SameLine 1 addEpaLocationDelta :: LayoutStartCol -> RealSrcSpan -> EpaLocation -> EpaLocation addEpaLocationDelta _off _anc (EpaDelta d cs) = EpaDelta d cs -addEpaLocationDelta off anc (EpaSpan r) +addEpaLocationDelta off anc (EpaSpan r _) = EpaDelta (adjustDeltaForOffset off (ss2deltaEnd anc r)) [] -- Set the entry DP for an element coming after an existing keyword annotation setEntryDPFromAnchor :: LayoutStartCol -> EpaLocation -> LocatedA t -> LocatedA t setEntryDPFromAnchor _off (EpaDelta _ _) (L la a) = L la a -setEntryDPFromAnchor off (EpaSpan anc) ll@(L la _) = setEntryDP ll dp' +setEntryDPFromAnchor off (EpaSpan anc _) ll@(L la _) = setEntryDP ll dp' where r = case la of (SrcSpanAnn EpAnnNotUsed l) -> realSrcSpan l @@ -944,7 +944,7 @@ instance HasDecls (LocatedA (HsExpr GhcPs)) where (L (TokenLoc l) ls, L (TokenLoc i) is) -> let off = case l of - (EpaSpan r) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan r _) -> LayoutStartCol $ snd $ ss2pos r (EpaDelta (SameLine _) _) -> LayoutStartCol 0 (EpaDelta (DifferentLine _ c) _) -> LayoutStartCol c ex'' = setEntryDPFromAnchor off i ex ===================================== utils/check-exact/Utils.hs ===================================== @@ -119,7 +119,7 @@ undelta (l,_) (DifferentLine dl dc) (LayoutStartCol co) = (fl,fc) fc = co + dc undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn -undeltaSpan anchor kw dp = AddEpAnn kw (EpaSpan sp) +undeltaSpan anchor kw dp = AddEpAnn kw (EpaSpan sp Strict.Nothing) where (l,c) = undelta (ss2pos anchor) dp (LayoutStartCol 0) len = length (keywordToString kw) @@ -256,7 +256,7 @@ sortEpaComments cs = sortBy cmp cs -- | Makes a comment which originates from a specific keyword. mkKWComment :: AnnKeywordId -> EpaLocation -> Comment -mkKWComment kw (EpaSpan ss) +mkKWComment kw (EpaSpan ss _) = Comment (keywordToString kw) (Anchor ss UnchangedAnchor) ss (Just kw) mkKWComment kw (EpaDelta dp _) = Comment (keywordToString kw) (Anchor placeholderRealSpan (MovedAnchor dp)) placeholderRealSpan (Just kw) @@ -373,7 +373,7 @@ addEpAnnLoc (AddEpAnn _ l) = l -- TODO: move this to GHC anchorToEpaLocation :: Anchor -> EpaLocation -anchorToEpaLocation (Anchor r UnchangedAnchor) = EpaSpan r +anchorToEpaLocation (Anchor r UnchangedAnchor) = EpaSpan r Strict.Nothing anchorToEpaLocation (Anchor _ (MovedAnchor dp)) = EpaDelta dp [] -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b47331023cc5ae0e112f7eaec90d6461dcd186fa...1edc25795ae09bfd39e5c0e5e185c64553f290c3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b47331023cc5ae0e112f7eaec90d6461dcd186fa...1edc25795ae09bfd39e5c0e5e185c64553f290c3 You're receiving 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 Dec 5 09:56:55 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Mon, 05 Dec 2022 04:56:55 -0500 Subject: [Git][ghc/ghc][wip/or-pats] Haddock update Message-ID: <638dc067bc8df_17512e38d2cbec10782a8@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 70b567a5 by David Knothe at 2022-12-05T10:56:51+01:00 Haddock update - - - - - 1 changed file: - utils/haddock Changes: ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 2ffde83344bab8ed0aee3e8ef46f43856c7ca6ef +Subproject commit 06759928e97fcad4f9b216a128ed89b78b302fc6 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/70b567a537b26325fb8f570ad57ff346e500212c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/70b567a537b26325fb8f570ad57ff346e500212c You're receiving 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 Dec 5 10:14:49 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Mon, 05 Dec 2022 05:14:49 -0500 Subject: [Git][ghc/ghc][wip/or-pats] Revert "Haddock update" Message-ID: <638dc49985e08_17512e1e46a9d8107894@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 20dab07a by David Knothe at 2022-12-05T11:14:24+01:00 Revert "Haddock update" This reverts commit 70b567a537b26325fb8f570ad57ff346e500212c. - - - - - 1 changed file: - utils/haddock Changes: ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 06759928e97fcad4f9b216a128ed89b78b302fc6 +Subproject commit 2ffde83344bab8ed0aee3e8ef46f43856c7ca6ef View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20dab07a5d20c2adbdee6947083d9fb3ee634ef7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20dab07a5d20c2adbdee6947083d9fb3ee634ef7 You're receiving 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 Dec 5 10:18:37 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 05 Dec 2022 05:18:37 -0500 Subject: [Git][ghc/ghc][master] Handle type data declarations in Template Haskell quotations and splices (fixes #22500) Message-ID: <638dc57dac42d_17512e4d4b8e10108478e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 15 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - + testsuite/tests/type-data/should_compile/TD_TH_splice.hs - testsuite/tests/type-data/should_compile/all.T - + testsuite/tests/type-data/should_run/T22500.hs - + testsuite/tests/type-data/should_run/T22500.stdout - testsuite/tests/type-data/should_run/all.T Changes: ===================================== compiler/GHC/Builtin/Names/TH.hs ===================================== @@ -69,7 +69,7 @@ templateHaskellNames = [ -- Stmt bindSName, letSName, noBindSName, parSName, recSName, -- Dec - funDName, valDName, dataDName, newtypeDName, tySynDName, + funDName, valDName, dataDName, newtypeDName, typeDataDName, tySynDName, classDName, instanceWithOverlapDName, standaloneDerivWithStrategyDName, sigDName, kiSigDName, forImpDName, pragInlDName, pragOpaqueDName, pragSpecDName, pragSpecInlDName, pragSpecInstDName, @@ -354,7 +354,7 @@ parSName = libFun (fsLit "parS") parSIdKey recSName = libFun (fsLit "recS") recSIdKey -- data Dec = ... -funDName, valDName, dataDName, newtypeDName, tySynDName, classDName, +funDName, valDName, dataDName, newtypeDName, typeDataDName, tySynDName, classDName, instanceWithOverlapDName, sigDName, kiSigDName, forImpDName, pragInlDName, pragSpecDName, pragSpecInlDName, pragSpecInstDName, pragRuleDName, pragAnnDName, standaloneDerivWithStrategyDName, defaultSigDName, defaultDName, @@ -366,6 +366,7 @@ funDName = libFun (fsLit "funD") valDName = libFun (fsLit "valD") valDIdKey dataDName = libFun (fsLit "dataD") dataDIdKey newtypeDName = libFun (fsLit "newtypeD") newtypeDIdKey +typeDataDName = libFun (fsLit "typeDataD") typeDataDIdKey tySynDName = libFun (fsLit "tySynD") tySynDIdKey classDName = libFun (fsLit "classD") classDIdKey instanceWithOverlapDName = libFun (fsLit "instanceWithOverlapD") instanceWithOverlapDIdKey @@ -888,7 +889,7 @@ funDIdKey, valDIdKey, dataDIdKey, newtypeDIdKey, tySynDIdKey, classDIdKey, newtypeInstDIdKey, tySynInstDIdKey, standaloneDerivWithStrategyDIdKey, infixLDIdKey, infixRDIdKey, infixNDIdKey, roleAnnotDIdKey, patSynDIdKey, patSynSigDIdKey, pragCompleteDIdKey, implicitParamBindDIdKey, - kiSigDIdKey, defaultDIdKey, pragOpaqueDIdKey :: Unique + kiSigDIdKey, defaultDIdKey, pragOpaqueDIdKey, typeDataDIdKey :: Unique funDIdKey = mkPreludeMiscIdUnique 320 valDIdKey = mkPreludeMiscIdUnique 321 dataDIdKey = mkPreludeMiscIdUnique 322 @@ -923,7 +924,8 @@ pragCompleteDIdKey = mkPreludeMiscIdUnique 350 implicitParamBindDIdKey = mkPreludeMiscIdUnique 351 kiSigDIdKey = mkPreludeMiscIdUnique 352 defaultDIdKey = mkPreludeMiscIdUnique 353 -pragOpaqueDIdKey = mkPreludeMiscIdUnique 354 +pragOpaqueDIdKey = mkPreludeMiscIdUnique 354 +typeDataDIdKey = mkPreludeMiscIdUnique 355 -- type Cxt = ... cxtIdKey :: Unique ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -528,10 +528,10 @@ repDataDefn tc opts ; ksig' <- repMaybeLTy ksig ; repNewtype cxt1 tc opts ksig' con' derivs1 } - DataTypeCons _ cons -> do { ksig' <- repMaybeLTy ksig + DataTypeCons type_data cons -> do { ksig' <- repMaybeLTy ksig ; consL <- mapM repC cons ; cons1 <- coreListM conTyConName consL - ; repData cxt1 tc opts ksig' cons1 + ; repData type_data cxt1 tc opts ksig' cons1 derivs1 } } @@ -2528,14 +2528,17 @@ repVal (MkC p) (MkC b) (MkC ds) = rep2 valDName [p, b, ds] repFun :: Core TH.Name -> Core [(M TH.Clause)] -> MetaM (Core (M TH.Dec)) repFun (MkC nm) (MkC b) = rep2 funDName [nm, b] -repData :: Core (M TH.Cxt) -> Core TH.Name +repData :: Bool -- ^ @True@ for a @type data@ declaration. + -- See Note [Type data declarations] in GHC.Rename.Module + -> Core (M TH.Cxt) -> Core TH.Name -> Either (Core [(M (TH.TyVarBndr ()))]) (Core (Maybe [(M (TH.TyVarBndr ()))]), Core (M TH.Type)) -> Core (Maybe (M TH.Kind)) -> Core [(M TH.Con)] -> Core [M TH.DerivClause] -> MetaM (Core (M TH.Dec)) -repData (MkC cxt) (MkC nm) (Left (MkC tvs)) (MkC ksig) (MkC cons) (MkC derivs) - = rep2 dataDName [cxt, nm, tvs, ksig, cons, derivs] -repData (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) +repData type_data (MkC cxt) (MkC nm) (Left (MkC tvs)) (MkC ksig) (MkC cons) (MkC derivs) + | type_data = rep2 typeDataDName [nm, tvs, ksig, cons] + | otherwise = rep2 dataDName [cxt, nm, tvs, ksig, cons, derivs] +repData _ (MkC cxt) (MkC _) (Right (MkC mb_bndrs, MkC ty)) (MkC ksig) (MkC cons) (MkC derivs) = rep2 dataInstDName [cxt, mb_bndrs, ty, ksig, cons, derivs] ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2130,6 +2130,10 @@ The main parts of the implementation are: of the `IfDataTyCon` constructor of `IfaceConDecls` by GHC.Iface.Make.tyConToIfaceDecl. +* The Template Haskell `Dec` type has an constructor `TypeDataD` for + `type data` declarations. When these are converted back to Hs types + in a splice, the constructors are placed in the TcCls namespace. + -} warnNoDerivStrat :: Maybe (LDerivStrategy GhcRn) ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -2681,7 +2681,7 @@ reify_tc_app tc tys | tc `hasKey` heqTyConKey = TH.EqualityT | tc `hasKey` eqPrimTyConKey = TH.EqualityT | tc `hasKey` eqReprPrimTyConKey = TH.ConT (reifyName coercibleTyCon) - | isPromotedDataCon tc = TH.PromotedT (reifyName tc) + | isDataKindsPromotedDataCon tc = TH.PromotedT (reifyName tc) | otherwise = TH.ConT (reifyName tc) -- See Note [When does a tycon application need an explicit kind ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -270,36 +270,12 @@ cvtDec (TySynD tc tvs rhs) , tcdRhs = rhs' } } cvtDec (DataD ctxt tc tvs ksig constrs derivs) - = do { let isGadtCon (GadtC _ _ _) = True - isGadtCon (RecGadtC _ _ _) = True - isGadtCon (ForallC _ _ c) = isGadtCon c - isGadtCon _ = False - isGadtDecl = all isGadtCon constrs - isH98Decl = all (not . isGadtCon) constrs - ; unless (isGadtDecl || isH98Decl) - (failWith CannotMixGADTConsWith98Cons) - ; unless (isNothing ksig || isGadtDecl) - (failWith KindSigsOnlyAllowedOnGADTs) - ; (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs - ; ksig' <- cvtKind `traverse` ksig - ; cons' <- mapM cvtConstr constrs - ; derivs' <- cvtDerivs derivs - ; let defn = HsDataDefn { dd_ext = noExtField - , dd_cType = Nothing - , dd_ctxt = mkHsContextMaybe ctxt' - , dd_kindSig = ksig' - , dd_cons = DataTypeCons False cons' - , dd_derivs = derivs' } - ; returnJustLA $ TyClD noExtField $ - DataDecl { tcdDExt = noAnn - , tcdLName = tc', tcdTyVars = tvs' - , tcdFixity = Prefix - , tcdDataDefn = defn } } + = cvtDataDec ctxt tc tvs ksig constrs derivs cvtDec (NewtypeD ctxt tc tvs ksig constr derivs) = do { (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs ; ksig' <- cvtKind `traverse` ksig - ; con' <- cvtConstr constr + ; con' <- cvtConstr cNameN constr ; derivs' <- cvtDerivs derivs ; let defn = HsDataDefn { dd_ext = noExtField , dd_cType = Nothing @@ -313,6 +289,9 @@ cvtDec (NewtypeD ctxt tc tvs ksig constr derivs) , tcdFixity = Prefix , tcdDataDefn = defn } } +cvtDec (TypeDataD tc tvs ksig constrs) + = cvtTypeDataDec tc tvs ksig constrs + cvtDec (ClassD ctxt cl tvs fds decs) = do { (cxt', tc', tvs') <- cvt_tycl_hdr ctxt cl tvs ; fds' <- mapM cvt_fundep fds @@ -368,7 +347,7 @@ cvtDec (DataFamilyD tc tvs kind) cvtDec (DataInstD ctxt bndrs tys ksig constrs derivs) = do { (ctxt', tc', bndrs', typats') <- cvt_datainst_hdr ctxt bndrs tys ; ksig' <- cvtKind `traverse` ksig - ; cons' <- mapM cvtConstr constrs + ; cons' <- mapM (cvtConstr cNameN) constrs ; derivs' <- cvtDerivs derivs ; let defn = HsDataDefn { dd_ext = noExtField , dd_cType = Nothing @@ -390,7 +369,7 @@ cvtDec (DataInstD ctxt bndrs tys ksig constrs derivs) cvtDec (NewtypeInstD ctxt bndrs tys ksig constr derivs) = do { (ctxt', tc', bndrs', typats') <- cvt_datainst_hdr ctxt bndrs tys ; ksig' <- cvtKind `traverse` ksig - ; con' <- cvtConstr constr + ; con' <- cvtConstr cNameN constr ; derivs' <- cvtDerivs derivs ; let defn = HsDataDefn { dd_ext = noExtField , dd_cType = Nothing @@ -484,6 +463,59 @@ cvtDec (TH.PatSynSigD nm ty) cvtDec (TH.ImplicitParamBindD _ _) = failWith InvalidImplicitParamBinding +-- Convert a @data@ declaration. +cvtDataDec :: TH.Cxt -> TH.Name -> [TH.TyVarBndr ()] + -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] + -> CvtM (Maybe (LHsDecl GhcPs)) +cvtDataDec = cvtGenDataDec False + +-- Convert a @type data@ declaration. +-- These have neither contexts nor derived clauses. +-- See Note [Type data declarations] in GHC.Rename.Module. +cvtTypeDataDec :: TH.Name -> [TH.TyVarBndr ()] -> Maybe TH.Kind -> [TH.Con] + -> CvtM (Maybe (LHsDecl GhcPs)) +cvtTypeDataDec tc tvs ksig constrs + = cvtGenDataDec True [] tc tvs ksig constrs [] + +-- Convert a @data@ or @type data@ declaration (flagged by the Bool arg). +-- See Note [Type data declarations] in GHC.Rename.Module. +cvtGenDataDec :: Bool -> TH.Cxt -> TH.Name -> [TH.TyVarBndr ()] + -> Maybe TH.Kind -> [TH.Con] -> [TH.DerivClause] + -> CvtM (Maybe (LHsDecl GhcPs)) +cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs + = do { let isGadtCon (GadtC _ _ _) = True + isGadtCon (RecGadtC _ _ _) = True + isGadtCon (ForallC _ _ c) = isGadtCon c + isGadtCon _ = False + isGadtDecl = all isGadtCon constrs + isH98Decl = all (not . isGadtCon) constrs + -- A constructor in a @data@ or @newtype@ declaration is + -- a data constructor. A constructor in a @type data@ + -- declaration is a type constructor. + -- See Note [Type data declarations] in GHC.Rename.Module. + con_name + | type_data = tconNameN + | otherwise = cNameN + ; unless (isGadtDecl || isH98Decl) + (failWith CannotMixGADTConsWith98Cons) + ; unless (isNothing ksig || isGadtDecl) + (failWith KindSigsOnlyAllowedOnGADTs) + ; (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs + ; ksig' <- cvtKind `traverse` ksig + ; cons' <- mapM (cvtConstr con_name) constrs + ; derivs' <- cvtDerivs derivs + ; let defn = HsDataDefn { dd_ext = noExtField + , dd_cType = Nothing + , dd_ctxt = mkHsContextMaybe ctxt' + , dd_kindSig = ksig' + , dd_cons = DataTypeCons type_data cons' + , dd_derivs = derivs' } + ; returnJustLA $ TyClD noExtField $ + DataDecl { tcdDExt = noAnn + , tcdLName = tc', tcdTyVars = tvs' + , tcdFixity = Prefix + , tcdDataDefn = defn } } + ---------------- cvtTySynEqn :: TySynEqn -> CvtM (LTyFamInstEqn GhcPs) cvtTySynEqn (TySynEqn mb_bndrs lhs rhs) @@ -617,30 +649,31 @@ is_ip_bind decl = Right decl -- Data types --------------------------------------------------- -cvtConstr :: TH.Con -> CvtM (LConDecl GhcPs) +cvtConstr :: (TH.Name -> CvtM (LocatedN RdrName)) -- ^ convert constructor name + -> TH.Con -> CvtM (LConDecl GhcPs) -cvtConstr (NormalC c strtys) - = do { c' <- cNameN c +cvtConstr con_name (NormalC c strtys) + = do { c' <- con_name c ; tys' <- mapM cvt_arg strtys ; returnLA $ mkConDeclH98 noAnn c' Nothing Nothing (PrefixCon noTypeArgs (map hsLinear tys')) } -cvtConstr (RecC c varstrtys) - = do { c' <- cNameN c +cvtConstr con_name (RecC c varstrtys) + = do { c' <- con_name c ; args' <- mapM cvt_id_arg varstrtys ; con_decl <- wrapParLA (mkConDeclH98 noAnn c' Nothing Nothing . RecCon) args' ; returnLA con_decl } -cvtConstr (InfixC st1 c st2) - = do { c' <- cNameN c +cvtConstr con_name (InfixC st1 c st2) + = do { c' <- con_name c ; st1' <- cvt_arg st1 ; st2' <- cvt_arg st2 ; returnLA $ mkConDeclH98 noAnn c' Nothing Nothing (InfixCon (hsLinear st1') (hsLinear st2')) } -cvtConstr (ForallC tvs ctxt con) +cvtConstr con_name (ForallC tvs ctxt con) = do { tvs' <- cvtTvs tvs ; ctxt' <- cvtContext funPrec ctxt - ; L _ con' <- cvtConstr con + ; L _ con' <- cvtConstr con_name con ; returnLA $ add_forall tvs' ctxt' con' } where add_cxt lcxt Nothing = mkHsContextMaybe lcxt @@ -668,18 +701,18 @@ cvtConstr (ForallC tvs ctxt con) where all_tvs = tvs' ++ ex_tvs -cvtConstr (GadtC c strtys ty) = case nonEmpty c of +cvtConstr con_name (GadtC c strtys ty) = case nonEmpty c of Nothing -> failWith GadtNoCons Just c -> do - { c' <- mapM cNameN c + { c' <- mapM con_name c ; args <- mapM cvt_arg strtys ; ty' <- cvtType ty ; mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'} -cvtConstr (RecGadtC c varstrtys ty) = case nonEmpty c of +cvtConstr con_name (RecGadtC c varstrtys ty) = case nonEmpty c of Nothing -> failWith RecGadtNoCons Just c -> do - { c' <- mapM cNameN c + { c' <- mapM con_name c ; ty' <- cvtType ty ; rec_flds <- mapM cvt_id_arg varstrtys ; lrec_flds <- returnLA rec_flds ===================================== libraries/template-haskell/Language/Haskell/TH/Lib.hs ===================================== @@ -86,7 +86,7 @@ module Language.Haskell.TH.Lib ( -- *** Top Level Declarations -- **** Data - valD, funD, tySynD, dataD, newtypeD, + valD, funD, tySynD, dataD, newtypeD, typeDataD, derivClause, DerivClause(..), stockStrategy, anyclassStrategy, newtypeStrategy, viaStrategy, DerivStrategy(..), @@ -131,8 +131,8 @@ module Language.Haskell.TH.Lib ( thisModule, -- ** Documentation - withDecDoc, withDecsDoc, funD_doc, dataD_doc, newtypeD_doc, dataInstD_doc, - newtypeInstD_doc, patSynD_doc + withDecDoc, withDecsDoc, funD_doc, dataD_doc, newtypeD_doc, + typeDataD_doc, dataInstD_doc, newtypeInstD_doc, patSynD_doc ) where @@ -140,6 +140,7 @@ import Language.Haskell.TH.Lib.Internal hiding ( tySynD , dataD , newtypeD + , typeDataD , classD , pragRuleD , dataInstD @@ -212,6 +213,13 @@ newtypeD ctxt tc tvs ksig con derivs = derivs1 <- sequenceA derivs return (NewtypeD ctxt1 tc tvs ksig con1 derivs1) +typeDataD :: Quote m => Name -> [TyVarBndr ()] -> Maybe Kind -> [m Con] + -> m Dec +typeDataD tc tvs ksig cons = + do + cons1 <- sequenceA cons + return (TypeDataD tc tvs ksig cons1) + classD :: Quote m => m Cxt -> Name -> [TyVarBndr ()] -> [FunDep] -> [m Dec] -> m Dec classD ctxt cls tvs fds decs = do ===================================== libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs ===================================== @@ -441,6 +441,15 @@ newtypeD ctxt tc tvs ksig con derivs = derivs1 <- sequenceA derivs pure (NewtypeD ctxt1 tc tvs1 ksig1 con1 derivs1) +typeDataD :: Quote m => Name -> [m (TyVarBndr ())] -> Maybe (m Kind) -> [m Con] + -> m Dec +typeDataD tc tvs ksig cons = + do + tvs1 <- sequenceA tvs + ksig1 <- sequenceA ksig + cons1 <- sequenceA cons + pure (TypeDataD tc tvs1 ksig1 cons1) + classD :: Quote m => m Cxt -> Name -> [m (TyVarBndr ())] -> [FunDep] -> [m Dec] -> m Dec classD ctxt cls tvs fds decs = do @@ -1033,6 +1042,7 @@ withDecDoc doc dec = do doc_loc (ValD (VarP n) _ _) = Just $ DeclDoc n doc_loc (DataD _ n _ _ _ _) = Just $ DeclDoc n doc_loc (NewtypeD _ n _ _ _ _) = Just $ DeclDoc n + doc_loc (TypeDataD n _ _ _) = Just $ DeclDoc n doc_loc (TySynD n _ _) = Just $ DeclDoc n doc_loc (ClassD _ n _ _ _) = Just $ DeclDoc n doc_loc (SigD n _) = Just $ DeclDoc n @@ -1108,6 +1118,19 @@ newtypeD_doc ctxt tc tvs ksig con_with_docs@(con, _, _) derivs mdoc = do let dec = newtypeD ctxt tc tvs ksig con derivs maybe dec (flip withDecDoc dec) mdoc +-- | Variant of 'typeDataD' that attaches Haddock documentation. +typeDataD_doc :: Name -> [Q (TyVarBndr ())] -> Maybe (Q Kind) + -> [(Q Con, Maybe String, [Maybe String])] + -- ^ List of constructors, documentation for the constructor, and + -- documentation for the arguments + -> Maybe String + -- ^ Documentation to attach to the data declaration + -> Q Dec +typeDataD_doc tc tvs ksig cons_with_docs mdoc = do + qAddModFinalizer $ mapM_ docCons cons_with_docs + let dec = typeDataD tc tvs ksig (map (\(con, _, _) -> con) cons_with_docs) + maybe dec (flip withDecDoc dec) mdoc + -- | Variant of 'dataInstD' that attaches Haddock documentation. dataInstD_doc :: Q Cxt -> (Maybe [Q (TyVarBndr ())]) -> Q Type -> Maybe (Q Kind) -> [(Q Con, Maybe String, [Maybe String])] ===================================== libraries/template-haskell/Language/Haskell/TH/Ppr.hs ===================================== @@ -399,6 +399,8 @@ ppr_dec _ (DataD ctxt t xs ksig cs decs) = ppr_data empty ctxt (Just t) (hsep (map ppr xs)) ksig cs decs ppr_dec _ (NewtypeD ctxt t xs ksig c decs) = ppr_newtype empty ctxt (Just t) (sep (map ppr xs)) ksig c decs +ppr_dec _ (TypeDataD t xs ksig cs) + = ppr_type_data empty [] (Just t) (hsep (map ppr xs)) ksig cs [] ppr_dec _ (ClassD ctxt c xs fds ds) = text "class" <+> pprCxt ctxt <+> ppr c <+> hsep (map ppr xs) <+> ppr fds $$ where_clause ds @@ -495,6 +497,10 @@ ppr_newtype :: Doc -> Cxt -> Maybe Name -> Doc -> Maybe Kind -> Con -> [DerivCla -> Doc ppr_newtype maybeInst ctxt t argsDoc ksig c decs = ppr_typedef "newtype" maybeInst ctxt t argsDoc ksig [c] decs +ppr_type_data :: Doc -> Cxt -> Maybe Name -> Doc -> Maybe Kind -> [Con] -> [DerivClause] + -> Doc +ppr_type_data = ppr_typedef "type data" + ppr_typedef :: String -> Doc -> Cxt -> Maybe Name -> Doc -> Maybe Kind -> [Con] -> [DerivClause] -> Doc ppr_typedef data_or_newtype maybeInst ctxt t argsDoc ksig cs decs = sep [text data_or_newtype <+> maybeInst ===================================== libraries/template-haskell/Language/Haskell/TH/Syntax.hs ===================================== @@ -2399,6 +2399,9 @@ data Dec Con [DerivClause] -- ^ @{ newtype Cxt x => T x = A (B x) -- deriving (Z,W Q) -- deriving stock Eq }@ + | TypeDataD Name [TyVarBndr ()] + (Maybe Kind) -- Kind signature (allowed only for GADTs) + [Con] -- ^ @{ type data T x = A x | B (T x) }@ | TySynD Name [TyVarBndr ()] Type -- ^ @{ type T x = (x,x) }@ | ClassD Cxt Name [TyVarBndr ()] [FunDep] [Dec] -- ^ @{ class Eq a => Ord a where ds }@ ===================================== libraries/template-haskell/changelog.md ===================================== @@ -5,6 +5,9 @@ * The `Ppr.pprInfixT` function has gained a `Precedence` argument. * The values of named precedence levels like `Ppr.appPrec` have changed. + * Add `TypeDataD` constructor to the `Dec` type for `type data` + declarations (GHC proposal #106). + ## 2.19.0.0 * Add `DefaultD` constructor to support Haskell `default` declarations. ===================================== testsuite/tests/type-data/should_compile/TD_TH_splice.hs ===================================== @@ -0,0 +1,18 @@ +-- Check that splicing in a quoted declaration has the same effect as +-- giving the declaration directly. +{-# LANGUAGE TemplateHaskell, TypeData, GADTs #-} + +module TD_TH_splice where + +import Data.Kind (Type) + +-- splice should be equivalent to giving the declaration directly +$( [d| type data Nat = Zero | Succ Nat |] ) + +data Vec :: Nat -> Type -> Type where + VNil :: Vec Zero a + VCons :: a -> Vec n a -> Vec (Succ n) a + +instance Functor (Vec n) where + fmap _ VNil = VNil + fmap f (VCons x xs) = VCons (f x) (fmap f xs) ===================================== testsuite/tests/type-data/should_compile/all.T ===================================== @@ -3,4 +3,5 @@ test('TDExistential', normal, compile, ['']) test('TDGADT', normal, compile, ['']) test('TDGoodConsConstraints', normal, compile, ['']) test('TDVector', normal, compile, ['']) +test('TD_TH_splice', normal, compile, ['']) test('T22315a', [extra_files(['T22315a/'])], multimod_compile, ['T22315a.Lib T22315a.Main', '-v0']) ===================================== testsuite/tests/type-data/should_run/T22500.hs ===================================== @@ -0,0 +1,9 @@ +-- Check that a quoted data type declaration is printed correctly +{-# LANGUAGE TemplateHaskellQuotes, TypeData #-} + +module Main where + +import Language.Haskell.TH +import Language.Haskell.TH.Ppr + +main = putStrLn . pprint =<< runQ [d| type data Nat = Zero | Succ Nat |] ===================================== testsuite/tests/type-data/should_run/T22500.stdout ===================================== @@ -0,0 +1,3 @@ +type data Nat_0 + = Zero_1 + | Succ_2 Nat_0 ===================================== testsuite/tests/type-data/should_run/all.T ===================================== @@ -1,2 +1,3 @@ test('T22332a', exit_code(1), compile_and_run, ['']) test('T22315b', extra_files(['T22315b.hs']), ghci_script, ['T22315b.script']) +test('T22500', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4251226448f34403b07822f3017845c4855f4dea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4251226448f34403b07822f3017845c4855f4dea You're receiving 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 Dec 5 10:19:11 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 05 Dec 2022 05:19:11 -0500 Subject: [Git][ghc/ghc][master] Add BufSpan to EpaLocation (#22319, #22558) Message-ID: <638dc59fe7edf_17512e1e46a9d8108831e@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 11 changed files: - compiler/GHC/Hs/Dump.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Types/SrcLoc.hs - utils/check-exact/ExactPrint.hs - utils/check-exact/Parsers.hs - utils/check-exact/Transform.hs - utils/check-exact/Utils.hs Changes: ===================================== compiler/GHC/Hs/Dump.hs ===================================== @@ -144,7 +144,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 _ -> parens $ text "SourceText" <+> text "blanked" epaAnchor :: EpaLocation -> SDoc - epaAnchor (EpaSpan r) = parens $ text "EpaSpan" <+> realSrcSpan r + epaAnchor (EpaSpan r _) = parens $ text "EpaSpan" <+> realSrcSpan r epaAnchor (EpaDelta d cs) = case ba of NoBlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> showAstData' cs BlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> text "blanked" ===================================== compiler/GHC/Parser.y ===================================== @@ -3058,34 +3058,34 @@ tup_exprs :: { forall b. DisambECP b => PV (SumOrTuple b) } : texp commas_tup_tail { unECP $1 >>= \ $1 -> $2 >>= \ $2 -> - do { t <- amsA $1 [AddCommaAnn (EpaSpan $ rs $ fst $2)] + do { t <- amsA $1 [AddCommaAnn (srcSpan2e $ fst $2)] ; return (Tuple (Right t : snd $2)) } } | commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) (EpaSpan $ rs ll) emptyComments))) (fst $1) } + do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) (srcSpan2e ll) emptyComments))) (fst $1) } ; return (Tuple (cos ++ $2)) } } | texp bars { unECP $1 >>= \ $1 -> return $ - (Sum 1 (snd $2 + 1) $1 [] (map (EpaSpan . realSrcSpan) $ fst $2)) } + (Sum 1 (snd $2 + 1) $1 [] (map srcSpan2e $ fst $2)) } | bars texp bars0 { unECP $2 >>= \ $2 -> return $ (Sum (snd $1 + 1) (snd $1 + snd $3 + 1) $2 - (map (EpaSpan . realSrcSpan) $ fst $1) - (map (EpaSpan . realSrcSpan) $ fst $3)) } + (map srcSpan2e $ fst $1) + (map srcSpan2e $ fst $3)) } -- Always starts with commas; always follows an expr commas_tup_tail :: { forall b. DisambECP b => PV (SrcSpan,[Either (EpAnn EpaLocation) (LocatedA b)]) } commas_tup_tail : commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) (EpaSpan $ rs l) emptyComments))) (tail $ fst $1) } + do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) (srcSpan2e l) emptyComments))) (tail $ fst $1) } ; return ((head $ fst $1, cos ++ $2)) } } -- Always follows a comma tup_tail :: { forall b. DisambECP b => PV [Either (EpAnn EpaLocation) (LocatedA b)] } : texp commas_tup_tail { unECP $1 >>= \ $1 -> $2 >>= \ $2 -> - do { t <- amsA $1 [AddCommaAnn (EpaSpan $ rs $ fst $2)] + do { t <- amsA $1 [AddCommaAnn (srcSpan2e $ fst $2)] ; return (Right t : snd $2) } } | texp { unECP $1 >>= \ $1 -> return [Right $1] } @@ -3564,10 +3564,10 @@ qcon_list : qcon { sL1N $1 [$1] } sysdcon_nolist :: { LocatedN DataCon } -- Wired in data constructors : '(' ')' {% amsrn (sLL $1 $> unitDataCon) (NameAnnOnly NameParens (glAA $1) (glAA $2) []) } | '(' commas ')' {% amsrn (sLL $1 $> $ tupleDataCon Boxed (snd $2 + 1)) - (NameAnnCommas NameParens (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParens (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' '#)' {% amsrn (sLL $1 $> $ unboxedUnitDataCon) (NameAnnOnly NameParensHash (glAA $1) (glAA $2) []) } | '(#' commas '#)' {% amsrn (sLL $1 $> $ tupleDataCon Unboxed (snd $2 + 1)) - (NameAnnCommas NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } -- See Note [Empty lists] in GHC.Hs.Expr sysdcon :: { LocatedN DataCon } @@ -3601,12 +3601,12 @@ ntgtycon :: { LocatedN RdrName } -- A "general" qualified tycon, excluding unit : oqtycon { $1 } | '(' commas ')' {% amsrn (sLL $1 $> $ getRdrName (tupleTyCon Boxed (snd $2 + 1))) - (NameAnnCommas NameParens (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParens (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' commas '#)' {% amsrn (sLL $1 $> $ getRdrName (tupleTyCon Unboxed (snd $2 + 1))) - (NameAnnCommas NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' bars '#)' {% amsrn (sLL $1 $> $ getRdrName (sumTyCon (snd $2 + 1))) - (NameAnnBars NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnBars NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(' '->' ')' {% amsrn (sLL $1 $> $ getRdrName unrestrictedFunTyCon) (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } | '[' ']' {% amsrn (sLL $1 $> $ listTyCon_RDR) @@ -4210,27 +4210,27 @@ in GHC.Parser.Annotation -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself mj :: AnnKeywordId -> Located e -> AddEpAnn -mj a l = AddEpAnn a (EpaSpan $ rs $ gl l) +mj a l = AddEpAnn a (srcSpan2e $ gl l) mjN :: AnnKeywordId -> LocatedN e -> AddEpAnn -mjN a l = AddEpAnn a (EpaSpan $ rs $ glN l) +mjN a l = AddEpAnn a (srcSpan2e $ glN l) -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself, provided the span is not zero width mz :: AnnKeywordId -> Located e -> [AddEpAnn] -mz a l = if isZeroWidthSpan (gl l) then [] else [AddEpAnn a (EpaSpan $ rs $ gl l)] +mz a l = if isZeroWidthSpan (gl l) then [] else [AddEpAnn a (srcSpan2e $ gl l)] msemi :: Located e -> [TrailingAnn] -msemi l = if isZeroWidthSpan (gl l) then [] else [AddSemiAnn (EpaSpan $ rs $ gl l)] +msemi l = if isZeroWidthSpan (gl l) then [] else [AddSemiAnn (srcSpan2e $ gl l)] msemim :: Located e -> Maybe EpaLocation -msemim l = if isZeroWidthSpan (gl l) then Nothing else Just (EpaSpan $ rs $ gl l) +msemim l = if isZeroWidthSpan (gl l) then Nothing else Just (srcSpan2e $ gl l) -- |Construct an AddEpAnn from the annotation keyword and the Located Token. If -- the token has a unicode equivalent and this has been used, provide the -- unicode variant of the annotation. mu :: AnnKeywordId -> Located Token -> AddEpAnn -mu a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (EpaSpan $ rs l) +mu a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (srcSpan2e l) -- | If the 'Token' is using its unicode variant return the unicode variant of -- the annotation @@ -4253,7 +4253,7 @@ glR :: Located a -> Anchor glR la = Anchor (realSrcSpan $ getLoc la) UnchangedAnchor glAA :: Located a -> EpaLocation -glAA = EpaSpan <$> realSrcSpan . getLoc +glAA = srcSpan2e . getLoc glRR :: Located a -> RealSrcSpan glRR = realSrcSpan . getLoc @@ -4265,7 +4265,7 @@ glNR :: LocatedN a -> Anchor glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor glNRR :: LocatedN a -> EpaLocation -glNRR = EpaSpan <$> realSrcSpan . getLocA +glNRR = srcSpan2e . getLocA anc :: RealSrcSpan -> Anchor anc r = Anchor r UnchangedAnchor @@ -4395,7 +4395,7 @@ rs _ = panic "Parser should only have RealSrcSpan" hsDoAnn :: Located a -> LocatedAn t b -> AnnKeywordId -> AnnList hsDoAnn (L l _) (L ll _) kw - = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (EpaSpan $ rs l)] [] + = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (srcSpan2e l)] [] listAsAnchor :: [LocatedAn t a] -> Anchor listAsAnchor [] = spanAsAnchor noSrcSpan @@ -4435,16 +4435,16 @@ addTrailingAnnA (L (SrcSpanAnn anns l) a) ss ta = do let anns' = if isZeroWidthSpan ss then anns - else addTrailingAnnToA l (ta (EpaSpan $ rs ss)) cs anns + else addTrailingAnnToA l (ta (srcSpan2e ss)) cs anns return (L (SrcSpanAnn anns' l) a) -- ------------------------------------- addTrailingVbarL :: MonadP m => LocatedL a -> SrcSpan -> m (LocatedL a) -addTrailingVbarL la span = addTrailingAnnL la (AddVbarAnn (EpaSpan $ rs span)) +addTrailingVbarL la span = addTrailingAnnL la (AddVbarAnn (srcSpan2e span)) addTrailingCommaL :: MonadP m => LocatedL a -> SrcSpan -> m (LocatedL a) -addTrailingCommaL la span = addTrailingAnnL la (AddCommaAnn (EpaSpan $ rs span)) +addTrailingCommaL la span = addTrailingAnnL la (AddCommaAnn (srcSpan2e span)) addTrailingAnnL :: MonadP m => LocatedL a -> TrailingAnn -> m (LocatedL a) addTrailingAnnL (L (SrcSpanAnn anns l) a) ta = do @@ -4462,7 +4462,7 @@ addTrailingCommaN (L (SrcSpanAnn anns l) a) span = do -- AZ:TODO: generalise updating comments into an annotation let anns' = if isZeroWidthSpan span then anns - else addTrailingCommaToN l anns (EpaSpan $ rs span) + else addTrailingCommaToN l anns (srcSpan2e span) return (L (SrcSpanAnn anns' l) a) addTrailingCommaS :: Located StringLiteral -> EpaLocation -> Located StringLiteral ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( la2na, na2la, n2l, l2n, l2l, la2la, reLoc, reLocA, reLocL, reLocC, reLocN, - la2r, realSrcSpan, + srcSpan2e, la2e, realSrcSpan, -- ** Building up annotations extraToAnnList, reAnn, @@ -403,7 +403,7 @@ data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq) -- in the @'EpaDelta'@ variant captures any comments between the prior -- output and the thing being marked here, since we cannot otherwise -- sort the relative order. -data EpaLocation = EpaSpan !RealSrcSpan +data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] deriving (Data,Eq) @@ -447,15 +447,15 @@ getDeltaLine (DifferentLine r _) = r -- 'EpaLocation'. The parser will never insert a 'DeltaPos', so the -- partial function is safe. epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan -epaLocationRealSrcSpan (EpaSpan r) = r +epaLocationRealSrcSpan (EpaSpan r _) = r epaLocationRealSrcSpan (EpaDelta _ _) = panic "epaLocationRealSrcSpan" epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation -epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) -epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) +epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) Strict.Nothing +epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) Strict.Nothing instance Outputable EpaLocation where - ppr (EpaSpan r) = text "EpaSpan" <+> ppr r + ppr (EpaSpan r _) = text "EpaSpan" <+> ppr r ppr (EpaDelta d cs) = text "EpaDelta" <+> ppr d <+> ppr cs instance Outputable AddEpAnn where @@ -916,8 +916,12 @@ realSrcSpan _ = mkRealSrcSpan l l -- AZ temporary where l = mkRealSrcLoc (fsLit "foo") (-1) (-1) -la2r :: SrcSpanAnn' a -> RealSrcSpan -la2r l = realSrcSpan (locA l) +srcSpan2e :: SrcSpan -> EpaLocation +srcSpan2e (RealSrcSpan s mb) = EpaSpan s mb +srcSpan2e span = EpaSpan (realSrcSpan span) Strict.Nothing + +la2e :: SrcSpanAnn' a -> EpaLocation +la2e = srcSpan2e . locA extraToAnnList :: AnnList -> [AddEpAnn] -> AnnList extraToAnnList (AnnList a o c e t) as = AnnList a o c (e++as) t @@ -976,7 +980,7 @@ widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan widenSpan s as = foldl combineSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s):rest) = RealSrcSpan s Strict.Nothing : go rest + go (AddEpAnn _ (EpaSpan s mb):rest) = RealSrcSpan s mb : go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest -- | The annotations need to all come after the anchor. Make sure @@ -985,7 +989,7 @@ widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan widenRealSpan s as = foldl combineRealSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s):rest) = s : go rest + go (AddEpAnn _ (EpaSpan s _):rest) = s : go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest widenAnchor :: Anchor -> [AddEpAnn] -> Anchor ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3646,7 +3646,7 @@ warn_unknown_prag prags span buf len buf2 = do -- 'AddEpAnn' values for the opening and closing bordering on the start -- and end of the span mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) -mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo),AddEpAnn AnnCloseP (EpaSpan lc)) +mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCloseP (EpaSpan lc Strict.Nothing)) where f = srcSpanFile ss sl = srcSpanStartLine ss ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -471,13 +471,13 @@ annBinds a cs (HsIPBinds an bs) = (HsIPBinds (add_where a an cs) bs, Nothing) annBinds _ cs (EmptyLocalBinds x) = (EmptyLocalBinds x, Just cs) add_where :: AddEpAnn -> EpAnn AnnList -> EpAnnComments -> EpAnn AnnList -add_where an@(AddEpAnn _ (EpaSpan rs)) (EpAnn a (AnnList anc o c r t) cs) cs2 +add_where an@(AddEpAnn _ (EpaSpan rs _)) (EpAnn a (AnnList anc o c r t) cs) cs2 | valid_anchor (anchor a) = EpAnn (widenAnchor a [an]) (AnnList anc o c (an:r) t) (cs Semi.<> cs2) | otherwise = EpAnn (patch_anchor rs a) (AnnList (fmap (patch_anchor rs) anc) o c (an:r) t) (cs Semi.<> cs2) -add_where an@(AddEpAnn _ (EpaSpan rs)) EpAnnNotUsed cs +add_where an@(AddEpAnn _ (EpaSpan rs _)) EpAnnNotUsed cs = EpAnn (Anchor rs UnchangedAnchor) (AnnList (Just $ Anchor rs UnchangedAnchor) Nothing Nothing [an] []) cs add_where (AddEpAnn _ (EpaDelta _ _)) _ _ = panic "add_where" @@ -501,7 +501,7 @@ fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) -- | The 'Anchor' for a stmtlist is based on either the location or -- the first semicolon annotion. stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Anchor -stmtsAnchor (L l ((ConsOL (AddEpAnn _ (EpaSpan r)) _), _)) +stmtsAnchor (L l ((ConsOL (AddEpAnn _ (EpaSpan r _)) _), _)) = widenAnchorR (Anchor (realSrcSpan l) UnchangedAnchor) r stmtsAnchor (L l _) = Anchor (realSrcSpan l) UnchangedAnchor @@ -1039,13 +1039,13 @@ checkTyClHdr is_cls ty newAnns (SrcSpanAnn EpAnnNotUsed l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (realSrcSpan l) (anchor as) - an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (EpaSpan $ realSrcSpan l) c []) cs) + an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (srcSpan2e l) c []) cs) in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) newAnns _ EpAnnNotUsed = panic "missing AnnParen" newAnns (SrcSpanAnn (EpAnn ap (AnnListItem ta) csp) l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (anchor ap) (anchor as) - an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (EpaSpan $ realSrcSpan l) c ta) (csp Semi.<> cs)) + an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs)) in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) -- | Yield a parse error if we have a function applied directly to a do block @@ -2855,7 +2855,7 @@ checkImportSpec ie@(L _ specs) = mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P ([AddEpAnn], ImpExpSubSpec) mkImpExpSubSpec [] = return ([], ImpExpList []) mkImpExpSubSpec [L la ImpExpQcWildcard] = - return ([AddEpAnn AnnDotdot (EpaSpan $ la2r la)], ImpExpAll) + return ([AddEpAnn AnnDotdot (la2e la)], ImpExpAll) mkImpExpSubSpec xs = if (any (isImpExpQcWildcard . unLoc) xs) then return $ ([], ImpExpAllWith xs) @@ -3124,14 +3124,14 @@ mkMultTy pct t arr = HsExplicitMult pct t arr mkTokenLocation :: SrcSpan -> TokenLocation mkTokenLocation (UnhelpfulSpan _) = NoTokenLoc -mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) +mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) -- Precondition: the TokenLocation has EpaSpan, never EpaDelta. token_location_widenR :: TokenLocation -> SrcSpan -> TokenLocation token_location_widenR NoTokenLoc _ = NoTokenLoc token_location_widenR tl (UnhelpfulSpan _) = tl -token_location_widenR (TokenLoc (EpaSpan r1)) (RealSrcSpan r2 _) = - (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2))) +token_location_widenR (TokenLoc (EpaSpan r1 mb1)) (RealSrcSpan r2 mb2) = + (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2) (liftA2 combineBufSpans mb1 mb2))) token_location_widenR (TokenLoc (EpaDelta _ _)) _ = -- Never happens because the parser does not produce EpaDelta. panic "token_location_widenR: EpaDelta" ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -2011,14 +2011,14 @@ printMinimalImports hsc_src imports_w_usage to_ie_post_rn_var :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn_var (L l n) - | isDataOcc $ occName n = L l (IEPattern (EpaSpan $ la2r l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (la2na l) n)) + | otherwise = L l (IEName noExtField (L (la2na l) n)) to_ie_post_rn :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn (L l n) - | isTcOcc occ && isSymOcc occ = L l (IEType (EpaSpan $ la2r l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (la2na l) n)) + | otherwise = L l (IEName noExtField (L (la2na l) n)) where occ = occName n {- ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Types.SrcLoc ( BufSpan(..), getBufSpan, removeBufSpan, + combineBufSpans, -- * Located Located, ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -543,7 +543,7 @@ printStringAtAAL (EpAnn anc an cs) l str = do printStringAtAAC :: (Monad m, Monoid w) => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation -printStringAtAAC capture (EpaSpan r) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s printStringAtAAC capture (EpaDelta d cs) s = do mapM_ (printOneComment . tokComment) cs pe1 <- getPriorEndD @@ -4108,7 +4108,7 @@ printUnicode anc n = do s -> s loc <- printStringAtAAC NoCaptureComments (EpaDelta (SameLine 0) []) str case loc of - EpaSpan _ -> return anc + EpaSpan _ _ -> return anc EpaDelta dp [] -> return anc { anchor_op = MovedAnchor dp } EpaDelta _ _cs -> error "printUnicode should not capture comments" ===================================== utils/check-exact/Parsers.hs ===================================== @@ -285,7 +285,7 @@ fixModuleTrailingComments (GHC.L l p) = GHC.L l p' rebalance al cs = cs' where cs' = case GHC.al_close al of - Just (GHC.AddEpAnn _ (GHC.EpaSpan ss)) -> + Just (GHC.AddEpAnn _ (GHC.EpaSpan ss _)) -> let pc = GHC.priorComments cs fc = GHC.getFollowingComments cs ===================================== utils/check-exact/Transform.hs ===================================== @@ -213,7 +213,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H L (SrcSpanAnn EpAnnNotUsed ll) _ -> realSrcSpan ll L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor? dc' = case dca of - EpaSpan r -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) + EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) EpaDelta _ _ -> AddEpAnn kw dca -- --------------------------------- @@ -223,7 +223,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H (L (SrcSpanAnn EpAnnNotUsed ll) b) -> let op = case dca of - EpaSpan r -> MovedAnchor (ss2delta (ss2posEnd r) (realSrcSpan ll)) + EpaSpan r _ -> MovedAnchor (ss2delta (ss2posEnd r) (realSrcSpan ll)) EpaDelta _ _ -> MovedAnchor (SameLine 1) in (L (SrcSpanAnn (EpAnn (Anchor (realSrcSpan ll) op) mempty emptyComments) ll) b) (L (SrcSpanAnn (EpAnn (Anchor r op) a c) ll) b) @@ -231,7 +231,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H op' = case op of MovedAnchor _ -> op _ -> case dca of - EpaSpan dcr -> MovedAnchor (ss2delta (ss2posEnd dcr) r) + EpaSpan dcr _ -> MovedAnchor (ss2delta (ss2posEnd dcr) r) EpaDelta _ _ -> MovedAnchor (SameLine 1) in (L (SrcSpanAnn (EpAnn (Anchor r op') a c) ll) b) @@ -341,13 +341,13 @@ getEntryDP _ = SameLine 1 addEpaLocationDelta :: LayoutStartCol -> RealSrcSpan -> EpaLocation -> EpaLocation addEpaLocationDelta _off _anc (EpaDelta d cs) = EpaDelta d cs -addEpaLocationDelta off anc (EpaSpan r) +addEpaLocationDelta off anc (EpaSpan r _) = EpaDelta (adjustDeltaForOffset off (ss2deltaEnd anc r)) [] -- Set the entry DP for an element coming after an existing keyword annotation setEntryDPFromAnchor :: LayoutStartCol -> EpaLocation -> LocatedA t -> LocatedA t setEntryDPFromAnchor _off (EpaDelta _ _) (L la a) = L la a -setEntryDPFromAnchor off (EpaSpan anc) ll@(L la _) = setEntryDP ll dp' +setEntryDPFromAnchor off (EpaSpan anc _) ll@(L la _) = setEntryDP ll dp' where r = case la of (SrcSpanAnn EpAnnNotUsed l) -> realSrcSpan l @@ -944,7 +944,7 @@ instance HasDecls (LocatedA (HsExpr GhcPs)) where (L (TokenLoc l) ls, L (TokenLoc i) is) -> let off = case l of - (EpaSpan r) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan r _) -> LayoutStartCol $ snd $ ss2pos r (EpaDelta (SameLine _) _) -> LayoutStartCol 0 (EpaDelta (DifferentLine _ c) _) -> LayoutStartCol c ex'' = setEntryDPFromAnchor off i ex ===================================== utils/check-exact/Utils.hs ===================================== @@ -119,7 +119,7 @@ undelta (l,_) (DifferentLine dl dc) (LayoutStartCol co) = (fl,fc) fc = co + dc undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn -undeltaSpan anchor kw dp = AddEpAnn kw (EpaSpan sp) +undeltaSpan anchor kw dp = AddEpAnn kw (EpaSpan sp Strict.Nothing) where (l,c) = undelta (ss2pos anchor) dp (LayoutStartCol 0) len = length (keywordToString kw) @@ -256,7 +256,7 @@ sortEpaComments cs = sortBy cmp cs -- | Makes a comment which originates from a specific keyword. mkKWComment :: AnnKeywordId -> EpaLocation -> Comment -mkKWComment kw (EpaSpan ss) +mkKWComment kw (EpaSpan ss _) = Comment (keywordToString kw) (Anchor ss UnchangedAnchor) ss (Just kw) mkKWComment kw (EpaDelta dp _) = Comment (keywordToString kw) (Anchor placeholderRealSpan (MovedAnchor dp)) placeholderRealSpan (Just kw) @@ -373,7 +373,7 @@ addEpAnnLoc (AddEpAnn _ l) = l -- TODO: move this to GHC anchorToEpaLocation :: Anchor -> EpaLocation -anchorToEpaLocation (Anchor r UnchangedAnchor) = EpaSpan r +anchorToEpaLocation (Anchor r UnchangedAnchor) = EpaSpan r Strict.Nothing anchorToEpaLocation (Anchor _ (MovedAnchor dp)) = EpaDelta dp [] -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a767fa359d22ca7637af41e29434e76487c3f21 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1a767fa359d22ca7637af41e29434e76487c3f21 You're receiving 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 Dec 5 11:14:29 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 05 Dec 2022 06:14:29 -0500 Subject: [Git][ghc/ghc][wip/T22317] 73 commits: configure: Don't check for an unsupported version of LLVM Message-ID: <638dd2955b20b_17512ed8b993c110701f@gitlab.mail> Sebastian Graf pushed to branch wip/T22317 at Glasgow Haskell Compiler / GHC Commits: 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 75320666 by Sebastian Graf at 2022-12-05T12:10:25+01:00 Simplifier: Fix `conSize` estimate (#22317) The estimate we used to have was far too optimistic (#22317). We now size up constructor applications like we do function applications. See the changes to `Note [Constructor size and result discount]`. I also made sure that join points are not affected by `Note [Inlining small things to avoid creating a thunk]`. Fixes #22317; regression test in T22317b. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/ProcPoint.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/Wasm/Types.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c52f215bfb5b3679087f57b8016646bd854bb63...753206665c7f4aba4df7d67e5de9baf5f16ea039 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c52f215bfb5b3679087f57b8016646bd854bb63...753206665c7f4aba4df7d67e5de9baf5f16ea039 You're receiving 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 Dec 5 11:18:53 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 05 Dec 2022 06:18:53 -0500 Subject: [Git][ghc/ghc][wip/T22317] Fix warnings in ExactPrint (#22555) Message-ID: <638dd39d24f2e_17512e2b979994111225a@gitlab.mail> Sebastian Graf pushed to branch wip/T22317 at Glasgow Haskell Compiler / GHC Commits: d27231cd by Sebastian Graf at 2022-12-05T12:18:47+01:00 Fix warnings in ExactPrint (#22555) - - - - - 1 changed file: - utils/check-exact/ExactPrint.hs Changes: ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -15,6 +15,7 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE BlockArguments #-} {-# LANGUAGE UndecidableInstances #-} -- For the (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ExactPrint instance +{-# OPTIONS_GHC -Wno-unused-matches -Wno-incomplete-uni-patterns #-} module ExactPrint ( View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d27231cd93a2ca175db1bab0b196218ee8e682d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d27231cd93a2ca175db1bab0b196218ee8e682d6 You're receiving 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 Dec 5 13:19:49 2022 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Mon, 05 Dec 2022 08:19:49 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/js-rts-fixmes Message-ID: <638deff585bca_17512e38d2cbec1133091@gitlab.mail> Josh Meredith pushed new branch wip/js-rts-fixmes at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/js-rts-fixmes You're receiving 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 Dec 5 13:43:50 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Mon, 05 Dec 2022 08:43:50 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/decl-invis-binders Message-ID: <638df596c868e_17512e2b9799941139210@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/decl-invis-binders at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/decl-invis-binders You're receiving 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 Dec 5 14:18:40 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 05 Dec 2022 09:18:40 -0500 Subject: [Git][ghc/ghc][wip/T22317] Fix warnings in ExactPrint (#22555) Message-ID: <638dfdc0af644_17512ed8b993c115076e@gitlab.mail> Sebastian Graf pushed to branch wip/T22317 at Glasgow Haskell Compiler / GHC Commits: 3e8398e7 by Sebastian Graf at 2022-12-05T15:18:31+01:00 Fix warnings in ExactPrint (#22555) - - - - - 18 changed files: - compiler/GHC/Core/Unfold.hs - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/deSugar/should_compile/T16615.stderr - testsuite/tests/numeric/should_compile/T14170.stdout - 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/T18013.stderr - 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/spec-inline.stderr - testsuite/tests/stranal/should_compile/T20510.stderr - testsuite/tests/stranal/should_compile/T21128.stderr - testsuite/tests/typecheck/should_compile/T13032.stderr - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -698,19 +698,24 @@ funSize opts top_args fun n_val_args voids conSize :: DataCon -> Int -> ExprSize conSize dc n_val_args - | n_val_args == 0 = SizeIs 0 emptyBag 10 -- Like variables - -- See Note [Unboxed tuple size and result discount] | isUnboxedTupleDataCon dc = SizeIs 0 emptyBag 10 -- See Note [Constructor size and result discount] - | otherwise = SizeIs (callSize n_val_args 0) emptyBag 10 + | otherwise = SizeIs (6 * n_val_args) emptyBag 10 {- Note [Constructor size and result discount] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We generally compute the size of a constructor application as if it was -a regular function call (#22317); the size of the code we generate is similar. -We have an extra case for when it's a nullary application, in which case it is +Constructor applications are generally a bit smaller than function calls, but +we have to ensure that we don't duplicate a lot of big record updates. +So every value argument contributes a size of 6, but SG's experiments concluded +that any factor between 6 and 9 would work: + * A factor of 10 means we don't inline eftWord anymore (undesirable for + T15263) + * But a factor of 5 means we get too much inlining in T22317b. +Picking 6 seems to have the lowest potential for breaking performance changes, +so that's what we go with. +A side effect of the formula is that a nullary constructor application is treated the same as a lone variable. The "result discount" is applied if the result of the call is ===================================== testsuite/tests/deSugar/should_compile/T13208.stdout ===================================== @@ -3,4 +3,4 @@ Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}] f = \ (@p) _ [Occ=Dead] -> GHC.Types.True Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 120 10}] ===================================== testsuite/tests/deSugar/should_compile/T16615.stderr ===================================== @@ -7,7 +7,7 @@ Result size of Desugar (after optimization) T16615.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 120 10}] T16615.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T16615"#) @@ -17,7 +17,7 @@ Rec { g :: Int -> Bool [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 120 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 130 10}] g = \ (i :: Int) -> case == @Int GHC.Classes.$fEqInt i (GHC.Types.I# 0#) of { False -> f (pred @Int GHC.Enum.$fEnumInt i); @@ -28,7 +28,7 @@ g = \ (i :: Int) -> f [Occ=LoopBreaker] :: Int -> Bool [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 120 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 130 10}] f = \ (i :: Int) -> case == @Int GHC.Classes.$fEqInt i (GHC.Types.I# 0#) of { False -> g (pred @Int GHC.Enum.$fEnumInt i); ===================================== testsuite/tests/numeric/should_compile/T14170.stdout ===================================== @@ -14,7 +14,7 @@ NatVal.$trModule4 = "main"# NatVal.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] NatVal.$trModule3 = GHC.Types.TrNameS NatVal.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ NatVal.$trModule2 = "NatVal"# NatVal.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] NatVal.$trModule1 = GHC.Types.TrNameS NatVal.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] NatVal.$trModule = GHC.Types.Module NatVal.$trModule3 NatVal.$trModule1 @@ -43,7 +43,7 @@ NatVal.$trModule foo :: Integer [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] foo = GHC.Num.Integer.IS 0# ===================================== testsuite/tests/numeric/should_compile/T14465.stdout ===================================== @@ -7,7 +7,7 @@ Result size of Tidy Core ten :: Natural [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] ten = GHC.Num.Natural.NS 10## -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -21,7 +21,7 @@ M.$trModule4 = "main"# M.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] M.$trModule3 = GHC.Types.TrNameS M.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -35,14 +35,14 @@ M.$trModule2 = "M"# M.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] M.$trModule1 = GHC.Types.TrNameS M.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} M.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] M.$trModule = GHC.Types.Module M.$trModule3 M.$trModule1 -- RHS size: {terms: 1, types: 1, coercions: 0, joins: 0/0} @@ -59,14 +59,14 @@ minusOne = GHC.Prim.Exception.raiseUnderflow @Natural twoTimesTwo :: Natural [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] twoTimesTwo = GHC.Num.Natural.NS 4## -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.one1 :: Natural [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] M.one1 = GHC.Num.Natural.NS 1## -- RHS size: {terms: 4, types: 1, coercions: 0, joins: 0/0} ===================================== testsuite/tests/numeric/should_compile/T7116.stdout ===================================== @@ -14,7 +14,7 @@ T7116.$trModule4 = "main"# T7116.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7116.$trModule3 = GHC.Types.TrNameS T7116.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T7116.$trModule2 = "T7116"# T7116.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7116.$trModule1 = GHC.Types.TrNameS T7116.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7116.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T7116.$trModule = GHC.Types.Module T7116.$trModule3 T7116.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -34,7 +34,7 @@ T13143.$trModule4 = "main"# T13143.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -48,14 +48,14 @@ T13143.$trModule2 = "T13143"# T13143.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T13143.$trModule1 = GHC.Types.TrNameS T13143.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T13143.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T13143.$trModule = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T18013.stderr ===================================== @@ -131,65 +131,30 @@ Rule fired: Class op fmap (BUILTIN) ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 52, types: 95, coercions: 17, joins: 0/1} + = {terms: 64, types: 125, coercions: 17, joins: 0/1} --- RHS size: {terms: 37, types: 78, coercions: 17, joins: 0/1} -mapMaybeRule [InlPrag=[2]] - :: forall a b. Rule IO a b -> Rule IO (Maybe a) (Maybe b) -[GblId, - Arity=1, - Str=<1!P(L,LC(S,C(1,C(1,P(L,1L)))))>, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (@a) (@b) (f [Occ=Once1!] :: Rule IO a b) -> - case f of { Rule @s ww ww1 [Occ=OnceL1!] -> - T18013a.Rule - @IO - @(Maybe a) - @(Maybe b) - @s - ww - ((\ (s2 [Occ=Once1] :: s) - (a1 [Occ=Once1!] :: Maybe a) - (s1 [Occ=Once2] :: GHC.Prim.State# GHC.Prim.RealWorld) -> - case a1 of { - Nothing -> - (# s1, T18013a.Result @s @(Maybe b) ww (GHC.Maybe.Nothing @b) #); - Just x [Occ=Once1] -> - case ((ww1 s2 x) - `cast` :: IO (Result s b) - ~R# (GHC.Prim.State# GHC.Prim.RealWorld - -> (# GHC.Prim.State# GHC.Prim.RealWorld, - Result s b #))) - s1 - of - { (# ipv [Occ=Once1], ipv1 [Occ=Once1!] #) -> - case ipv1 of { Result t2 [Occ=Once1] c1 [Occ=Once1] -> - (# ipv, T18013a.Result @s @(Maybe b) t2 (GHC.Maybe.Just @b c1) #) - } - } - }) - `cast` :: (s - -> Maybe a - -> GHC.Prim.State# GHC.Prim.RealWorld - -> (# GHC.Prim.State# GHC.Prim.RealWorld, - Result s (Maybe b) #)) - ~R# (s -> Maybe a -> IO (Result s (Maybe b)))) - }}] -mapMaybeRule - = \ (@a) (@b) (f :: Rule IO a b) -> - case f of { Rule @s ww ww1 -> +-- RHS size: {terms: 39, types: 71, coercions: 17, joins: 0/1} +T18013.$wmapMaybeRule [InlPrag=[2]] + :: forall {a} {b} {s}. + s -> (s -> a -> IO (Result s b)) -> Rule IO (Maybe a) (Maybe b) +[GblId[StrictWorker([!])], + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 60] 220 10}] +T18013.$wmapMaybeRule + = \ (@a) (@b) (@s) (ww :: s) (ww1 :: s -> a -> IO (Result s b)) -> + case ww of ww2 { __DEFAULT -> let { lvl :: Result s (Maybe b) [LclId, Unf=OtherCon []] - lvl = T18013a.Result @s @(Maybe b) ww (GHC.Maybe.Nothing @b) } in + lvl = T18013a.Result @s @(Maybe b) ww2 (GHC.Maybe.Nothing @b) } in T18013a.Rule @IO @(Maybe a) @(Maybe b) @s - ww + ww2 ((\ (s2 :: s) (a1 :: Maybe a) (s1 :: GHC.Prim.State# GHC.Prim.RealWorld) -> @@ -216,6 +181,25 @@ mapMaybeRule ~R# (s -> Maybe a -> IO (Result s (Maybe b)))) } +-- RHS size: {terms: 9, types: 21, coercions: 0, joins: 0/0} +mapMaybeRule [InlPrag=[2]] + :: forall a b. Rule IO a b -> Rule IO (Maybe a) (Maybe b) +[GblId, + Arity=1, + Str=<1!P(1L,LC(S,C(1,C(1,P(L,1L)))))>, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (@a) (@b) (f [Occ=Once1!] :: Rule IO a b) -> + case f of { Rule @s ww [Occ=Once1] ww1 [Occ=Once1] -> + T18013.$wmapMaybeRule @a @b @s ww ww1 + }}] +mapMaybeRule + = \ (@a) (@b) (f :: Rule IO a b) -> + case f of { Rule @s ww ww1 -> + T18013.$wmapMaybeRule @a @b @s ww ww1 + } + -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18013.$trModule4 :: GHC.Prim.Addr# [GblId, @@ -227,7 +211,7 @@ T18013.$trModule4 = "main"# T18013.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T18013.$trModule3 = GHC.Types.TrNameS T18013.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -241,14 +225,14 @@ T18013.$trModule2 = "T18013"# T18013.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T18013.$trModule1 = GHC.Types.TrNameS T18013.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18013.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T18013.$trModule = GHC.Types.Module T18013.$trModule3 T18013.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T3717.stderr ===================================== @@ -14,7 +14,7 @@ T3717.$trModule4 = "main"# T3717.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T3717.$trModule3 = GHC.Types.TrNameS T3717.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T3717.$trModule2 = "T3717"# T3717.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T3717.$trModule1 = GHC.Types.TrNameS T3717.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3717.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T3717.$trModule = GHC.Types.Module T3717.$trModule3 T3717.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T3772.stdout ===================================== @@ -14,7 +14,7 @@ T3772.$trModule4 = "main"# T3772.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T3772.$trModule3 = GHC.Types.TrNameS T3772.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T3772.$trModule2 = "T3772"# T3772.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T3772.$trModule1 = GHC.Types.TrNameS T3772.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3772.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T3772.$trModule = GHC.Types.Module T3772.$trModule3 T3772.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T4908.stderr ===================================== @@ -14,7 +14,7 @@ T4908.$trModule4 = "main"# T4908.$trModule3 :: TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T4908.$trModule3 = GHC.Types.TrNameS T4908.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T4908.$trModule2 = "T4908"# T4908.$trModule1 :: TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T4908.$trModule1 = GHC.Types.TrNameS T4908.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T4908.$trModule :: Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T4908.$trModule = GHC.Types.Module T4908.$trModule3 T4908.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T4930.stderr ===================================== @@ -14,7 +14,7 @@ T4930.$trModule4 = "main"# T4930.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T4930.$trModule3 = GHC.Types.TrNameS T4930.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T4930.$trModule2 = "T4930"# T4930.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T4930.$trModule1 = GHC.Types.TrNameS T4930.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T4930.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T4930.$trModule = GHC.Types.Module T4930.$trModule3 T4930.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -80,7 +80,7 @@ T7360.$trModule4 = "main"# T7360.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$trModule3 = GHC.Types.TrNameS T7360.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -94,14 +94,14 @@ T7360.$trModule2 = "T7360"# T7360.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$trModule1 = GHC.Types.TrNameS T7360.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7360.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T7360.$trModule = GHC.Types.Module T7360.$trModule3 T7360.$trModule1 @@ -123,14 +123,14 @@ T7360.$tcFoo2 = "Foo"# T7360.$tcFoo1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$tcFoo1 = GHC.Types.TrNameS T7360.$tcFoo2 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tcFoo :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}] T7360.$tcFoo = GHC.Types.TyCon 1581370841583180512#Word64 @@ -158,14 +158,14 @@ T7360.$tc'Foo6 = "'Foo1"# T7360.$tc'Foo5 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$tc'Foo5 = GHC.Types.TrNameS T7360.$tc'Foo6 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo1 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}] T7360.$tc'Foo1 = GHC.Types.TyCon 3986951253261644518#Word64 @@ -186,14 +186,14 @@ T7360.$tc'Foo8 = "'Foo2"# T7360.$tc'Foo7 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$tc'Foo7 = GHC.Types.TrNameS T7360.$tc'Foo8 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo2 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}] T7360.$tc'Foo2 = GHC.Types.TyCon 17325079864060690428#Word64 @@ -219,14 +219,14 @@ T7360.$tc'Foo11 = "'Foo3"# T7360.$tc'Foo10 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$tc'Foo10 = GHC.Types.TrNameS T7360.$tc'Foo11 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo3 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}] T7360.$tc'Foo3 = GHC.Types.TyCon 3674231676522181654#Word64 ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -14,7 +14,7 @@ Roman.$trModule4 = "main"# Roman.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] Roman.$trModule3 = GHC.Types.TrNameS Roman.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ Roman.$trModule2 = "Roman"# Roman.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] Roman.$trModule1 = GHC.Types.TrNameS Roman.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} Roman.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] Roman.$trModule = GHC.Types.Module Roman.$trModule3 Roman.$trModule1 @@ -129,14 +129,14 @@ Roman.foo_go Roman.foo2 :: Int [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] Roman.foo2 = GHC.Types.I# 6# -- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} Roman.foo1 :: Maybe Int [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 -- RHS size: {terms: 11, types: 4, coercions: 0, joins: 0/0} ===================================== testsuite/tests/stranal/should_compile/T20510.stderr ===================================== @@ -1,90 +1,55 @@ ==================== Exitification transformation ==================== Result size of Exitification transformation - = {terms: 50, types: 22, coercions: 0, joins: 2/2} + = {terms: 51, types: 23, coercions: 0, joins: 2/2} --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl :: Int -[LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] -lvl = GHC.Types.I# 0# - --- RHS size: {terms: 32, types: 14, coercions: 0, joins: 2/2} -small :: Int -> Int -[LclIdX, +-- RHS size: {terms: 25, types: 10, coercions: 0, joins: 2/2} +$wsmall [InlPrag=[2]] :: GHC.Prim.Int# -> GHC.Prim.Int# +[LclId[StrictWorker([])], Arity=1, - Str=, - Cpr=1, - 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= \ (x [Dmd=SP(SL)] :: Int) -> - joinrec { - go [InlPrag=[2], Occ=T[2]] :: Int -> Int -> Int - [LclId[JoinId(2)], - Arity=2, - Str=, - Unf=Unf{Src=InlineStable, TopLvl=False, Value=True, ConLike=True, - WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (z [Occ=Once1!, Dmd=SP(L)] :: Int) - (ds [Occ=Once1!, Dmd=SP(SL)] :: Int) -> - case z of { GHC.Types.I# ww [Occ=Once1] -> - case ds of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> - jump $wgo ww ww - } - }}] - go (z [Occ=Once1!, Dmd=SP(L)] :: Int) - (ds [Occ=Once1!, Dmd=SP(SL)] :: Int) - = case z of { GHC.Types.I# ww [Occ=Once1] -> - case ds of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> - jump $wgo ww ww - } - }; - $wgo [InlPrag=[2], Occ=LoopBreakerT[2]] - :: GHC.Prim.Int# -> GHC.Prim.Int# -> Int - [LclId[JoinId(2)], - Arity=2, - Str=, - Unf=Unf{Src=, TopLvl=False, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 51] 69 10}] - $wgo (ww [Occ=Once2] :: GHC.Prim.Int#) - (ww [Occ=Once1!, Dmd=SL] :: GHC.Prim.Int#) - = case ww of ds { - __DEFAULT -> - jump go - (GHC.Types.I# (GHC.Prim.+# ww ds)) - (GHC.Types.I# (GHC.Prim.-# ds 1#)); - 0# -> - case x of { GHC.Types.I# y [Occ=Once1] -> - GHC.Types.I# (GHC.Prim.*# ww y) - } - }; } in - jump go lvl x}] -small - = \ (x [Dmd=SP(SL)] :: Int) -> + Str=, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 35 0}] +$wsmall + = \ (ww [Dmd=SL] :: GHC.Prim.Int#) -> join { - exit :: GHC.Prim.Int# -> Int - [LclId[JoinId(1)]] - exit (ww :: GHC.Prim.Int#) - = case x of { GHC.Types.I# y -> - GHC.Types.I# (GHC.Prim.*# ww y) - } } in + exit :: GHC.Prim.Int# -> GHC.Prim.Int# + [LclId[JoinId(1)(Nothing)]] + exit (ww :: GHC.Prim.Int#) = GHC.Prim.*# ww ww } in joinrec { $wgo [InlPrag=[2], Occ=LoopBreaker] - :: GHC.Prim.Int# -> GHC.Prim.Int# -> Int - [LclId[JoinId(2)], + :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# + [LclId[JoinId(2)(Just [])], Arity=2, Str=, Unf=Unf{Src=, TopLvl=False, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 38] 49 10}] + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=True)}] $wgo (ww :: GHC.Prim.Int#) (ww [Dmd=SL] :: GHC.Prim.Int#) = case ww of ds { __DEFAULT -> jump $wgo (GHC.Prim.+# ww ds) (GHC.Prim.-# ds 1#); 0# -> jump exit ww }; } in - case x of { GHC.Types.I# ww [Dmd=SL] -> jump $wgo 0# ww } + jump $wgo 0# ww + +-- RHS size: {terms: 10, types: 4, coercions: 0, joins: 0/0} +small [InlPrag=[2]] :: Int -> Int +[LclIdX, + Arity=1, + Str=, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (x [Occ=Once1!, Dmd=S!P(SL)] :: Int) -> + case x of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> + case $wsmall ww of ww [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww } + }}] +small + = \ (x [Dmd=S!P(SL)] :: Int) -> + case x of { GHC.Types.I# ww [Dmd=SL] -> + case $wsmall ww of ww { __DEFAULT -> GHC.Types.I# ww } + } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Prim.Addr# @@ -97,7 +62,7 @@ $trModule = "main"# $trModule :: GHC.Types.TrName [LclId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] $trModule = GHC.Types.TrNameS $trModule -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -111,14 +76,14 @@ $trModule = "T20510"# $trModule :: GHC.Types.TrName [LclId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] $trModule = GHC.Types.TrNameS $trModule -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T20510.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T20510.$trModule = GHC.Types.Module $trModule $trModule ===================================== testsuite/tests/stranal/should_compile/T21128.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 125, types: 68, coercions: 4, joins: 0/0} + = {terms: 124, types: 69, coercions: 4, joins: 1/1} lvl = "error"# @@ -48,12 +48,13 @@ index = \ l u i -> case l of { I# x -> case i of { I# y -> + join { $j = case u of { I# ww -> $wlvl y ww x } } in case <=# x y of { - __DEFAULT -> case u of { I# ww -> $wlvl y ww x }; + __DEFAULT -> jump $j; 1# -> case u of { I# y1 -> case <# y y1 of { - __DEFAULT -> $wlvl y y1 x; + __DEFAULT -> jump $j; 1# -> I# (-# y x) } } @@ -66,7 +67,7 @@ index ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 108, types: 46, coercions: 0, joins: 3/3} + = {terms: 107, types: 47, coercions: 0, joins: 4/5} $trModule4 = "main"# @@ -82,25 +83,27 @@ i = I# 1# l = I# 0# -lvl = \ x ww -> indexError $fShowInt x (I# ww) i +lvl = \ x y -> indexError $fShowInt x y i -lvl1 = \ ww -> indexError $fShowInt l (I# ww) l +lvl1 = \ y -> indexError $fShowInt l y l $wtheresCrud = \ ww ww1 -> + let { y = I# ww1 } in join { exit = case <# 0# ww1 of { - __DEFAULT -> case lvl1 ww1 of wild { }; + __DEFAULT -> case lvl1 y of wild { }; 1# -> 0# } } in join { exit1 - = case <=# ww 1# of { - __DEFAULT -> case lvl (I# ww) ww1 of wild { }; + = join { $j = case lvl (I# ww) y of wild { } } in + case <=# ww 1# of { + __DEFAULT -> jump $j; 1# -> case <# 1# ww1 of { - __DEFAULT -> case lvl (I# ww) ww1 of wild { }; + __DEFAULT -> jump $j; 1# -> -# 1# ww } } } in ===================================== testsuite/tests/typecheck/should_compile/T13032.stderr ===================================== @@ -16,7 +16,7 @@ f = \ (@a) (@b) _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> T13032.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 120 10}] T13032.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T13032"#) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -15,6 +15,7 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE BlockArguments #-} {-# LANGUAGE UndecidableInstances #-} -- For the (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ExactPrint instance +{-# OPTIONS_GHC -Wno-unused-matches -Wno-incomplete-uni-patterns #-} module ExactPrint ( View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e8398e79655fa8e82da7244796a2ed9ddfdb0e8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e8398e79655fa8e82da7244796a2ed9ddfdb0e8 You're receiving 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 Dec 5 15:00:46 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 05 Dec 2022 10:00:46 -0500 Subject: [Git][ghc/ghc][wip/andreask/pinned] 187 commits: Remove source location information from interface files Message-ID: <638e079e534d9_17512e52be81157685@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/pinned at Glasgow Haskell Compiler / GHC Commits: 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 0122f3b0 by Andreas Klebinger at 2022-12-05T15:58:20+01:00 Don't consider large byte arrays/compact regions pinned. Workaround for #22255 which showed how treating large/compact regions as pinned could cause segfaults. - - - - - 16 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b0c2f586d6fd4e70e4ce7282fb6a07809f501b2c...0122f3b0f186823d77543f6fb9a838ed4c3e97a2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b0c2f586d6fd4e70e4ce7282fb6a07809f501b2c...0122f3b0f186823d77543f6fb9a838ed4c3e97a2 You're receiving 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 Dec 5 15:03:34 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Mon, 05 Dec 2022 10:03:34 -0500 Subject: [Git][ghc/ghc][wip/or-pats] Add tests Message-ID: <638e084615864_17512e64b9d7011591ab@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 9df48e0b by David Knothe at 2022-12-05T16:03:28+01:00 Add tests - - - - - 14 changed files: - + testsuite/tests/deSugar/should_run/Or5.hs - + testsuite/tests/deSugar/should_run/Or5.stderr - + testsuite/tests/deSugar/should_run/Or5.stdout - testsuite/tests/deSugar/should_run/all.T - + testsuite/tests/parser/should_fail/Or1.hs - + testsuite/tests/parser/should_fail/Or1.stderr - + testsuite/tests/parser/should_fail/Or2.hs - + testsuite/tests/parser/should_fail/Or2.stderr - + testsuite/tests/parser/should_fail/Or3.hs - + testsuite/tests/parser/should_fail/Or3.stderr - testsuite/tests/parser/should_fail/all.T - + testsuite/tests/rename/should_fail/Or4.hs - + testsuite/tests/rename/should_fail/Or4.stderr - testsuite/tests/rename/should_fail/all.T Changes: ===================================== testsuite/tests/deSugar/should_run/Or5.hs ===================================== @@ -0,0 +1,42 @@ +{-# LANGUAGE OrPatterns #-} +{-# LANGUAGE ViewPatterns #-} + +module Main where + +main = do + print ((f1 3) == 1) + print ((f1 5) == 3) + print ((f2 [0,2,4]) == 1) + print ((f2 [1,3]) == 2) + print ((f3 4 4) == True) + print ((f3 3 8) == True) + print (a3 == 3) + print (a4 == True) + print (a5 == True) + print (a6 == False) + print backtrack + +f1 x = case x of + 3 -> 1 + 4 -> 2 + (one of 3,4,5) -> 3 + +f2 y = case y of + (one of _:2:_, 1:_) | length y /= 2 -> 1 + (one of [1,2], 1:3:_)-> 2 + (one of _, _) -> 3 + +f3 :: (Eq a, Show a) => a -> a -> Bool +f3 a (one of (== a) -> True, show -> "8") = True +f3 _ _ = False + +a3 = (\(one of 1, 2) -> 3) 1 +a4 = (\(one of Left 0, Right 1) -> True) (Right 1) +a5 = (\(one of (one of [1], [2, _]), (one of [3, _, _], [4, _, _, _])) -> True) [4, undefined, undefined, undefined] +a6 = (\(one of 1, 2, 3) -> False) 3 + +backtrack :: String +backtrack = case (True, error "backtracking") of + (one of (True, _), (_, True)) + | False -> error "inaccessible" + _ -> error "no backtracking" \ No newline at end of file ===================================== testsuite/tests/deSugar/should_run/Or5.stderr ===================================== @@ -0,0 +1,3 @@ +Or5: no backtracking +CallStack (from HasCallStack): + error, called at Or5.hs:42:8 in main:Main ===================================== testsuite/tests/deSugar/should_run/Or5.stdout ===================================== @@ -0,0 +1,10 @@ +True +True +True +True +True +True +True +True +True +True ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -74,3 +74,5 @@ test('T19289', normal, compile_and_run, ['']) test('T19680', normal, compile_and_run, ['']) test('T19680A', normal, compile_and_run, ['']) test('T20024', exit_code(1), compile_and_run, ['']) + +test('Or5', exit_code(1), compile_and_run, ['']) ===================================== testsuite/tests/parser/should_fail/Or1.hs ===================================== @@ -0,0 +1,4 @@ +module Main where + +main = case 1 of + (one of 2, 3) -> True \ No newline at end of file ===================================== testsuite/tests/parser/should_fail/Or1.stderr ===================================== @@ -0,0 +1,4 @@ + +Or1.hs:4:4: error: [GHC-29847] + Illegal or-pattern: one of 2, 3 + Suggested fix: Perhaps you intended to use OrPatterns ===================================== testsuite/tests/parser/should_fail/Or2.hs ===================================== @@ -0,0 +1,4 @@ +module Main where + +main = case 3 of + one of 4, 5 -> False \ No newline at end of file ===================================== testsuite/tests/parser/should_fail/Or2.stderr ===================================== @@ -0,0 +1,2 @@ + +Or2.hs:4:7: error: [GHC-58481] parse error on input ‘of’ ===================================== testsuite/tests/parser/should_fail/Or3.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE OrPatterns #-} + +module Main where + +main = case 3 of + (one of 4) -> False + (one of x, _) -> x == 3 \ No newline at end of file ===================================== testsuite/tests/parser/should_fail/Or3.stderr ===================================== @@ -0,0 +1,3 @@ + +Or3.hs:6:4: error: [GHC-96152] + Or-pattern needs at least two alternatives: one of 4 ===================================== testsuite/tests/parser/should_fail/all.T ===================================== @@ -215,3 +215,7 @@ test('T21843c', normal, compile_fail, ['']) test('T21843d', normal, compile_fail, ['']) test('T21843e', normal, compile_fail, ['']) test('T21843f', normal, compile_fail, ['']) + +test('Or1', normal, compile_fail, ['']) +test('Or2', normal, compile_fail, ['']) +test('Or3', normal, compile_fail, ['']) ===================================== testsuite/tests/rename/should_fail/Or4.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE OrPatterns #-} +{-# LANGUAGE GADTs #-} + +module Main where + +data GADT a where + IsInt1 :: GADT Int + IsInt2 :: GADT Int + +foo :: a -> GADT a -> a +foo x (one of IsInt1 {}, IsInt2 {}) = x + 1 + +main = print $ foo 3 IsInt1 \ No newline at end of file ===================================== testsuite/tests/rename/should_fail/Or4.stderr ===================================== @@ -0,0 +1,131 @@ +*** Core Lint errors : in result of Desugar (before optimization) *** +Or4.hs:11:5: warning: + Out of scope: $dNum_aDz :: Num a_aDq + [LclId] + In the RHS of foo :: forall a. a -> GADT a -> a + In the body of lambda with binder a_aDq :: * + In the body of lambda with binder x_aw0 :: a_aDq + In the body of lambda with binder ds_dMh :: GADT a_aDq + In the body of lambda with binder ds_dMt :: (# #) + In an occurrence of $dNum_aDz :: Num a_aDq + Substitution: a_aDq] + CvSubst = []> +*** Offending Program *** +Rec { +$tcGADT :: TyCon +[LclIdX] +$tcGADT + = TyCon + 7315894308497656774#Word64 + 13366801423186927574#Word64 + $trModule + (TrNameS "GADT"#) + 0# + krep$*Arr* + +$tc'IsInt1 :: TyCon +[LclIdX] +$tc'IsInt1 + = TyCon + 1090152040133353571#Word64 + 3950193049621776869#Word64 + $trModule + (TrNameS "'IsInt1"#) + 0# + $krep_aLk + +$tc'IsInt2 :: TyCon +[LclIdX] +$tc'IsInt2 + = TyCon + 838859291769359256#Word64 + 1629192201818783450#Word64 + $trModule + (TrNameS "'IsInt2"#) + 0# + $krep_aLk + +$krep_aLk [InlPrag=[~]] :: KindRep +[LclId] +$krep_aLk + = KindRepTyConApp $tcGADT (: @KindRep $krep_aLl ([] @KindRep)) + +$krep_aLl [InlPrag=[~]] :: KindRep +[LclId] +$krep_aLl = KindRepTyConApp $tcInt ([] @KindRep) + +$trModule :: Module +[LclIdX] +$trModule = Module (TrNameS "main"#) (TrNameS "Main"#) + +foo :: forall a. a -> GADT a -> a +[LclIdX] +foo + = \ (@a_aDq) (x_aw0 :: a_aDq) (ds_dMh :: GADT a_aDq) -> + let { + success_dMs :: (# #) -> a_aDq + [LclId] + success_dMs + = \ (ds_dMt [OS=OneShot] :: (# #)) -> + + @a_aDq + $dNum_aDz + x_aw0 + (fromInteger @a_aDq $dNum_aDB (IS 1#)) } in + case ds_dMh of wild_00 { + IsInt1 co_aDt -> success_dMs (##); + IsInt2 co_aDv -> + let { + $dNum_aL2 :: Num Int + [LclId] + $dNum_aL2 = $fNumInt } in + let { + $dNum_aDB :: Num a_aDq + [LclId] + $dNum_aDB + = $dNum_aL2 + `cast` (Sub (Sym (Num co_aDt)_N) :: Num Int ~R# Num a_aDq) } in + let { + $dNum_aDz :: Num a_aDq + [LclId] + $dNum_aDz + = $dNum_aL2 + `cast` (Sub (Sym (Num co_aDt)_N) :: Num Int ~R# Num a_aDq) } in + success_dMs (##) + } + +main :: IO () +[LclIdX] +main + = let { + $dNum_aKU :: Num Int + [LclId] + $dNum_aKU = $fNumInt } in + let { + $dShow_aKR :: Show Int + [LclId] + $dShow_aKR = $fShowInt } in + letrec { + main_aDF :: IO () + [LclId] + main_aDF + = $ @LiftedRep + @Int + @(IO ()) + (print @Int $dShow_aKR) + (foo @Int (I# 3#) $WIsInt1); } in + main_aDF + +main :: IO () +[LclIdX] +main = runMainIO @() main +end Rec } + +*** End of Offense *** + + +: error: +Compilation had errors + + ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -180,3 +180,5 @@ test('T20147', normal, compile_fail, ['']) test('RnEmptyStatementGroup1', normal, compile_fail, ['']) test('RnImplicitBindInMdoNotation', normal, compile_fail, ['']) + +test('Or4', normal, compile_fail, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9df48e0b04ded38b535f7da84cc8a223d39e265d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9df48e0b04ded38b535f7da84cc8a223d39e265d You're receiving 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 Dec 5 18:05:29 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 05 Dec 2022 13:05:29 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/typeable-list Message-ID: <638e32e9c2e40_17512e2b9799941170034@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/typeable-list at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/typeable-list You're receiving 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 Dec 5 18:28:07 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 13:28:07 -0500 Subject: [Git][ghc/ghc][wip/T22264] 6 commits: nonmoving: Add missing no-op in busy-wait loop Message-ID: <638e38372f9cd_17512e13299fec1176182@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC Commits: ae95ecac by Ben Gamari at 2022-12-04T16:18:47-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - 4bb3c523 by Ben Gamari at 2022-12-04T16:19:25-05:00 nonmoving: Clarify comment - - - - - f885b896 by Ben Gamari at 2022-12-04T16:41:15-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - d2b42867 by Ben Gamari at 2022-12-04T19:54:23-05:00 setNumCapabilities - - - - - ba130fcd by Ben Gamari at 2022-12-04T19:54:34-05:00 nonmovingMark: noop - - - - - 8ce0eb1f by Ben Gamari at 2022-12-04T19:54:44-05:00 nonmoving: Disable shortcutting - - - - - 6 changed files: - libraries/base/GHC/Conc/Sync.hs - rts/Schedule.c - rts/include/rts/Threads.h - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/NonMovingShortcut.c Changes: ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -380,10 +380,15 @@ to avoid contention with other processes in the machine. setNumCapabilities :: Int -> IO () setNumCapabilities i | i <= 0 = failIO $ "setNumCapabilities: Capability count ("++show i++") must be positive" - | otherwise = c_setNumCapabilities (fromIntegral i) + | otherwise = do + ret <- c_setNumCapabilities (fromIntegral i) + case ret of + 0 -> return () + 1 -> yield >> setNumCapabilities i + _ -> failIO $ "setNumCapabilities: Unknown result" foreign import ccall safe "setNumCapabilities" - c_setNumCapabilities :: CUInt -> IO () + c_setNumCapabilities :: CUInt -> IO CInt -- | Returns the number of CPUs that the machine has -- ===================================== rts/Schedule.c ===================================== @@ -2212,9 +2212,12 @@ forkProcess(HsStablePtr *entry * Finally we release the Capabilities we are holding, and start * worker Tasks on the new Capabilities we created. * + * One wrinkle here is that we must also ensure that we don't change the + * capability count while the nonmoving mark thread is active. + * * ------------------------------------------------------------------------- */ -void +int setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) { #if !defined(THREADED_RTS) @@ -2234,11 +2237,15 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) Capability *old_capabilities = NULL; uint32_t old_n_capabilities = n_capabilities; + if (RELAXED_LOAD(&concurrent_coll_running)) { + return 1; + } + if (new_n_capabilities == enabled_capabilities) { - return; + return 0; } else if (new_n_capabilities <= 0) { errorBelch("setNumCapabilities: Capability count must be positive"); - return; + return 1; } @@ -2340,6 +2347,7 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) rts_unlock(cap); + return 0; #endif // THREADED_RTS } ===================================== rts/include/rts/Threads.h ===================================== @@ -85,4 +85,4 @@ extern Capability MainCapability; // Change the number of capabilities (only supports increasing the // current value at the moment). // -extern void setNumCapabilities (uint32_t new_); +extern int setNumCapabilities (uint32_t new_); ===================================== rts/sm/NonMoving.h ===================================== @@ -344,7 +344,7 @@ INLINE_HEADER bool nonmovingClosureBeingSwept(StgClosure *p) INLINE_HEADER bool isNonmovingClosure(StgClosure *p) { - return !HEAP_ALLOCED_GC(p) || Bdescr((P_)p)->flags & BF_NONMOVING; + return RtsFlags.GcFlags.useNonmoving && (!HEAP_ALLOCED_GC(p) || Bdescr((P_)p)->flags & BF_NONMOVING); } #if defined(DEBUG) ===================================== rts/sm/NonMovingMark.c ===================================== @@ -1319,8 +1319,11 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) goto done; case WHITEHOLE: - while (*(StgInfoTable* volatile*) &p->header.info == &stg_WHITEHOLE_info); - // busy_wait_nop(); // FIXME + while (*(StgInfoTable* volatile*) &p->header.info == &stg_WHITEHOLE_info) +#if defined(PARALLEL_GC) + busy_wait_nop() +#endif + ; goto try_again; default: @@ -1599,7 +1602,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) // selectee unreachable. However, we must mark the selectee regardless // to satisfy the snapshot invariant. PUSH_FIELD(sel, selectee); - nonmoving_eval_thunk_selector(queue, sel, origin); + //nonmoving_eval_thunk_selector(queue, sel, origin); break; } ===================================== rts/sm/NonMovingShortcut.c ===================================== @@ -42,7 +42,7 @@ update_selector_chain( ) { ASSERT(val != NULL); - // Make sure we don't introduce non-moving-to-moving pointers here. + // Make sure we don't introduce nonmoving-to-moving pointers here. ASSERT(isNonmovingClosure(val)); // This case we can't handle because we don't know info ptr of the closure View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f095454b5bcf0d604e62c784931f80b5d7f0fb88...8ce0eb1fc8563838fe6b6ec151eedba395a2e0d1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f095454b5bcf0d604e62c784931f80b5d7f0fb88...8ce0eb1fc8563838fe6b6ec151eedba395a2e0d1 You're receiving 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 Dec 5 19:21:04 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Mon, 05 Dec 2022 14:21:04 -0500 Subject: [Git][ghc/ghc][wip/int-index/emb-type] 74 commits: base: make Foreign.Marshal.Pool use RTS internal arena for allocation Message-ID: <638e44a075a28_17512e64b9d70117837d@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/emb-type at Glasgow Haskell Compiler / GHC Commits: 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 458c52b9 by Vladislav Zavialov at 2022-12-05T17:27:15+03:00 WIP: Visible forall in types of terms - - - - - 01861138 by Vladislav Zavialov at 2022-12-05T22:20:43+03:00 VDQ: reject nonlinear type variable bindings - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/ProcPoint.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/Wasm/Types.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/05faa91005c7921d2b9970e1526df418dacfc54d...01861138494cddef5bc605ce03a215699b62b180 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/05faa91005c7921d2b9970e1526df418dacfc54d...01861138494cddef5bc605ce03a215699b62b180 You're receiving 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 Dec 5 19:31:46 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Mon, 05 Dec 2022 14:31:46 -0500 Subject: [Git][ghc/ghc][wip/int-index/emb-type] 2 commits: WIP: Visible forall in types of terms Message-ID: <638e47225d4a8_17512e4d4b8e1011801f7@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/emb-type at Glasgow Haskell Compiler / GHC Commits: 18acf993 by Vladislav Zavialov at 2022-12-05T22:31:30+03:00 WIP: Visible forall in types of terms - - - - - c0bd4dde by Vladislav Zavialov at 2022-12-05T22:31:30+03:00 VDQ: reject nonlinear type variable bindings - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Core/TyCo/Compare.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Ticks.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.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/Gen/Pat.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Types/Origin.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Tc/Utils/Zonk.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/01861138494cddef5bc605ce03a215699b62b180...c0bd4ddea3d95b99354ff46b58be0eaa52ba5120 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/01861138494cddef5bc605ce03a215699b62b180...c0bd4ddea3d95b99354ff46b58be0eaa52ba5120 You're receiving 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 Dec 5 19:59:57 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 14:59:57 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/state-hack-nonglobal Message-ID: <638e4dbdb664d_17512e64b9d7011805c9@gitlab.mail> Ben Gamari pushed new branch wip/state-hack-nonglobal at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/state-hack-nonglobal You're receiving 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 Dec 5 23:37:49 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 18:37:49 -0500 Subject: [Git][ghc/ghc][wip/T22468] compiler: Ensure that MutVar operations have necessary barriers Message-ID: <638e80cd746d0_17512e2b97999412027f@gitlab.mail> Ben Gamari pushed to branch wip/T22468 at Glasgow Haskell Compiler / GHC Commits: f8e8fe64 by Ben Gamari at 2022-12-05T18:37:04-05:00 compiler: Ensure that MutVar operations have necessary barriers Here we add acquire and release barriers in readMutVar# and writeMutVar#, which are necessary for soundness. Fixes #22468. - - - - - 1 changed file: - compiler/GHC/StgToCmm/Prim.hs Changes: ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -283,9 +283,10 @@ emitPrimOp cfg primop = emitAssign (CmmLocal res) currentTSOExpr ReadMutVarOp -> \[mutv] -> opIntoRegs $ \[res] -> - emitAssign (CmmLocal res) (cmmLoadIndexW platform mutv (fixedHdrSizeW profile) (gcWord platform)) + emitPrimCall [res] (MO_AtomicRead (wordWidth platform) MemOrderAcquire) + [ cmmOffsetW platform mutv (fixedHdrSizeW profile) ] - WriteMutVarOp -> \[mutv, var] -> opIntoRegs $ \res@[] -> do + WriteMutVarOp -> \[mutv, var] -> opIntoRegs $ \[] -> do old_val <- CmmLocal <$> newTemp (cmmExprType platform var) emitAssign old_val (cmmLoadIndexW platform mutv (fixedHdrSizeW profile) (gcWord platform)) @@ -294,8 +295,8 @@ emitPrimOp cfg primop = -- Note that this also must come after we read the old value to ensure -- that the read of old_val comes before another core's write to the -- MutVar's value. - emitPrimCall res MO_WriteBarrier [] - emitStore (cmmOffsetW platform mutv (fixedHdrSizeW profile)) var + emitPrimCall [] (MO_AtomicWrite (wordWidth platform) MemOrderRelease) + [ cmmOffsetW platform mutv (fixedHdrSizeW profile), var ] platform <- getPlatform mkdirtyMutVarCCall <- getCode $! emitCCall View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8e8fe6413621c5e1be7cc8de6dc58d67f6e720d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8e8fe6413621c5e1be7cc8de6dc58d67f6e720d You're receiving 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 Dec 5 23:43:57 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 18:43:57 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 59 commits: Add unsafePtrEquality# restricted to UnliftedTypes Message-ID: <638e823d32141_17512e4d4b8e101203584@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 0927dde4 by Ben Gamari at 2022-12-05T18:42:59-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - ade88423 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce blockConcat - - - - - 4dd2d83f by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce MemoryOrderings - - - - - e812bb93 by Ben Gamari at 2022-12-05T18:42:59-05:00 llvm: Respect memory specified orderings - - - - - cf0915f6 by Ben Gamari at 2022-12-05T18:42:59-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 4e2ae5d2 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm/Parser: Reduce some repetition - - - - - 251f8c99 by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 699bf77a by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 65dd69f6 by Ben Gamari at 2022-12-05T18:43:25-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 938d6176 by Ben Gamari at 2022-12-05T18:43:26-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 1ee07a55 by Ben Gamari at 2022-12-05T18:43:26-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 4f85f747 by Ben Gamari at 2022-12-05T18:43:26-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/ProcPoint.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/Wasm/Types.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fe44f27593eed7fb00115df0d30ac93481201208...4f85f747b06a3be1591b52c1f15ff6588b8e5764 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fe44f27593eed7fb00115df0d30ac93481201208...4f85f747b06a3be1591b52c1f15ff6588b8e5764 You're receiving 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 Dec 5 23:44:01 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 18:44:01 -0500 Subject: [Git][ghc/ghc][wip/tsan/fixes] 81 commits: Add unsafePtrEquality# restricted to UnliftedTypes Message-ID: <638e824179ea5_17512e1e46a9d812039f9@gitlab.mail> Ben Gamari pushed to branch wip/tsan/fixes at Glasgow Haskell Compiler / GHC Commits: 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 0927dde4 by Ben Gamari at 2022-12-05T18:42:59-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - ade88423 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce blockConcat - - - - - 4dd2d83f by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce MemoryOrderings - - - - - e812bb93 by Ben Gamari at 2022-12-05T18:42:59-05:00 llvm: Respect memory specified orderings - - - - - cf0915f6 by Ben Gamari at 2022-12-05T18:42:59-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 4e2ae5d2 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm/Parser: Reduce some repetition - - - - - 251f8c99 by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 699bf77a by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 65dd69f6 by Ben Gamari at 2022-12-05T18:43:25-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 938d6176 by Ben Gamari at 2022-12-05T18:43:26-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 1ee07a55 by Ben Gamari at 2022-12-05T18:43:26-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 4f85f747 by Ben Gamari at 2022-12-05T18:43:26-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 1dba2919 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 875907eb by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/ThreadPaused: Ordering fixes - - - - - 3c86d5ff by Ben Gamari at 2022-12-05T18:43:41-05:00 eventlog: Silence spurious data race - - - - - d8798a71 by Ben Gamari at 2022-12-05T18:43:41-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - c547e241 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Use fences instead of explicit barriers - - - - - c6d790ae by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - ea0a9590 by Ben Gamari at 2022-12-05T18:43:41-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - ab49e79c by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Introduce getNumCapabilities And ensure accesses to n_capabilities are atomic (although with relaxed ordering). This is necessary as RTS API callers may concurrently call into the RTS without holding a capability. - - - - - 2c5e2a4c by Ben Gamari at 2022-12-05T18:43:41-05:00 ghc: Fix data race in dump file handling Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer. - - - - - 3c6188b5 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - e07bf7e2 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/Timer: Always use atomic operations As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded. - - - - - 8fe4d790 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - 5f2c7b91 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Encapsulate access to capabilities array - - - - - 41cc4588 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Encapsulate sched_state - - - - - 0d18f570 by Ben Gamari at 2022-12-05T18:43:41-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 702f1e17 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Style fix - - - - - 48d4940a by Ben Gamari at 2022-12-05T18:43:41-05:00 compiler: Use release store in eager blackholing - - - - - 0332abcb by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Fix ordering of makeStableName - - - - - b526f0e6 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - 52f60568 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - ae25f482 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 2cddf0c7 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Note race with wakeBlockingQueue - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/ProcPoint.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/Wasm/Types.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7222fa225adb57f276a555a70d56f22ad8858f2c...2cddf0c78ddfa1c19918b7c315c3158b9282de6d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7222fa225adb57f276a555a70d56f22ad8858f2c...2cddf0c78ddfa1c19918b7c315c3158b9282de6d You're receiving 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 Dec 5 23:44:38 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 18:44:38 -0500 Subject: [Git][ghc/ghc][wip/T22468] 77 commits: Extend documentation for Data.IORef Message-ID: <638e82669d2eb_17512e13299fec12047b2@gitlab.mail> Ben Gamari pushed to branch wip/T22468 at Glasgow Haskell Compiler / GHC Commits: f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 0927dde4 by Ben Gamari at 2022-12-05T18:42:59-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - ade88423 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce blockConcat - - - - - 4dd2d83f by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce MemoryOrderings - - - - - e812bb93 by Ben Gamari at 2022-12-05T18:42:59-05:00 llvm: Respect memory specified orderings - - - - - cf0915f6 by Ben Gamari at 2022-12-05T18:42:59-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 4e2ae5d2 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm/Parser: Reduce some repetition - - - - - 251f8c99 by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 699bf77a by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 65dd69f6 by Ben Gamari at 2022-12-05T18:43:25-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 938d6176 by Ben Gamari at 2022-12-05T18:43:26-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 1ee07a55 by Ben Gamari at 2022-12-05T18:43:26-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 4f85f747 by Ben Gamari at 2022-12-05T18:43:26-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - a9834736 by Ben Gamari at 2022-12-05T18:44:08-05:00 compiler: Ensure that MutVar operations have necessary barriers Here we add acquire and release barriers in readMutVar# and writeMutVar#, which are necessary for soundness. Fixes #22468. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/ProcPoint.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/Wasm/Types.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f8e8fe6413621c5e1be7cc8de6dc58d67f6e720d...a9834736a90aefdd32cfc15be507e22b57eedc07 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f8e8fe6413621c5e1be7cc8de6dc58d67f6e720d...a9834736a90aefdd32cfc15be507e22b57eedc07 You're receiving 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 Dec 6 00:21:20 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 19:21:20 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/tsan/nonmoving Message-ID: <638e8b00564c3_17512e52be81204945@gitlab.mail> Ben Gamari pushed new branch wip/tsan/nonmoving at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/tsan/nonmoving You're receiving 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 Dec 6 02:23:24 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 21:23:24 -0500 Subject: [Git][ghc/ghc][wip/T22264] 154 commits: Implement UNPACK support for sum types. Message-ID: <638ea79c94bc0_17512e2b9799941213332@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC Commits: 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 0927dde4 by Ben Gamari at 2022-12-05T18:42:59-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - ade88423 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce blockConcat - - - - - 4dd2d83f by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce MemoryOrderings - - - - - e812bb93 by Ben Gamari at 2022-12-05T18:42:59-05:00 llvm: Respect memory specified orderings - - - - - cf0915f6 by Ben Gamari at 2022-12-05T18:42:59-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 4e2ae5d2 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm/Parser: Reduce some repetition - - - - - 251f8c99 by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 699bf77a by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 65dd69f6 by Ben Gamari at 2022-12-05T18:43:25-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 938d6176 by Ben Gamari at 2022-12-05T18:43:26-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 1ee07a55 by Ben Gamari at 2022-12-05T18:43:26-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 4f85f747 by Ben Gamari at 2022-12-05T18:43:26-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 1dba2919 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 875907eb by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/ThreadPaused: Ordering fixes - - - - - 3c86d5ff by Ben Gamari at 2022-12-05T18:43:41-05:00 eventlog: Silence spurious data race - - - - - d8798a71 by Ben Gamari at 2022-12-05T18:43:41-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - c547e241 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Use fences instead of explicit barriers - - - - - c6d790ae by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - ea0a9590 by Ben Gamari at 2022-12-05T18:43:41-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - ab49e79c by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Introduce getNumCapabilities And ensure accesses to n_capabilities are atomic (although with relaxed ordering). This is necessary as RTS API callers may concurrently call into the RTS without holding a capability. - - - - - 2c5e2a4c by Ben Gamari at 2022-12-05T18:43:41-05:00 ghc: Fix data race in dump file handling Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer. - - - - - 3c6188b5 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - e07bf7e2 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/Timer: Always use atomic operations As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded. - - - - - 8fe4d790 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - 5f2c7b91 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Encapsulate access to capabilities array - - - - - 41cc4588 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Encapsulate sched_state - - - - - 0d18f570 by Ben Gamari at 2022-12-05T18:43:41-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 702f1e17 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Style fix - - - - - 48d4940a by Ben Gamari at 2022-12-05T18:43:41-05:00 compiler: Use release store in eager blackholing - - - - - 0332abcb by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Fix ordering of makeStableName - - - - - b526f0e6 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - 52f60568 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - ae25f482 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 2cddf0c7 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Note race with wakeBlockingQueue - - - - - a630bf97 by Ben Gamari at 2022-12-05T19:20:46-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 725c3a4d by Ben Gamari at 2022-12-05T19:20:46-05:00 nonmoving: Fix segment list races - - - - - 4fac9da4 by Ben Gamari at 2022-12-05T19:20:46-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - f63db2e5 by Ben Gamari at 2022-12-05T19:20:46-05:00 nonmoving: Eliminate race in bump_static_flag To ensure that we don't race with a mutator entering a new CAF we take the SM mutex before touching static_flag. The other option here would be to instead modify newCAF to use a CAS but the present approach is a bit safer. - - - - - cfc725d5 by Ben Gamari at 2022-12-05T19:20:46-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 7257f5b4 by Ben Gamari at 2022-12-05T19:20:46-05:00 nonmoving: Fix races in collector status tracking Mark a number of accesses to do with tracking of the status of the concurrent collection thread as atomic. No interesting races here, merely necessary to satisfy TSAN. - - - - - 69167d3d by Ben Gamari at 2022-12-05T19:20:46-05:00 nonmoving: Make segment state updates atomic - - - - - 4f0ce6eb by Ben Gamari at 2022-12-05T19:20:46-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex by not dropping the SM_MUTEX in nonmovingCollect. This requires quite a bit of rejiggering but it does seem like a better strategy. - - - - - 4d03da2d by Ben Gamari at 2022-12-05T19:20:47-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - c2dbafbb by Ben Gamari at 2022-12-05T19:20:47-05:00 nonmoving: Make bitmap accesses atomic This is a benign race on any sensible hard since these are byte accesses. Nevertheless, atomic accesses are necessary to satisfy TSAN. - - - - - 9ebb27e7 by Ben Gamari at 2022-12-05T19:20:47-05:00 nonmoving: Fix benign race in update remembered set check Relaxed load is fine here since we will take the lock before looking at the list. - - - - - 20fff668 by Ben Gamari at 2022-12-05T19:20:47-05:00 nonmoving: Fix race in shortcutting We must use an acquire load to read the info table pointer since if we find an indirection we must be certain that we see the indirectee. - - - - - 801f97e8 by Ben Gamari at 2022-12-05T19:20:47-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - d6941cde by Ben Gamari at 2022-12-05T19:24:34-05:00 nonmoving: Fix style - - - - - aae53e14 by Ben Gamari at 2022-12-05T19:24:34-05:00 nonmoving: Deduplicate assertion - - - - - 4c72ab50 by Ben Gamari at 2022-12-05T19:24:59-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - 96e53819 by Ben Gamari at 2022-12-05T19:29:46-05:00 rts/BlockAlloc: Allow disabling of internal assertions These can be quite expensive and it is sometimes useful to compile a DEBUG RTS without them. - - - - - 68bcd5b1 by Ben Gamari at 2022-12-05T19:29:46-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - 5fb7f08e by Ben Gamari at 2022-12-05T19:29:46-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - 1923554b by Ben Gamari at 2022-12-05T19:29:46-05:00 Evac: Squash data race in eval_selector_chain - - - - - ad27c93f by Ben Gamari at 2022-12-05T19:29:46-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - 692c45fd by Ben Gamari at 2022-12-05T19:29:46-05:00 nonmoving: Clarify comment - - - - - 238c5dc6 by Ben Gamari at 2022-12-05T19:29:46-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - f8988a9c by Ben Gamari at 2022-12-05T19:29:47-05:00 nonmoving: Don't push empty arrays to update remembered set Previously the write barrier of resizeSmallArray# incorrectly handled resizing of zero-sized arrays, pushing an invalid pointer to the update remembered set. Likely fixes the cause of #22264. - - - - - cab678fc by Ben Gamari at 2022-12-05T19:29:47-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. - - - - - 20175f19 by Ben Gamari at 2022-12-05T19:29:47-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - 71a2eb22 by Ben Gamari at 2022-12-05T19:29:47-05:00 nonmoving: Sanity check mutable list Assert that entries in the nonmoving generation's generational remembered set (a.k.a. mutable list) live in nonmoving generation. - - - - - e59d63e1 by Ben Gamari at 2022-12-05T19:29:47-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 69eb9874 by Ben Gamari at 2022-12-05T19:30:33-05:00 nonmoving: Fix tracking of FILLED_SWEEPING segments Previously we only updated the state of the segment at the head of each allocator's filled list. - - - - - dfb5dcc8 by Ben Gamari at 2022-12-05T19:30:34-05:00 nonmoving: Assert state of swept segments - - - - - 36ca160d by Ben Gamari at 2022-12-05T19:30:34-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive - - - - - 8b64aff0 by Ben Gamari at 2022-12-05T19:30:34-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. - - - - - dde67d6e by Ben Gamari at 2022-12-05T19:30:34-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. - - - - - 547cbcf4 by Ben Gamari at 2022-12-05T19:30:34-05:00 nonmoving: Post-sweep sanity checking - - - - - c29cff3b by Ben Gamari at 2022-12-05T19:31:14-05:00 nonmoving: Avoid n_caps race - - - - - 12c8c180 by Ben Gamari at 2022-12-05T19:31:14-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 2583862c by Ben Gamari at 2022-12-05T19:32:32-05:00 nonmoving: Paranoia - - - - - 5f7a372b by Ben Gamari at 2022-12-05T19:34:04-05:00 rts: Drop SM spinlock - - - - - bc0072b5 by Ben Gamari at 2022-12-05T19:34:04-05:00 rts: C++ typing issues Make the RTS compilable with a C++ compiler by inserting necessary casts. - - - - - e3a09262 by Ben Gamari at 2022-12-05T19:34:04-05:00 CheckGC - - - - - 536a1a2d by Ben Gamari at 2022-12-05T19:34:04-05:00 setNumCapabilities - - - - - 9b211e41 by Ben Gamari at 2022-12-05T19:34:04-05:00 nonmoving: Disable shortcutting - - - - - 4b4207f3 by Ben Gamari at 2022-12-05T19:53:22-05:00 rts: Drop racy assertion 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/ProcPoint.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.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/8ce0eb1fc8563838fe6b6ec151eedba395a2e0d1...4b4207f32fd4c0a6995e2be1a59bf2b3eff53d51 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8ce0eb1fc8563838fe6b6ec151eedba395a2e0d1...4b4207f32fd4c0a6995e2be1a59bf2b3eff53d51 You're receiving 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 Dec 6 02:55:27 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 21:55:27 -0500 Subject: [Git][ghc/ghc][wip/T22264-9.2] 26 commits: Revert "Fix combination of ArityType in andArityType" Message-ID: <638eaf1fa707c_17512ed8b993c1213751@gitlab.mail> Ben Gamari pushed to branch wip/T22264-9.2 at Glasgow Haskell Compiler / GHC Commits: 8b839c33 by Zubin Duggal at 2022-10-11T11:12:07+01:00 Revert "Fix combination of ArityType in andArityType" This reverts commit 74ef2853464255a86d88fda619eb68b08b52e689. - - - - - c45387ce by Simon Peyton Jones at 2022-10-26T15:39:08+05:30 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694 and #21755 * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * I realised that, now we have ae_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. And finally, it was the strange treatment of join-point Ids (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring * Rewrote Note [Combining case branches: optimistic one-shot-ness] Compile time improves slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- CoOpt_Read(normal) ghc/alloc 803,788,056 747,832,680 -7.1% GOOD T18223(normal) ghc/alloc 928,207,320 959,424,016 +3.1% BAD geo. mean -0.3% minimum -7.1% maximum +3.1% On Windows it's a bit better: geo mean is -0.6%, and three more benchmarks trip their compile-time bytes-allocated threshold (they were all close on the other build): T18698b(normal) ghc/alloc 235,619,776 233,219,008 -1.0% GOOD T6048(optasm) ghc/alloc 112,208,192 109,704,936 -2.2% GOOD T18140(normal) ghc/alloc 85,064,192 83,168,360 -2.2% GOOD I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3.4% increase in exchange for goodness elsewhere. Metric Decrease: CoOpt_Read T18140 T18698b T6048 Metric Increase: T18223 - - - - - 8a38c548 by Ben Gamari at 2022-10-26T15:39:08+05:30 rts: Don't clear cards of zero-length arrays Fix #21962, where attempting to clear the card table of a zero-length array resulted in an integer underflow. - - - - - 17552468 by Cheng Shao at 2022-10-26T15:39:08+05:30 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh (cherry picked from commit ee471dfb8a4a4bb5131a5baa61d1d0d22c933d5f) - - - - - 4d047b3c by Matthew Pickering at 2022-10-26T15:39:08+05:30 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 (cherry picked from commit 7f0decd5063a853fc8f38a8944b2c91995cd5e48) - - - - - 9e254001 by Ben Gamari at 2022-10-26T15:39:08+05:30 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. (cherry picked from commit 62a550010ed94e1969c96150f2781854a0802766) - - - - - 74e329d2 by Ben Gamari at 2022-10-26T15:39:08+05:30 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. (cherry picked from commit 8eff62a43cebbb21f00aeea138bcc343d8ac8f34) - - - - - 064371d3 by Douglas Wilson at 2022-10-26T15:39:09+05:30 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. (cherry picked from commit 76b52cf0c52ee05c20f7d1b80f5600eecab3c42a) - - - - - 2821391a by Douglas Wilson at 2022-10-26T15:39:09+05:30 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. (cherry picked from commit 7589ee7241d46b393979d98d4ded17a15ee974fb) - - - - - 7ad76d79 by Tamar Christina at 2022-10-26T15:39:09+05:30 winio: do not re-translate input when handle is uncooked (cherry picked from commit 626652f7c172f307bd87afaee59c7f0e2825c55d) - - - - - 63fe2ee2 by Sebastian Graf at 2022-11-03T14:21:10+05:30 Rubbish literals for all representations (#18983) This patch cleans up the complexity around WW's `mk_absent_let` by broadening the scope of `LitRubbish`. Rubbish literals now store the `PrimRep` they represent and are ultimately lowered in Cmm. This in turn allows absent literals of `VecRep` or `VoidRep`. The latter allows absent literals for unlifted coercions, as requested in #18983. I took the liberty to rewrite and clean up `Note [Absent fillers]` and `Note [Rubbish values]` to account for the new implementation and to make them more orthogonal in their description. I didn't add a new regression test, as `T18982` already contains the test in the ticket and its test output changes as expected. Fixes #18983. - - - - - 1fabaae4 by Dai at 2022-11-03T15:12:38+05:30 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 (cherry picked from commit 5b3a992f5d166007c3c5a22f120ed08e0a27f01a) - - - - - 9d469bff by sheaf at 2022-11-03T15:12:38+05:30 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. (cherry picked from commit 3be48877e204fca8e5d5ab984186e0d20d81f262) - - - - - 14e0442e by sheaf at 2022-11-03T15:12:38+05:30 Disable some SIMD tests on non-X86 architectures (cherry picked from commit f7b7a3122185222d5059e37315991afcf319e43c) - - - - - 45459cce by Zubin Duggal at 2022-11-03T15:12:38+05:30 Bump process to 1.6.16.0 - - - - - 5674eb8b by Zubin Duggal at 2022-11-03T15:12:38+05:30 Attemp fix for core lint failures For an expression: joinrec foo = ... in expr we compute the arityType as `foldr andArityType (arityType expr) [arityType foo]` which is the same as `andArityType (arityType expr) (arityType foo)`. However, this is incorrect: joinrec go x = ... in go 0 then the arity of go is 1 (\?. T), but the arity of the overall expression is 0 (_|_). `andArityType` however returns (\?. T) for these, which is wrong. (cherry picked from commit 53235edd478bd4c5e29e4f254ce02559af259dd5) - - - - - 36cfeb7c by Zubin Duggal at 2022-11-03T15:12:38+05:30 Bump base to 4.16.4.0 and add release notes - - - - - 3588c3a9 by Zubin Duggal at 2022-11-03T15:12:38+05:30 Fix bkpcabal02 - - - - - c35d3f80 by Zubin Duggal at 2022-11-03T17:15:22+05:30 Fix core lint errors to do with SIMD vector indexing in T22187_run. This patch was originally from 6d7d91817795d7ee7f45557411368a1738daa488, but all the changes in that commit can't make it because we don't want to change the interface of primops in a backport. - - - - - 784324bc by Zubin Duggal at 2022-11-04T15:39:38+05:30 Add notes for 9.2.5 - - - - - 74ca6191 by normalcoder at 2022-11-07T00:06:37+05:30 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms (cherry picked from commit 67575f2004340564d6e52af055ed6fb43d3f9711) - - - - - 98d62a98 by Ben Gamari at 2022-12-05T21:43:13-05:00 nonmoving: Don't push empty arrays to update remembered set Previously the write barrier of resizeSmallArray# incorrectly handled resizing of zero-sized arrays, pushing an invalid pointer to the update remembered set. Likely fixes the cause of #22264. (cherry picked from commit f8988a9c53ae73ff5b9c6008f467a7171e99c61f) - - - - - c0a9329b by Ben Gamari at 2022-12-05T21:46:58-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. (cherry picked from commit cab678fc11d0a3f28fbf2210c4c0bb04eb52997d) - - - - - e6b83196 by Ben Gamari at 2022-12-05T21:47:21-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive (cherry picked from commit 36ca160d0f199a688cf5fbc91d4bb92d2d4ea14e) - - - - - 62031282 by Ben Gamari at 2022-12-05T21:48:03-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. (cherry picked from commit 8b64aff0fa978c762dfae8df235dd2b2a340656a) - - - - - c6f17f12 by Ben Gamari at 2022-12-05T21:49:31-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. (cherry picked from commit dde67d6e32ecff0e400f98213d42ae790babac09) - - - - - 30 changed files: - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToCmm/ArgRep.hs - compiler/GHC/StgToCmm/Env.hs - compiler/GHC/StgToCmm/Expr.hs - + compiler/GHC/StgToCmm/Expr.hs-boot - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Heap.hs - compiler/GHC/StgToCmm/Layout.hs - + compiler/GHC/StgToCmm/Lit.hs - compiler/GHC/StgToCmm/Monad.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToCmm/Prof.hs - compiler/GHC/StgToCmm/Ticky.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b09bd5bdebe32ce864286f19d6c78f7ebc6faf1...c6f17f1218301dc7aed2a3d29f071353ee16fb89 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b09bd5bdebe32ce864286f19d6c78f7ebc6faf1...c6f17f1218301dc7aed2a3d29f071353ee16fb89 You're receiving 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 Dec 6 03:48:03 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 05 Dec 2022 22:48:03 -0500 Subject: [Git][ghc/ghc][wip/tsan/fixes] 9 commits: rts: Encapsulate sched_state Message-ID: <638ebb739c4f8_17512e2b979994121534a@gitlab.mail> Ben Gamari pushed to branch wip/tsan/fixes at Glasgow Haskell Compiler / GHC Commits: e07d269d by Ben Gamari at 2022-12-05T22:47:53-05:00 rts: Encapsulate sched_state - - - - - 36f40b3e by Ben Gamari at 2022-12-05T22:47:53-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - e3aef00c by Ben Gamari at 2022-12-05T22:47:53-05:00 rts: Style fix - - - - - 82d87c8d by Ben Gamari at 2022-12-05T22:47:53-05:00 compiler: Use release store in eager blackholing - - - - - db034924 by Ben Gamari at 2022-12-05T22:47:53-05:00 rts: Fix ordering of makeStableName - - - - - 658e4f4c by Ben Gamari at 2022-12-05T22:47:53-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a809de0c by Ben Gamari at 2022-12-05T22:47:53-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - bc22d7c6 by Ben Gamari at 2022-12-05T22:47:53-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 246bdfa9 by Ben Gamari at 2022-12-05T22:47:53-05:00 rts: Note race with wakeBlockingQueue - - - - - 17 changed files: - compiler/GHC/StgToCmm/Bind.hs - rts/Capability.c - rts/Capability.h - rts/PrimOps.cmm - rts/Schedule.c - rts/Schedule.h - rts/StgMiscClosures.cmm - rts/eventlog/EventLog.c - rts/include/Cmm.h - rts/include/rts/Config.h - rts/posix/Select.c - rts/posix/Signals.c - rts/sm/GC.c - rts/sm/NonMoving.c - rts/win32/AsyncMIO.c - rts/win32/AwaitEvent.c - rts/win32/ConsoleHandler.c Changes: ===================================== compiler/GHC/StgToCmm/Bind.hs ===================================== @@ -703,8 +703,8 @@ emitBlackHoleCode node = do whenUpdRemSetEnabled $ emitUpdRemSetPushThunk node emitStore (cmmOffsetW platform node (fixedHdrSizeW profile)) currentTSOExpr -- See Note [Heap memory barriers] in SMP.h. - emitPrimCall [] MO_WriteBarrier [] - emitStore node (CmmReg (CmmGlobal EagerBlackholeInfo)) + let w = wordWidth platform + emitPrimCall [] (MO_AtomicWrite w MemOrderRelease) [node, CmmReg (CmmGlobal EagerBlackholeInfo)] setupUpdate :: ClosureInfo -> LocalReg -> FCode () -> FCode () -- Nota Bene: this function does not change Node (even if it's a CAF), ===================================== rts/Capability.c ===================================== @@ -45,7 +45,7 @@ uint32_t enabled_capabilities = 0; // Capabilities, because there may be pointers to them in use // (e.g. threads in waitForCapability(), see #8209), so this is // an array of Capability* rather than an array of Capability. -Capability **capabilities = NULL; +Capability *capabilities[MAX_N_CAPABILITIES]; // Holds the Capability which last became free. This is used so that // an in-call has a chance of quickly finding a free Capability. @@ -82,7 +82,7 @@ Capability * rts_unsafeGetMyCapability (void) STATIC_INLINE bool globalWorkToDo (void) { - return RELAXED_LOAD(&sched_state) >= SCHED_INTERRUPTING + return getSchedState() >= SCHED_INTERRUPTING || getRecentActivity() == ACTIVITY_INACTIVE; // need to check for deadlock } #endif @@ -387,6 +387,12 @@ void initCapabilities (void) } #endif + if (RtsFlags.ParFlags.nCapabilities > MAX_N_CAPABILITIES) { + errorBelch("warning: this GHC runtime system only supports up to %d capabilities", + MAX_N_CAPABILITIES); + RtsFlags.ParFlags.nCapabilities = MAX_N_CAPABILITIES; + } + n_capabilities = 0; moreCapabilities(0, RtsFlags.ParFlags.nCapabilities); n_capabilities = RtsFlags.ParFlags.nCapabilities; @@ -394,7 +400,6 @@ void initCapabilities (void) #else /* !THREADED_RTS */ n_capabilities = 1; - capabilities = stgMallocBytes(sizeof(Capability*), "initCapabilities"); capabilities[0] = &MainCapability; initCapability(&MainCapability, 0); @@ -415,8 +420,6 @@ void moreCapabilities (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) { #if defined(THREADED_RTS) - Capability **new_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 @@ -428,30 +431,22 @@ moreCapabilities (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) // 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. - new_capabilities[0] = &MainCapability; + capabilities[0] = &MainCapability; initCapability(&MainCapability, 0); } else { for (uint32_t i = 0; i < to; i++) { - if (i < from) { - new_capabilities[i] = capabilities[i]; - } else { - new_capabilities[i] = stgMallocBytes(sizeof(Capability), + if (i >= from) { + capabilities[i] = stgMallocBytes(sizeof(Capability), "moreCapabilities"); - initCapability(new_capabilities[i], i); + initCapability(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 } @@ -581,7 +576,7 @@ releaseCapability_ (Capability* cap, // is interrupted, we only create a worker task if there // are threads that need to be completed. If the system is // shutting down, we never create a new worker. - if (RELAXED_LOAD(&sched_state) < SCHED_SHUTTING_DOWN || !emptyRunQueue(cap)) { + if (getSchedState() < SCHED_SHUTTING_DOWN || !emptyRunQueue(cap)) { debugTrace(DEBUG_sched, "starting new worker on capability %d", cap->no); startWorkerTask(cap); @@ -1153,7 +1148,7 @@ shutdownCapability (Capability *cap USED_IF_THREADS, // isn't safe, for one thing). for (i = 0; /* i < 50 */; i++) { - ASSERT(sched_state == SCHED_SHUTTING_DOWN); + ASSERT(getSchedState() == SCHED_SHUTTING_DOWN); debugTrace(DEBUG_sched, "shutting down capability %d, attempt %d", cap->no, i); @@ -1285,7 +1280,6 @@ freeCapabilities (void) #else freeCapability(&MainCapability); #endif - stgFree(capabilities); traceCapsetDelete(CAPSET_OSPROCESS_DEFAULT); traceCapsetDelete(CAPSET_CLOCKDOMAIN_DEFAULT); } ===================================== rts/Capability.h ===================================== @@ -261,11 +261,11 @@ INLINE_HEADER void releaseCapability_ (Capability* cap STG_UNUSED, // extern uint32_t enabled_capabilities; // Array of all the capabilities -extern Capability **capabilities; +extern Capability *capabilities[MAX_N_CAPABILITIES]; INLINE_HEADER Capability *getCapability(uint32_t i) { - return RELAXED_LOAD(&capabilities)[i]; + return RELAXED_LOAD(&capabilities[i]); } // ===================================== rts/PrimOps.cmm ===================================== @@ -776,7 +776,7 @@ stg_atomicModifyMutVar2zh ( gcptr mv, gcptr f ) StgThunk_payload(y,0) = z; retry: - x = StgMutVar_var(mv); + x = %relaxed StgMutVar_var(mv); StgThunk_payload(z,1) = x; #if defined(THREADED_RTS) (h) = prim %cmpxchgW(mv + SIZEOF_StgHeader + OFFSET_StgMutVar_var, x, y); @@ -829,7 +829,7 @@ stg_atomicModifyMutVarzuzh ( gcptr mv, gcptr f ) StgThunk_payload(z,0) = f; retry: - x = StgMutVar_var(mv); + x = %relaxed StgMutVar_var(mv); StgThunk_payload(z,1) = x; #if defined(THREADED_RTS) (h) = prim %cmpxchgW(mv + SIZEOF_StgHeader + OFFSET_StgMutVar_var, x, z); @@ -1728,7 +1728,7 @@ stg_takeMVarzh ( P_ mvar /* :: MVar a */ ) // Write barrier before we make the new MVAR_TSO_QUEUE // visible to other cores. // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -1895,7 +1895,7 @@ stg_putMVarzh ( P_ mvar, /* :: MVar a */ SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -2104,7 +2104,7 @@ stg_readMVarzh ( P_ mvar, /* :: MVar a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgTSO__link(CurrentTSO) = q; StgTSO_block_info(CurrentTSO) = mvar; @@ -2237,7 +2237,7 @@ stg_readIOPortzh ( P_ ioport /* :: IOPort a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgMVar_head(ioport) = q; StgTSO__link(CurrentTSO) = q; @@ -2389,7 +2389,8 @@ stg_makeStableNamezh ( P_ obj ) /* Is there already a StableName for this heap object? * stable_name_table is a pointer to an array of snEntry structs. */ - if ( snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) == NULL ) { + sn_obj = %acquire snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + if (sn_obj == NULL) { // At this point we have a snEntry, but it doesn't look as used to the // GC yet because we don't have a StableName object for the sn_obj field // (remember that sn_obj == NULL means the entry is free). So if we call @@ -2406,10 +2407,7 @@ stg_makeStableNamezh ( P_ obj ) // This will make the StableName# object visible to other threads; // be sure that its completely visible to other cores. // See Note [Heap memory barriers] in SMP.h. - prim_write_barrier; - snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; - } else { - sn_obj = snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + %release snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; } return (sn_obj); ===================================== rts/Schedule.c ===================================== @@ -91,7 +91,7 @@ StgWord recent_activity = ACTIVITY_YES; /* if this flag is set as well, give up execution * LOCK: none (changes monotonically) */ -volatile StgWord sched_state = SCHED_RUNNING; +StgWord sched_state = SCHED_RUNNING; /* * This mutex protects most of the global scheduler data in @@ -166,7 +166,6 @@ static void deleteAllThreads (void); static void deleteThread_(StgTSO *tso); #endif - /* --------------------------------------------------------------------------- Main scheduling loop. @@ -254,7 +253,7 @@ schedule (Capability *initialCapability, Task *task) // * We might be left with threads blocked in foreign calls, // we should really attempt to kill these somehow (TODO). - switch (RELAXED_LOAD(&sched_state)) { + switch (getSchedState()) { case SCHED_RUNNING: break; case SCHED_INTERRUPTING: @@ -266,7 +265,7 @@ schedule (Capability *initialCapability, Task *task) // other Capability did the final GC, or we did it above, // either way we can fall through to the SCHED_SHUTTING_DOWN // case now. - ASSERT(RELAXED_LOAD(&sched_state) == SCHED_SHUTTING_DOWN); + ASSERT(getSchedState() == SCHED_SHUTTING_DOWN); // fall through case SCHED_SHUTTING_DOWN: @@ -321,7 +320,7 @@ schedule (Capability *initialCapability, Task *task) */ awaitEvent (cap, emptyRunQueue(cap)); #else - ASSERT(sched_state >= SCHED_INTERRUPTING); + ASSERT(getSchedState() >= SCHED_INTERRUPTING); #endif } #endif @@ -371,7 +370,7 @@ schedule (Capability *initialCapability, Task *task) // killed, kill it now. This sometimes happens when a finalizer // thread is created by the final GC, or a thread previously // in a foreign call returns. - if (RELAXED_LOAD(&sched_state) >= SCHED_INTERRUPTING && + if (getSchedState() >= SCHED_INTERRUPTING && !(t->what_next == ThreadComplete || t->what_next == ThreadKilled)) { deleteThread(t); } @@ -688,7 +687,7 @@ scheduleYield (Capability **pcap, Task *task) if (!shouldYieldCapability(cap,task,false) && (!emptyRunQueue(cap) || !emptyInbox(cap) || - RELAXED_LOAD(&sched_state) >= SCHED_INTERRUPTING)) { + getSchedState() >= SCHED_INTERRUPTING)) { return; } @@ -991,7 +990,7 @@ scheduleDetectDeadlock (Capability **pcap, Task *task) } // either we have threads to run, or we were interrupted: - ASSERT(!emptyRunQueue(cap) || sched_state >= SCHED_INTERRUPTING); + ASSERT(!emptyRunQueue(cap) || getSchedState() >= SCHED_INTERRUPTING); return; } @@ -1343,7 +1342,7 @@ scheduleHandleThreadFinished (Capability *cap, Task *task, StgTSO *t) if (task->incall->ret) { *(task->incall->ret) = NULL; } - if (RELAXED_LOAD(&sched_state) >= SCHED_INTERRUPTING) { + if (getSchedState() >= SCHED_INTERRUPTING) { if (heap_overflow) { task->incall->rstat = HeapExhausted; } else { @@ -1431,7 +1430,7 @@ void stopAllCapabilitiesWith (Capability **pCap, Task *task, SyncType sync_type) acquireAllCapabilities(pCap ? *pCap : NULL, task); - pending_sync = 0; + RELAXED_STORE(&pending_sync, 0); signalCondition(&sync_finished_cond); } #endif @@ -1603,7 +1602,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, // cycle. #endif - if (RELAXED_LOAD(&sched_state) == SCHED_SHUTTING_DOWN) { + if (getSchedState() == SCHED_SHUTTING_DOWN) { // The final GC has already been done, and the system is // shutting down. We'll probably deadlock if we try to GC // now. @@ -1622,7 +1621,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, major_gc = (collect_gen == RtsFlags.GcFlags.generations-1); #if defined(THREADED_RTS) - if (RELAXED_LOAD(&sched_state) < SCHED_INTERRUPTING + if (getSchedState() < SCHED_INTERRUPTING && RtsFlags.ParFlags.parGcEnabled && collect_gen >= RtsFlags.ParFlags.parGcGen && ! oldest_gen->mark) @@ -1715,7 +1714,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, } if (was_syncing && (prev_sync == SYNC_GC_SEQ || prev_sync == SYNC_GC_PAR) && - !(RELAXED_LOAD(&sched_state) == SCHED_INTERRUPTING && force_major)) { + !(getSchedState() == SCHED_INTERRUPTING && force_major)) { // someone else had a pending sync request for a GC, so // let's assume GC has been done and we don't need to GC // again. @@ -1723,7 +1722,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, // need to do the final GC. return; } - if (RELAXED_LOAD(&sched_state) == SCHED_SHUTTING_DOWN) { + if (getSchedState() == SCHED_SHUTTING_DOWN) { // The scheduler might now be shutting down. We tested // this above, but it might have become true since then as // we yielded the capability in requestSync(). @@ -1826,7 +1825,7 @@ delete_threads_and_gc: * threads in the system. * Checking for major_gc ensures that the last GC is major. */ - if (RELAXED_LOAD(&sched_state) == SCHED_INTERRUPTING && major_gc) { + if (getSchedState() == SCHED_INTERRUPTING && major_gc) { deleteAllThreads(); #if defined(THREADED_RTS) // Discard all the sparks from every Capability. Why? @@ -1840,7 +1839,7 @@ delete_threads_and_gc: discardSparksCap(getCapability(i)); } #endif - RELAXED_STORE(&sched_state, SCHED_SHUTTING_DOWN); + setSchedState(SCHED_SHUTTING_DOWN); } /* @@ -1877,7 +1876,7 @@ delete_threads_and_gc: #if defined(THREADED_RTS) // reset pending_sync *before* GC, so that when the GC threads // emerge they don't immediately re-enter the GC. - pending_sync = 0; + RELAXED_STORE(&pending_sync, 0); signalCondition(&sync_finished_cond); GarbageCollect(collect_gen, heap_census, is_overflow_gc, deadlock_detect, gc_type, cap, idle_cap); #else @@ -1885,7 +1884,7 @@ delete_threads_and_gc: #endif // If we're shutting down, don't leave any idle GC work to do. - if (RELAXED_LOAD(&sched_state) == SCHED_SHUTTING_DOWN) { + if (getSchedState() == SCHED_SHUTTING_DOWN) { doIdleGCWork(cap, true /* all of it */); } @@ -1962,7 +1961,7 @@ delete_threads_and_gc: releaseGCThreads(cap, idle_cap); } #endif - if (heap_overflow && RELAXED_LOAD(&sched_state) == SCHED_RUNNING) { + if (heap_overflow && getSchedState() == SCHED_RUNNING) { // GC set the heap_overflow flag. We should throw an exception if we // can, or shut down otherwise. @@ -1974,7 +1973,7 @@ delete_threads_and_gc: // shutdown now. Ultimately we want the main thread to return to // its caller with HeapExhausted, at which point the caller should // call hs_exit(). The first step is to delete all the threads. - RELAXED_STORE(&sched_state, SCHED_INTERRUPTING); + setSchedState(SCHED_INTERRUPTING); goto delete_threads_and_gc; } @@ -2720,7 +2719,7 @@ startWorkerTasks (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) void initScheduler(void) { - sched_state = SCHED_RUNNING; + setSchedState(SCHED_RUNNING); setRecentActivity(ACTIVITY_YES); @@ -2763,8 +2762,8 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) Task *task = newBoundTask(); // If we haven't killed all the threads yet, do it now. - if (RELAXED_LOAD(&sched_state) < SCHED_SHUTTING_DOWN) { - RELAXED_STORE(&sched_state, SCHED_INTERRUPTING); + if (getSchedState() < SCHED_SHUTTING_DOWN) { + setSchedState(SCHED_INTERRUPTING); nonmovingStop(); Capability *cap = task->cap; waitForCapability(&cap,task); @@ -2772,7 +2771,7 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) ASSERT(task->incall->tso == NULL); releaseCapability(cap); } - ASSERT(sched_state == SCHED_SHUTTING_DOWN); + ASSERT(getSchedState() == SCHED_SHUTTING_DOWN); shutdownCapabilities(task, wait_foreign); @@ -2851,8 +2850,8 @@ performMajorGC(void) void interruptStgRts(void) { - ASSERT(sched_state != SCHED_SHUTTING_DOWN); - sched_state = SCHED_INTERRUPTING; + ASSERT(getSchedState() != SCHED_SHUTTING_DOWN); + setSchedState(SCHED_INTERRUPTING); interruptAllCapabilities(); #if defined(THREADED_RTS) wakeUpRts(); ===================================== rts/Schedule.h ===================================== @@ -64,11 +64,23 @@ void releaseAllCapabilities(uint32_t n, Capability *keep_cap, Task *task); /* The state of the scheduler. This is used to control the sequence * of events during shutdown. See Note [shutdown] in Schedule.c. */ -#define SCHED_RUNNING 0 /* running as normal */ -#define SCHED_INTERRUPTING 1 /* before threads are deleted */ -#define SCHED_SHUTTING_DOWN 2 /* final shutdown */ +enum SchedState { + SCHED_RUNNING = 0, /* running as normal */ + SCHED_INTERRUPTING = 1, /* before threads are deleted */ + SCHED_SHUTTING_DOWN = 2, /* final shutdown */ +}; + +extern StgWord sched_state; -extern volatile StgWord sched_state; +INLINE_HEADER void setSchedState(enum SchedState ss) +{ + SEQ_CST_STORE_ALWAYS(&sched_state, (StgWord) ss); +} + +INLINE_HEADER enum SchedState getSchedState(void) +{ + return (enum SchedState) SEQ_CST_LOAD_ALWAYS(&sched_state); +} /* * flag that tracks whether we have done any execution in this time ===================================== rts/StgMiscClosures.cmm ===================================== @@ -540,7 +540,8 @@ retry: return (p); } - info = GET_INFO(p); + // May race with OVERWRITE_INFO in wakeBlockingQueue() + info = %relaxed GET_INFO(p); if (info == stg_IND_info) { // This could happen, if e.g. we got a BLOCKING_QUEUE that has // just been replaced with an IND by another thread in ===================================== rts/eventlog/EventLog.c ===================================== @@ -478,7 +478,7 @@ endEventLogging(void) // // N.B. Don't flush if shutting down: this was done in // finishCapEventLogging and the capabilities have already been freed. - if (sched_state != SCHED_SHUTTING_DOWN) { + if (getSchedState() != SCHED_SHUTTING_DOWN) { flushEventLog(NULL); } ===================================== rts/include/Cmm.h ===================================== @@ -278,8 +278,7 @@ // "used". #define LOAD_INFO_ACQUIRE(ret,x) \ - info = %INFO_PTR(UNTAG(x)); \ - prim_read_barrier; + info = %acquire StgHeader_info(UNTAG(x)); #define UNTAG_IF_PROF(x) UNTAG(x) @@ -289,8 +288,7 @@ if (GETTAG(x) != 0) { \ ret(x); \ } \ - info = %INFO_PTR(x); \ - prim_read_barrier; + info = %acquire StgHeader_info(x); #define UNTAG_IF_PROF(x) (x) /* already untagged */ ===================================== rts/include/rts/Config.h ===================================== @@ -76,3 +76,9 @@ code. #if defined(DEBUG) #define PROF_SPIN #endif + +#if defined(THREADED_RTS) +#define MAX_N_CAPABILITIES 256 +#else +#define MAX_N_CAPABILITIES 1 +#endif ===================================== rts/posix/Select.c ===================================== @@ -362,7 +362,7 @@ awaitEvent(Capability *cap, bool wait) /* we were interrupted, return to the scheduler immediately. */ - if (sched_state >= SCHED_INTERRUPTING) { + if (getSchedState() >= SCHED_INTERRUPTING) { return; /* still hold the lock */ } @@ -459,7 +459,7 @@ awaitEvent(Capability *cap, bool wait) } } - } while (wait && sched_state == SCHED_RUNNING + } while (wait && getSchedState() == SCHED_RUNNING && emptyRunQueue(cap)); } ===================================== rts/posix/Signals.c ===================================== @@ -350,7 +350,7 @@ anyUserHandlers(void) void awaitUserSignals(void) { - while (!signals_pending() && sched_state == SCHED_RUNNING) { + while (!signals_pending() && getSchedState() == SCHED_RUNNING) { pause(); } } @@ -521,7 +521,7 @@ shutdown_handler(int sig STG_UNUSED) // If we're already trying to interrupt the RTS, terminate with // extreme prejudice. So the first ^C tries to exit the program // cleanly, and the second one just kills it. - if (sched_state >= SCHED_INTERRUPTING) { + if (getSchedState() >= SCHED_INTERRUPTING) { stg_exit(EXIT_INTERRUPTED); } else { interruptStgRts(); ===================================== rts/sm/GC.c ===================================== @@ -833,12 +833,9 @@ GarbageCollect (uint32_t collect_gen, live_blocks += genLiveBlocks(gen); // add in the partial blocks in the gen_workspaces - { - uint32_t i; - for (i = 0; i < getNumCapabilities(); i++) { - live_words += gcThreadLiveWords(i, gen->no); - live_blocks += gcThreadLiveBlocks(i, gen->no); - } + for (uint32_t i = 0; i < getNumCapabilities(); i++) { + live_words += gcThreadLiveWords(i, gen->no); + live_blocks += gcThreadLiveBlocks(i, gen->no); } } // for all generations ===================================== rts/sm/NonMoving.c ===================================== @@ -921,7 +921,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) #if defined(THREADED_RTS) // We can't start a new collection until the old one has finished // We also don't run in final GC - if (concurrent_coll_running || sched_state > SCHED_RUNNING) { + if (concurrent_coll_running || getSchedState() > SCHED_RUNNING) { return; } #endif @@ -994,7 +994,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) // again for the sync if we let it go, because it'll immediately start doing // a major GC, because that's what we do when exiting scheduler (see // exitScheduler()). - if (sched_state == SCHED_RUNNING) { + if (getSchedState() == SCHED_RUNNING) { concurrent_coll_running = true; nonmoving_write_barrier_enabled = true; debugTrace(DEBUG_nonmoving_gc, "Starting concurrent mark thread"); @@ -1086,7 +1086,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * Task *task = newBoundTask(); // If at this point if we've decided to exit then just return - if (sched_state > SCHED_RUNNING) { + if (getSchedState() > SCHED_RUNNING) { // Note that we break our invariants here and leave segments in // nonmovingHeap.sweep_list, don't free nonmoving_large_objects etc. // However because we won't be running mark-sweep in the final GC this ===================================== rts/win32/AsyncMIO.c ===================================== @@ -247,7 +247,7 @@ start: if (completed_hw == 0) { // empty table, drop lock and wait OS_RELEASE_LOCK(&queue_lock); - if ( wait && sched_state == SCHED_RUNNING ) { + if ( wait && getSchedState() == SCHED_RUNNING ) { DWORD dwRes = WaitForMultipleObjects(2, wait_handles, FALSE, INFINITE); switch (dwRes) { ===================================== rts/win32/AwaitEvent.c ===================================== @@ -56,7 +56,7 @@ awaitEvent(Capability *cap, bool wait) // - the run-queue is now non- empty } while (wait - && sched_state == SCHED_RUNNING + && getSchedState() == SCHED_RUNNING && emptyRunQueue(cap) ); } ===================================== rts/win32/ConsoleHandler.c ===================================== @@ -91,7 +91,7 @@ static BOOL WINAPI shutdown_handler(DWORD dwCtrlType) // If we're already trying to interrupt the RTS, terminate with // extreme prejudice. So the first ^C tries to exit the program // cleanly, and the second one just kills it. - if (sched_state >= SCHED_INTERRUPTING) { + if (getSchedState() >= SCHED_INTERRUPTING) { stg_exit(EXIT_INTERRUPTED); } else { interruptStgRts(); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2cddf0c78ddfa1c19918b7c315c3158b9282de6d...246bdfa9cb8c91b875139cb6bb26b62a70a2a29c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2cddf0c78ddfa1c19918b7c315c3158b9282de6d...246bdfa9cb8c91b875139cb6bb26b62a70a2a29c You're receiving 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 Dec 6 09:30:33 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Tue, 06 Dec 2022 04:30:33 -0500 Subject: [Git][ghc/ghc][wip/int-index/emb-type] 2 commits: VDQ: accept test suite changes Message-ID: <638f0bb919070_17512e2fdaf37012392c9@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/emb-type at Glasgow Haskell Compiler / GHC Commits: 062bf0c9 by Vladislav Zavialov at 2022-12-06T12:24:02+03:00 VDQ: accept test suite changes Not all of these are quite right: in some contexts, the suggestion to enable RequiredTypeArguments is incorrect, as enabling the extension wouldn't make the program accepted. - - - - - 108c316a by Vladislav Zavialov at 2022-12-06T12:30:23+03:00 VDQ: mark T18863a broken - - - - - 15 changed files: - testsuite/tests/dependent/should_fail/T15859.stderr - testsuite/tests/dependent/should_fail/T16326_Fail1.stderr - testsuite/tests/dependent/should_fail/T16326_Fail10.stderr - testsuite/tests/dependent/should_fail/T16326_Fail11.stderr - testsuite/tests/dependent/should_fail/T16326_Fail12.stderr - testsuite/tests/dependent/should_fail/T16326_Fail2.stderr - testsuite/tests/dependent/should_fail/T16326_Fail3.stderr - testsuite/tests/dependent/should_fail/T16326_Fail4.stderr - testsuite/tests/dependent/should_fail/T16326_Fail5.stderr - testsuite/tests/dependent/should_fail/T16326_Fail6.stderr - testsuite/tests/dependent/should_fail/T16326_Fail8.stderr - testsuite/tests/dependent/should_fail/T16326_Fail9.stderr - testsuite/tests/dependent/should_fail/T17687.stderr - testsuite/tests/dependent/should_fail/T18271.stderr - testsuite/tests/saks/should_fail/all.T Changes: ===================================== testsuite/tests/dependent/should_fail/T15859.stderr ===================================== @@ -2,8 +2,8 @@ T15859.hs:9:19: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall k -> k -> * - (GHC does not yet support this) • In an expression type signature: forall k -> k -> Type In the expression: (undefined :: forall k -> k -> Type) @Int In an equation for ‘a’: a = (undefined :: forall k -> k -> Type) @Int + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail1.stderr ===================================== @@ -2,12 +2,12 @@ T16326_Fail1.hs:5:8: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall a -> a -> a - (GHC does not yet support this) • In the type signature: id1 :: forall a -> a -> a + Suggested fix: Perhaps you intended to use RequiredTypeArguments T16326_Fail1.hs:9:8: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall a -> a -> a - (GHC does not yet support this) • In the expansion of type synonym ‘Foo’ In the type signature: id2 :: Foo + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail10.stderr ===================================== @@ -2,6 +2,6 @@ T16326_Fail10.hs:12:18: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall a -> a -> a - (GHC does not yet support this) • In the type signature for ‘x’: forall a -> a -> a When checking the rewrite rule "flurmp" + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail11.stderr ===================================== @@ -2,6 +2,6 @@ T16326_Fail11.hs:9:11: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall x -> x - (GHC does not yet support this) • When checking the class method: m :: forall a b. C a => b -> a In the class declaration for ‘C’ + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail12.stderr ===================================== @@ -2,7 +2,7 @@ T16326_Fail12.hs:6:1: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall a -> Show a - (GHC does not yet support this) • In the context: forall a -> Show a While checking the super-classes of class ‘C’ In the class declaration for ‘C’ + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail2.stderr ===================================== @@ -2,7 +2,7 @@ T16326_Fail2.hs:6:37: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall a -> a -> IO () - (GHC does not yet support this) • In the type signature: blah :: forall a -> a -> IO () When checking declaration: foreign import ccall safe "blah" blah :: forall a -> a -> IO () + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail3.stderr ===================================== @@ -2,4 +2,4 @@ T16326_Fail3.hs:6:1: error: [GHC-51580] Illegal visible, dependent quantification in the type of a term: forall a -> [a] - (GHC does not yet support this) + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail4.stderr ===================================== @@ -2,10 +2,10 @@ T16326_Fail4.hs:6:30: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall a1 -> Maybe a1 -> Maybe a1 -> Maybe a1 - (GHC does not yet support this) • In an expression type signature: forall a -> Maybe a -> Maybe a -> Maybe a In the first argument of ‘zipWith’, namely ‘((<>) :: forall a -> Maybe a -> Maybe a -> Maybe a)’ In the expression: zipWith ((<>) :: forall a -> Maybe a -> Maybe a -> Maybe a) xs ys + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail5.stderr ===================================== @@ -2,8 +2,8 @@ T16326_Fail5.hs:7:20: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall a1 -> Maybe a1 - (GHC does not yet support this) • In a pattern type signature: forall a -> Maybe a In the pattern: Nothing :: forall a -> Maybe a In an equation for ‘isJust’: isJust (Nothing :: forall a -> Maybe a) = False + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail6.stderr ===================================== @@ -1,5 +1,5 @@ T16326_Fail6.hs:9:12: error: [GHC-51580] - Illegal visible, dependent quantification in the type of a term - (GHC does not yet support this) - In the definition of data constructor ‘MkFoo’ + • Illegal visible, dependent quantification in the type of a term + • In the definition of data constructor ‘MkFoo’ + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail8.stderr ===================================== @@ -1,5 +1,5 @@ T16326_Fail8.hs:7:10: error: [GHC-51580] - Illegal visible, dependent quantification in the type of a term - (GHC does not yet support this) - In an instance declaration + • Illegal visible, dependent quantification in the type of a term + • In an instance declaration + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T16326_Fail9.stderr ===================================== @@ -2,7 +2,7 @@ T16326_Fail9.hs:11:5: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall a -> a -> a - (GHC does not yet support this) • In the expression: lol @(forall a -> a -> a) undefined True In an equation for ‘t’: t = lol @(forall a -> a -> a) undefined True + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T17687.stderr ===================================== @@ -2,5 +2,5 @@ T17687.hs:5:6: error: [GHC-51580] • Illegal visible, dependent quantification in the type of a term: forall a -> a -> a - (GHC does not yet support this) • In the type signature: x :: forall a -> a -> a + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/dependent/should_fail/T18271.stderr ===================================== @@ -1,5 +1,5 @@ T18271.hs:7:19: error: [GHC-51580] - Illegal visible, dependent quantification in the type of a term - (GHC does not yet support this) - In a deriving declaration + • Illegal visible, dependent quantification in the type of a term + • In a deriving declaration + Suggested fix: Perhaps you intended to use RequiredTypeArguments ===================================== testsuite/tests/saks/should_fail/all.T ===================================== @@ -32,6 +32,6 @@ 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('T18863a', expect_broken(22326), compile_fail, ['']) # TODO (int-index): ticket for specificity subsumption test('T18863b', normal, compile_fail, ['']) test('T20916', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c0bd4ddea3d95b99354ff46b58be0eaa52ba5120...108c316ac365a61a89912d2b0eb77a7a59cdea13 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c0bd4ddea3d95b99354ff46b58be0eaa52ba5120...108c316ac365a61a89912d2b0eb77a7a59cdea13 You're receiving 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 Dec 6 11:25:58 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 06 Dec 2022 06:25:58 -0500 Subject: [Git][ghc/ghc][wip/fix-multi-repl] 313 commits: Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) Message-ID: <638f26c654a62_17512e7d443b3012538c0@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 1b83041c by Matthew Pickering at 2022-12-06T11:24:34+00:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - baddc452 by Matthew Pickering at 2022-12-06T11:24:59+00:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - f9e3f960 by Matthew Pickering at 2022-12-06T11:24:59+00:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 6d050602 by Matthew Pickering at 2022-12-06T11:24:59+00:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - d58e3bc7 by Matthew Pickering at 2022-12-06T11:25:00+00:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - 18 changed files: - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - CODEOWNERS - README.md - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3150b008269e038d59049de63caaa74610506605...d58e3bc7d0922eb3afe1564c3b54c6401288fdca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3150b008269e038d59049de63caaa74610506605...d58e3bc7d0922eb3afe1564c3b54c6401288fdca You're receiving 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 Dec 6 11:28:15 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 06 Dec 2022 06:28:15 -0500 Subject: [Git][ghc/ghc][wip/T18964] Make `drop` and `dropWhile` fuse (#18964) Message-ID: <638f274f19c50_17512e7dc0547c12559c7@gitlab.mail> Sebastian Graf pushed to branch wip/T18964 at Glasgow Haskell Compiler / GHC Commits: cdd9d55f by Sebastian Graf at 2022-12-06T12:28:05+01:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 4 changed files: - libraries/base/GHC/List.hs - + testsuite/tests/perf/should_run/T18964.hs - + testsuite/tests/perf/should_run/T18964.stdout - testsuite/tests/perf/should_run/all.T Changes: ===================================== libraries/base/GHC/List.hs ===================================== @@ -517,9 +517,9 @@ scanl' = scanlGo' -- See Note [scanl rewrite rules] {-# RULES "scanl'" [~1] forall f a bs . scanl' f a bs = - build (\c n -> a `c` foldr (scanlFB' f c) (flipSeqScanl' n) bs a) + build (\c n -> a `c` foldr (scanlFB' f c) (flipSeq n) bs a) "scanlList'" [1] forall f a bs . - foldr (scanlFB' f (:)) (flipSeqScanl' []) bs a = tail (scanl' f a bs) + foldr (scanlFB' f (:)) (flipSeq []) bs a = tail (scanl' f a bs) #-} {-# INLINE [0] scanlFB' #-} -- See Note [Inline FB functions] @@ -527,10 +527,6 @@ scanlFB' :: (b -> a -> b) -> (b -> c -> c) -> a -> (b -> c) -> b -> c scanlFB' f c = \b g -> oneShot (\x -> let !b' = f x b in b' `c` g b') -- See Note [Left folds via right fold] -{-# INLINE [0] flipSeqScanl' #-} -flipSeqScanl' :: a -> b -> a -flipSeqScanl' a !_b = a - {- Note [scanl rewrite rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -890,12 +886,23 @@ takeWhileFB p c n = \x r -> if p x then x `c` r else n -- [] -- >>> dropWhile (< 0) [1,2,3] -- [1,2,3] +{-# NOINLINE [1] dropWhile #-} dropWhile :: (a -> Bool) -> [a] -> [a] dropWhile _ [] = [] dropWhile p xs@(x:xs') | p x = dropWhile p xs' | otherwise = xs +{-# INLINE [0] dropWhileFB #-} -- See Note [Inline FB functions] +dropWhileFB :: (a -> Bool) -> (a -> b -> b) -> b -> a -> (Bool -> b) -> Bool -> b +dropWhileFB p c _n x xs = \drp -> if drp && p x then xs True else x `c` xs False + +{-# RULES +"dropWhile" [~1] forall p xs. dropWhile p xs = + build (\c n -> foldr (dropWhileFB p c n) (flipSeq n) xs True) +"dropWhileList" [1] forall p xs. foldr (dropWhileFB p (:) []) (flipSeq []) xs True = dropWhile p xs + #-} + -- | 'take' @n@, applied to a list @xs@, returns the prefix of @xs@ -- of length @n@, or @xs@ itself if @n >= 'length' xs at . -- @@ -932,7 +939,7 @@ take n xs | 0 < n = unsafeTake n xs -- A version of take that takes the whole list if it's given an argument less -- than 1. -{-# NOINLINE [1] unsafeTake #-} +{-# NOINLINE [0] unsafeTake #-} -- See Note [Inline FB functions] unsafeTake :: Int -> [a] -> [a] unsafeTake !_ [] = [] unsafeTake 1 (x: _) = [x] @@ -941,20 +948,18 @@ unsafeTake m (x:xs) = x : unsafeTake (m - 1) xs {-# RULES "take" [~1] forall n xs . take n xs = build (\c nil -> if 0 < n - then foldr (takeFB c nil) (flipSeqTake nil) xs n + then foldr (takeFB c nil) (flipSeq nil) xs n else nil) -"unsafeTakeList" [1] forall n xs . foldr (takeFB (:) []) (flipSeqTake []) xs n +"unsafeTakeList" [1] forall n xs . foldr (takeFB (:) []) (flipSeq []) xs n = unsafeTake n xs #-} -{-# INLINE [0] flipSeqTake #-} --- Just flip seq, specialized to Int, but not inlined too early. --- It's important to force the numeric argument here, even though --- it's not used. Otherwise, take n [] doesn't force n. This is --- bad for strictness analysis and unboxing, and leads to increased --- allocation in T7257. -flipSeqTake :: a -> Int -> a -flipSeqTake x !_n = x +{-# INLINE [0] flipSeq #-} +-- Just flip seq, but not inlined too early. +-- It's important to force the argument here, even though it's not used. +-- Otherwise, take n [] can't unbox n, leading to increased allocation in T7257. +flipSeq :: a -> b -> a +flipSeq x !_n = x {-# INLINE [0] takeFB #-} -- See Note [Inline FB functions] takeFB :: (a -> b -> b) -> b -> a -> (Int -> b) -> Int -> b @@ -993,17 +998,31 @@ drop n xs | n <= 0 = xs drop _ [] = [] drop n (_:xs) = drop (n-1) xs #else /* hack away */ -{-# INLINE drop #-} +{-# INLINE[1] drop #-} -- Why [1]? See justification on take! => RULES drop n ls | n <= 0 = ls | otherwise = unsafeDrop n ls - where - -- A version of drop that drops the whole list if given an argument - -- less than 1 - unsafeDrop :: Int -> [a] -> [a] - unsafeDrop !_ [] = [] - unsafeDrop 1 (_:xs) = xs - unsafeDrop m (_:xs) = unsafeDrop (m - 1) xs + +-- A version of drop that drops the whole list if given an argument +-- less than 1 +{-# NOINLINE [0] unsafeDrop #-} -- See Note [Inline FB functions] +unsafeDrop :: Int -> [a] -> [a] +unsafeDrop !_ [] = [] +unsafeDrop 1 (_:xs) = xs +unsafeDrop m (_:xs) = unsafeDrop (m - 1) xs + +{-# RULES +"drop" [~1] forall n xs . drop n xs = + build (\c nil -> if n <= 0 + then foldr c nil xs + else foldr (dropFB c nil) (flipSeq nil) xs n) +"unsafeDropList" [1] forall n xs . foldr (dropFB (:) []) (flipSeq []) xs n + = unsafeDrop n xs + #-} + +{-# INLINE [0] dropFB #-} -- See Note [Inline FB functions] +dropFB :: (a -> b -> b) -> b -> a -> (Int -> b) -> Int -> b +dropFB c _n x xs = \ m -> if m <= 0 then x `c` xs m else xs (m-1) #endif -- | 'splitAt' @n xs@ returns a tuple where first element is @xs@ prefix of ===================================== testsuite/tests/perf/should_run/T18964.hs ===================================== @@ -0,0 +1,14 @@ +import GHC.Exts + +main :: IO () +main = do + -- drop should fuse away and the program should consume O(1) space + -- If fusion fails, this allocates about 640MB. + print $ sum $ drop 10 [0..10000000::Int] + -- Here, drop can't fuse. This asserts that we don't regress in allocations in that case either + -- If we don't do a good job here, we'll see more than 6.4MB of allocs. + print $ lazy $ sum $ lazy $ drop 10 $ lazy [0..100000::Int] + + -- and once more with dropWhile + print $ sum $ dropWhile (< 10) [0..10000000::Int] + print $ lazy $ sum $ lazy $ dropWhile (< 10) $ lazy [0..100000::Int] ===================================== testsuite/tests/perf/should_run/T18964.stdout ===================================== @@ -0,0 +1,4 @@ +50000004999955 +5000049955 +50000004999955 +5000049955 ===================================== testsuite/tests/perf/should_run/all.T ===================================== @@ -408,3 +408,5 @@ test('T21839r', only_ways(['normal'])], compile_and_run, ['-O']) + +test('T18964', [collect_stats('bytes allocated', 1), only_ways(['normal'])], compile_and_run, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdd9d55fa469252ccd550580b422ecbfb5be6ecc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cdd9d55fa469252ccd550580b422ecbfb5be6ecc You're receiving 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 Dec 6 11:44:08 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 06 Dec 2022 06:44:08 -0500 Subject: [Git][ghc/ghc] Pushed new branch ghc-9.6 Message-ID: <638f2b08309e6_17512e7eb4863c127321c@gitlab.mail> Ben Gamari pushed new branch ghc-9.6 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.6 You're receiving 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 Dec 6 11:56:11 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 06 Dec 2022 06:56:11 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22563 Message-ID: <638f2ddb602d9_17512e240afea012835cf@gitlab.mail> Ben Gamari pushed new branch wip/T22563 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22563 You're receiving 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 Dec 6 12:05:19 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 06 Dec 2022 07:05:19 -0500 Subject: [Git][ghc/ghc][wip/par-simpl] 119 commits: Fire RULES in the Specialiser Message-ID: <638f2fff83c84_17512e7d443b30129204@gitlab.mail> Matthew Pickering pushed to branch wip/par-simpl at Glasgow Haskell Compiler / GHC Commits: f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - 3b7adbfc by Matthew Pickering at 2022-11-29T12:00:38+00:00 Wip: parr - - - - - ba177155 by Matthew Pickering at 2022-12-06T12:04:52+00:00 wip - - - - - 8fedd354 by Matthew Pickering at 2022-12-06T12:04:52+00:00 Perf experiments @simonpj I have pushed a branch which has access to four configurations. Could you please have a look and see if you think there is another approach which doesn't compromise performance for the serial case? The test I ran was `T9233`. | config | allocs | | ------ | ------ | | normal | 718,212,096 | | fresh unique in subst_id_bndr | 814,082,368 | | fresh uniques after floating (substExpr) | 838,098,280 | | fresh uniques after floating (insert let) | 929,485,912 | The two relevant places to look are in `subst_id_bndr` and `simplLazyBind` where there are calls to `uniqifyFloats_lazy` and `uniqifyFloats_strict`. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - 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/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/ProcPoint.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bea1328fe8202fb87c6702da3e07cfb3e13195f7...8fedd354e6a34649f6504f2641a5856720ac4415 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bea1328fe8202fb87c6702da3e07cfb3e13195f7...8fedd354e6a34649f6504f2641a5856720ac4415 You're receiving 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 Dec 6 12:25:42 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 06 Dec 2022 07:25:42 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Add BufSpan to EpaLocation (#22319, #22558) Message-ID: <638f34c6d5284_17512e7d443b301318746@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 7bfd32c4 by sheaf at 2022-12-06T07:25:14-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 63f9a9ab by mrkun at 2022-12-06T07:25:24-05:00 Push DynFlags out of runInstallNameTool - - - - - 35795f77 by mrkun at 2022-12-06T07:25:24-05:00 Push DynFlags out of askOtool - - - - - 5611fd6e by mrkun at 2022-12-06T07:25:24-05:00 Push DynFlags out of runInjectRPaths - - - - - 3610891d by mrkun at 2022-12-06T07:25:24-05:00 Push DynFlags out of Linker.MacOS - - - - - 24 changed files: - + compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - + compiler/GHC/Linker/Config.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Types/SrcLoc.hs - compiler/ghc.cabal.in - hadrian/doc/user-settings.md - hadrian/src/Flavour/Type.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Flavours/Development.hs - hadrian/src/Settings/Packages.hs - utils/check-exact/ExactPrint.hs - utils/check-exact/Parsers.hs - utils/check-exact/Transform.hs - utils/check-exact/Utils.hs Changes: ===================================== compiler/GHC/Driver/Config/Linker.hs ===================================== @@ -0,0 +1,13 @@ +module GHC.Driver.Config.Linker + ( initFrameworkOpts + ) where + +import GHC.Linker.Config + +import GHC.Driver.Session + +initFrameworkOpts :: DynFlags -> FrameworkOpts +initFrameworkOpts dflags = FrameworkOpts + { foFrameworkPaths = frameworkPaths dflags + , foCmdlineFrameworks = cmdlineFrameworks dflags + } ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -130,7 +130,7 @@ module GHC.Driver.Session ( versionedAppDir, versionedFilePath, extraGccViaCFlags, globalPackageDatabasePath, pgm_L, pgm_P, pgm_F, pgm_c, pgm_cxx, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, - pgm_windres, pgm_ar, pgm_otool, pgm_install_name_tool, + pgm_windres, pgm_ar, 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, @@ -833,10 +833,6 @@ 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]) ===================================== compiler/GHC/Hs/Dump.hs ===================================== @@ -144,7 +144,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 _ -> parens $ text "SourceText" <+> text "blanked" epaAnchor :: EpaLocation -> SDoc - epaAnchor (EpaSpan r) = parens $ text "EpaSpan" <+> realSrcSpan r + epaAnchor (EpaSpan r _) = parens $ text "EpaSpan" <+> realSrcSpan r epaAnchor (EpaDelta d cs) = case ba of NoBlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> showAstData' cs BlankEpAnnotations -> parens $ text "EpaDelta" <+> deltaPos d <+> text "blanked" ===================================== compiler/GHC/Linker/Config.hs ===================================== @@ -0,0 +1,13 @@ +-- | Linker configuration + +module GHC.Linker.Config + ( FrameworkOpts(..) + ) where + +import GHC.Prelude + +-- used on darwin only +data FrameworkOpts = FrameworkOpts + { foFrameworkPaths :: [String] + , foCmdlineFrameworks :: [String] + } ===================================== compiler/GHC/Linker/Dynamic.hs ===================================== @@ -12,6 +12,7 @@ import GHC.Prelude import GHC.Platform import GHC.Platform.Ways +import GHC.Driver.Config.Linker import GHC.Driver.Session import GHC.Unit.Env @@ -23,6 +24,7 @@ import GHC.SysTools.Tasks import GHC.Utils.Logger import GHC.Utils.TmpFs +import Control.Monad (when) import System.FilePath linkDynLib :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [String] -> [UnitId] -> IO () @@ -94,7 +96,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- frameworks pkg_framework_opts <- getUnitFrameworkOpts unit_env (map unitId pkgs) - let framework_opts = getFrameworkOpts dflags platform + let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform case os of OSMinGW32 -> do @@ -193,7 +195,9 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- See Note [Dynamic linking on macOS] ++ [ Option "-Wl,-dead_strip_dylibs", Option "-Wl,-headerpad,8000" ] ) - runInjectRPaths logger dflags pkg_lib_paths output_fn + -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004 + when (gopt Opt_RPath dflags) $ + runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn _ -> do ------------------------------------------------------------------- -- Making a DSO ===================================== compiler/GHC/Linker/MacOS.hs ===================================== @@ -9,12 +9,15 @@ where import GHC.Prelude import GHC.Platform +import GHC.Linker.Config + import GHC.Driver.Session import GHC.Unit.Types import GHC.Unit.State import GHC.Unit.Env +import GHC.Settings import GHC.SysTools.Tasks import GHC.Runtime.Interpreter @@ -46,15 +49,13 @@ import Text.ParserCombinators.ReadP as Parser -- dynamic library through @-add_rpath at . -- -- See Note [Dynamic linking on macOS] -runInjectRPaths :: Logger -> DynFlags -> [FilePath] -> FilePath -> IO () --- Make sure to honour -fno-use-rpaths if set on darwin as well see #20004 -runInjectRPaths _ dflags _ _ | not (gopt Opt_RPath dflags) = return () -runInjectRPaths logger dflags lib_paths dylib = do - info <- lines <$> askOtool logger dflags Nothing [Option "-L", Option dylib] +runInjectRPaths :: Logger -> ToolSettings -> [FilePath] -> FilePath -> IO () +runInjectRPaths logger toolSettings lib_paths dylib = do + info <- lines <$> askOtool logger toolSettings 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 <- lines <$> askOtool logger dflags Nothing [Option "-l", Option dylib] + info <- lines <$> askOtool logger toolSettings Nothing [Option "-l", Option dylib] let paths = mapMaybe get_rpath info lib_paths' = [ p | p <- lib_paths, not (p `elem` paths) ] -- only find those rpaths, that aren't already in the library. @@ -62,7 +63,7 @@ runInjectRPaths logger dflags lib_paths dylib = do -- inject the rpaths case rpaths of [] -> return () - _ -> runInstallNameTool logger dflags $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] + _ -> runInstallNameTool logger toolSettings $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] get_rpath :: String -> Maybe FilePath get_rpath l = case readP_to_S rpath_parser l of @@ -96,15 +97,15 @@ getUnitFrameworkOpts unit_env dep_packages | otherwise = return [] -getFrameworkOpts :: DynFlags -> Platform -> [String] -getFrameworkOpts dflags platform +getFrameworkOpts :: FrameworkOpts -> Platform -> [String] +getFrameworkOpts fwOpts platform | platformUsesFrameworks platform = framework_path_opts ++ framework_opts | otherwise = [] where - framework_paths = frameworkPaths dflags + framework_paths = foFrameworkPaths fwOpts framework_path_opts = map ("-F" ++) framework_paths - frameworks = cmdlineFrameworks dflags + frameworks = foCmdlineFrameworks fwOpts -- reverse because they're added in reverse order from the cmd line: framework_opts = concat [ ["-framework", fw] | fw <- reverse frameworks ] ===================================== compiler/GHC/Linker/Static.hs ===================================== @@ -29,6 +29,7 @@ import GHC.Linker.ExtraObj import GHC.Linker.Windows import GHC.Linker.Static.Utils +import GHC.Driver.Config.Linker import GHC.Driver.Session import System.FilePath @@ -171,7 +172,7 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do -- frameworks pkg_framework_opts <- getUnitFrameworkOpts unit_env dep_units - let framework_opts = getFrameworkOpts dflags platform + let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform -- probably _stub.o files let extra_ld_inputs = ldInputs dflags @@ -183,7 +184,9 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do let link dflags args | platformOS platform == OSDarwin = do GHC.SysTools.runLink logger tmpfs dflags args - GHC.Linker.MacOS.runInjectRPaths logger dflags pkg_lib_paths output_fn + -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004 + when (gopt Opt_RPath dflags) $ + GHC.Linker.MacOS.runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn | otherwise = GHC.SysTools.runLink logger tmpfs dflags args ===================================== compiler/GHC/Parser.y ===================================== @@ -3058,34 +3058,34 @@ tup_exprs :: { forall b. DisambECP b => PV (SumOrTuple b) } : texp commas_tup_tail { unECP $1 >>= \ $1 -> $2 >>= \ $2 -> - do { t <- amsA $1 [AddCommaAnn (EpaSpan $ rs $ fst $2)] + do { t <- amsA $1 [AddCommaAnn (srcSpan2e $ fst $2)] ; return (Tuple (Right t : snd $2)) } } | commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) (EpaSpan $ rs ll) emptyComments))) (fst $1) } + do { let {cos = map (\ll -> (Left (EpAnn (anc $ rs ll) (srcSpan2e ll) emptyComments))) (fst $1) } ; return (Tuple (cos ++ $2)) } } | texp bars { unECP $1 >>= \ $1 -> return $ - (Sum 1 (snd $2 + 1) $1 [] (map (EpaSpan . realSrcSpan) $ fst $2)) } + (Sum 1 (snd $2 + 1) $1 [] (map srcSpan2e $ fst $2)) } | bars texp bars0 { unECP $2 >>= \ $2 -> return $ (Sum (snd $1 + 1) (snd $1 + snd $3 + 1) $2 - (map (EpaSpan . realSrcSpan) $ fst $1) - (map (EpaSpan . realSrcSpan) $ fst $3)) } + (map srcSpan2e $ fst $1) + (map srcSpan2e $ fst $3)) } -- Always starts with commas; always follows an expr commas_tup_tail :: { forall b. DisambECP b => PV (SrcSpan,[Either (EpAnn EpaLocation) (LocatedA b)]) } commas_tup_tail : commas tup_tail { $2 >>= \ $2 -> - do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) (EpaSpan $ rs l) emptyComments))) (tail $ fst $1) } + do { let {cos = map (\l -> (Left (EpAnn (anc $ rs l) (srcSpan2e l) emptyComments))) (tail $ fst $1) } ; return ((head $ fst $1, cos ++ $2)) } } -- Always follows a comma tup_tail :: { forall b. DisambECP b => PV [Either (EpAnn EpaLocation) (LocatedA b)] } : texp commas_tup_tail { unECP $1 >>= \ $1 -> $2 >>= \ $2 -> - do { t <- amsA $1 [AddCommaAnn (EpaSpan $ rs $ fst $2)] + do { t <- amsA $1 [AddCommaAnn (srcSpan2e $ fst $2)] ; return (Right t : snd $2) } } | texp { unECP $1 >>= \ $1 -> return [Right $1] } @@ -3564,10 +3564,10 @@ qcon_list : qcon { sL1N $1 [$1] } sysdcon_nolist :: { LocatedN DataCon } -- Wired in data constructors : '(' ')' {% amsrn (sLL $1 $> unitDataCon) (NameAnnOnly NameParens (glAA $1) (glAA $2) []) } | '(' commas ')' {% amsrn (sLL $1 $> $ tupleDataCon Boxed (snd $2 + 1)) - (NameAnnCommas NameParens (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParens (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' '#)' {% amsrn (sLL $1 $> $ unboxedUnitDataCon) (NameAnnOnly NameParensHash (glAA $1) (glAA $2) []) } | '(#' commas '#)' {% amsrn (sLL $1 $> $ tupleDataCon Unboxed (snd $2 + 1)) - (NameAnnCommas NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } -- See Note [Empty lists] in GHC.Hs.Expr sysdcon :: { LocatedN DataCon } @@ -3601,12 +3601,12 @@ ntgtycon :: { LocatedN RdrName } -- A "general" qualified tycon, excluding unit : oqtycon { $1 } | '(' commas ')' {% amsrn (sLL $1 $> $ getRdrName (tupleTyCon Boxed (snd $2 + 1))) - (NameAnnCommas NameParens (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParens (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' commas '#)' {% amsrn (sLL $1 $> $ getRdrName (tupleTyCon Unboxed (snd $2 + 1))) - (NameAnnCommas NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnCommas NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(#' bars '#)' {% amsrn (sLL $1 $> $ getRdrName (sumTyCon (snd $2 + 1))) - (NameAnnBars NameParensHash (glAA $1) (map (EpaSpan . realSrcSpan) (fst $2)) (glAA $3) []) } + (NameAnnBars NameParensHash (glAA $1) (map srcSpan2e (fst $2)) (glAA $3) []) } | '(' '->' ')' {% amsrn (sLL $1 $> $ getRdrName unrestrictedFunTyCon) (NameAnn NameParens (glAA $1) (glAA $2) (glAA $3) []) } | '[' ']' {% amsrn (sLL $1 $> $ listTyCon_RDR) @@ -4210,27 +4210,27 @@ in GHC.Parser.Annotation -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself mj :: AnnKeywordId -> Located e -> AddEpAnn -mj a l = AddEpAnn a (EpaSpan $ rs $ gl l) +mj a l = AddEpAnn a (srcSpan2e $ gl l) mjN :: AnnKeywordId -> LocatedN e -> AddEpAnn -mjN a l = AddEpAnn a (EpaSpan $ rs $ glN l) +mjN a l = AddEpAnn a (srcSpan2e $ glN l) -- |Construct an AddEpAnn from the annotation keyword and the location -- of the keyword itself, provided the span is not zero width mz :: AnnKeywordId -> Located e -> [AddEpAnn] -mz a l = if isZeroWidthSpan (gl l) then [] else [AddEpAnn a (EpaSpan $ rs $ gl l)] +mz a l = if isZeroWidthSpan (gl l) then [] else [AddEpAnn a (srcSpan2e $ gl l)] msemi :: Located e -> [TrailingAnn] -msemi l = if isZeroWidthSpan (gl l) then [] else [AddSemiAnn (EpaSpan $ rs $ gl l)] +msemi l = if isZeroWidthSpan (gl l) then [] else [AddSemiAnn (srcSpan2e $ gl l)] msemim :: Located e -> Maybe EpaLocation -msemim l = if isZeroWidthSpan (gl l) then Nothing else Just (EpaSpan $ rs $ gl l) +msemim l = if isZeroWidthSpan (gl l) then Nothing else Just (srcSpan2e $ gl l) -- |Construct an AddEpAnn from the annotation keyword and the Located Token. If -- the token has a unicode equivalent and this has been used, provide the -- unicode variant of the annotation. mu :: AnnKeywordId -> Located Token -> AddEpAnn -mu a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (EpaSpan $ rs l) +mu a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (srcSpan2e l) -- | If the 'Token' is using its unicode variant return the unicode variant of -- the annotation @@ -4253,7 +4253,7 @@ glR :: Located a -> Anchor glR la = Anchor (realSrcSpan $ getLoc la) UnchangedAnchor glAA :: Located a -> EpaLocation -glAA = EpaSpan <$> realSrcSpan . getLoc +glAA = srcSpan2e . getLoc glRR :: Located a -> RealSrcSpan glRR = realSrcSpan . getLoc @@ -4265,7 +4265,7 @@ glNR :: LocatedN a -> Anchor glNR ln = Anchor (realSrcSpan $ getLocA ln) UnchangedAnchor glNRR :: LocatedN a -> EpaLocation -glNRR = EpaSpan <$> realSrcSpan . getLocA +glNRR = srcSpan2e . getLocA anc :: RealSrcSpan -> Anchor anc r = Anchor r UnchangedAnchor @@ -4395,7 +4395,7 @@ rs _ = panic "Parser should only have RealSrcSpan" hsDoAnn :: Located a -> LocatedAn t b -> AnnKeywordId -> AnnList hsDoAnn (L l _) (L ll _) kw - = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (EpaSpan $ rs l)] [] + = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (srcSpan2e l)] [] listAsAnchor :: [LocatedAn t a] -> Anchor listAsAnchor [] = spanAsAnchor noSrcSpan @@ -4435,16 +4435,16 @@ addTrailingAnnA (L (SrcSpanAnn anns l) a) ss ta = do let anns' = if isZeroWidthSpan ss then anns - else addTrailingAnnToA l (ta (EpaSpan $ rs ss)) cs anns + else addTrailingAnnToA l (ta (srcSpan2e ss)) cs anns return (L (SrcSpanAnn anns' l) a) -- ------------------------------------- addTrailingVbarL :: MonadP m => LocatedL a -> SrcSpan -> m (LocatedL a) -addTrailingVbarL la span = addTrailingAnnL la (AddVbarAnn (EpaSpan $ rs span)) +addTrailingVbarL la span = addTrailingAnnL la (AddVbarAnn (srcSpan2e span)) addTrailingCommaL :: MonadP m => LocatedL a -> SrcSpan -> m (LocatedL a) -addTrailingCommaL la span = addTrailingAnnL la (AddCommaAnn (EpaSpan $ rs span)) +addTrailingCommaL la span = addTrailingAnnL la (AddCommaAnn (srcSpan2e span)) addTrailingAnnL :: MonadP m => LocatedL a -> TrailingAnn -> m (LocatedL a) addTrailingAnnL (L (SrcSpanAnn anns l) a) ta = do @@ -4462,7 +4462,7 @@ addTrailingCommaN (L (SrcSpanAnn anns l) a) span = do -- AZ:TODO: generalise updating comments into an annotation let anns' = if isZeroWidthSpan span then anns - else addTrailingCommaToN l anns (EpaSpan $ rs span) + else addTrailingCommaToN l anns (srcSpan2e span) return (L (SrcSpanAnn anns' l) a) addTrailingCommaS :: Located StringLiteral -> EpaLocation -> Located StringLiteral ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -51,7 +51,7 @@ module GHC.Parser.Annotation ( la2na, na2la, n2l, l2n, l2l, la2la, reLoc, reLocA, reLocL, reLocC, reLocN, - la2r, realSrcSpan, + srcSpan2e, la2e, realSrcSpan, -- ** Building up annotations extraToAnnList, reAnn, @@ -403,7 +403,7 @@ data AddEpAnn = AddEpAnn AnnKeywordId EpaLocation deriving (Data,Eq) -- in the @'EpaDelta'@ variant captures any comments between the prior -- output and the thing being marked here, since we cannot otherwise -- sort the relative order. -data EpaLocation = EpaSpan !RealSrcSpan +data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | EpaDelta !DeltaPos ![LEpaComment] deriving (Data,Eq) @@ -447,15 +447,15 @@ getDeltaLine (DifferentLine r _) = r -- 'EpaLocation'. The parser will never insert a 'DeltaPos', so the -- partial function is safe. epaLocationRealSrcSpan :: EpaLocation -> RealSrcSpan -epaLocationRealSrcSpan (EpaSpan r) = r +epaLocationRealSrcSpan (EpaSpan r _) = r epaLocationRealSrcSpan (EpaDelta _ _) = panic "epaLocationRealSrcSpan" epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation -epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) -epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) +epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) Strict.Nothing +epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) Strict.Nothing instance Outputable EpaLocation where - ppr (EpaSpan r) = text "EpaSpan" <+> ppr r + ppr (EpaSpan r _) = text "EpaSpan" <+> ppr r ppr (EpaDelta d cs) = text "EpaDelta" <+> ppr d <+> ppr cs instance Outputable AddEpAnn where @@ -916,8 +916,12 @@ realSrcSpan _ = mkRealSrcSpan l l -- AZ temporary where l = mkRealSrcLoc (fsLit "foo") (-1) (-1) -la2r :: SrcSpanAnn' a -> RealSrcSpan -la2r l = realSrcSpan (locA l) +srcSpan2e :: SrcSpan -> EpaLocation +srcSpan2e (RealSrcSpan s mb) = EpaSpan s mb +srcSpan2e span = EpaSpan (realSrcSpan span) Strict.Nothing + +la2e :: SrcSpanAnn' a -> EpaLocation +la2e = srcSpan2e . locA extraToAnnList :: AnnList -> [AddEpAnn] -> AnnList extraToAnnList (AnnList a o c e t) as = AnnList a o c (e++as) t @@ -976,7 +980,7 @@ widenSpan :: SrcSpan -> [AddEpAnn] -> SrcSpan widenSpan s as = foldl combineSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s):rest) = RealSrcSpan s Strict.Nothing : go rest + go (AddEpAnn _ (EpaSpan s mb):rest) = RealSrcSpan s mb : go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest -- | The annotations need to all come after the anchor. Make sure @@ -985,7 +989,7 @@ widenRealSpan :: RealSrcSpan -> [AddEpAnn] -> RealSrcSpan widenRealSpan s as = foldl combineRealSrcSpans s (go as) where go [] = [] - go (AddEpAnn _ (EpaSpan s):rest) = s : go rest + go (AddEpAnn _ (EpaSpan s _):rest) = s : go rest go (AddEpAnn _ (EpaDelta _ _):rest) = go rest widenAnchor :: Anchor -> [AddEpAnn] -> Anchor ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3646,7 +3646,7 @@ warn_unknown_prag prags span buf len buf2 = do -- 'AddEpAnn' values for the opening and closing bordering on the start -- and end of the span mkParensEpAnn :: RealSrcSpan -> (AddEpAnn, AddEpAnn) -mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo),AddEpAnn AnnCloseP (EpaSpan lc)) +mkParensEpAnn ss = (AddEpAnn AnnOpenP (EpaSpan lo Strict.Nothing),AddEpAnn AnnCloseP (EpaSpan lc Strict.Nothing)) where f = srcSpanFile ss sl = srcSpanStartLine ss ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -471,13 +471,13 @@ annBinds a cs (HsIPBinds an bs) = (HsIPBinds (add_where a an cs) bs, Nothing) annBinds _ cs (EmptyLocalBinds x) = (EmptyLocalBinds x, Just cs) add_where :: AddEpAnn -> EpAnn AnnList -> EpAnnComments -> EpAnn AnnList -add_where an@(AddEpAnn _ (EpaSpan rs)) (EpAnn a (AnnList anc o c r t) cs) cs2 +add_where an@(AddEpAnn _ (EpaSpan rs _)) (EpAnn a (AnnList anc o c r t) cs) cs2 | valid_anchor (anchor a) = EpAnn (widenAnchor a [an]) (AnnList anc o c (an:r) t) (cs Semi.<> cs2) | otherwise = EpAnn (patch_anchor rs a) (AnnList (fmap (patch_anchor rs) anc) o c (an:r) t) (cs Semi.<> cs2) -add_where an@(AddEpAnn _ (EpaSpan rs)) EpAnnNotUsed cs +add_where an@(AddEpAnn _ (EpaSpan rs _)) EpAnnNotUsed cs = EpAnn (Anchor rs UnchangedAnchor) (AnnList (Just $ Anchor rs UnchangedAnchor) Nothing Nothing [an] []) cs add_where (AddEpAnn _ (EpaDelta _ _)) _ _ = panic "add_where" @@ -501,7 +501,7 @@ fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) -- | The 'Anchor' for a stmtlist is based on either the location or -- the first semicolon annotion. stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Anchor -stmtsAnchor (L l ((ConsOL (AddEpAnn _ (EpaSpan r)) _), _)) +stmtsAnchor (L l ((ConsOL (AddEpAnn _ (EpaSpan r _)) _), _)) = widenAnchorR (Anchor (realSrcSpan l) UnchangedAnchor) r stmtsAnchor (L l _) = Anchor (realSrcSpan l) UnchangedAnchor @@ -1039,13 +1039,13 @@ checkTyClHdr is_cls ty newAnns (SrcSpanAnn EpAnnNotUsed l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (realSrcSpan l) (anchor as) - an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (EpaSpan $ realSrcSpan l) c []) cs) + an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (srcSpan2e l) c []) cs) in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) newAnns _ EpAnnNotUsed = panic "missing AnnParen" newAnns (SrcSpanAnn (EpAnn ap (AnnListItem ta) csp) l) (EpAnn as (AnnParen _ o c) cs) = let lr = combineRealSrcSpans (anchor ap) (anchor as) - an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (EpaSpan $ realSrcSpan l) c ta) (csp Semi.<> cs)) + an = (EpAnn (Anchor lr UnchangedAnchor) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs)) in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) -- | Yield a parse error if we have a function applied directly to a do block @@ -2855,7 +2855,7 @@ checkImportSpec ie@(L _ specs) = mkImpExpSubSpec :: [LocatedA ImpExpQcSpec] -> P ([AddEpAnn], ImpExpSubSpec) mkImpExpSubSpec [] = return ([], ImpExpList []) mkImpExpSubSpec [L la ImpExpQcWildcard] = - return ([AddEpAnn AnnDotdot (EpaSpan $ la2r la)], ImpExpAll) + return ([AddEpAnn AnnDotdot (la2e la)], ImpExpAll) mkImpExpSubSpec xs = if (any (isImpExpQcWildcard . unLoc) xs) then return $ ([], ImpExpAllWith xs) @@ -3124,14 +3124,14 @@ mkMultTy pct t arr = HsExplicitMult pct t arr mkTokenLocation :: SrcSpan -> TokenLocation mkTokenLocation (UnhelpfulSpan _) = NoTokenLoc -mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) +mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) -- Precondition: the TokenLocation has EpaSpan, never EpaDelta. token_location_widenR :: TokenLocation -> SrcSpan -> TokenLocation token_location_widenR NoTokenLoc _ = NoTokenLoc token_location_widenR tl (UnhelpfulSpan _) = tl -token_location_widenR (TokenLoc (EpaSpan r1)) (RealSrcSpan r2 _) = - (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2))) +token_location_widenR (TokenLoc (EpaSpan r1 mb1)) (RealSrcSpan r2 mb2) = + (TokenLoc (EpaSpan (combineRealSrcSpans r1 r2) (liftA2 combineBufSpans mb1 mb2))) token_location_widenR (TokenLoc (EpaDelta _ _)) _ = -- Never happens because the parser does not produce EpaDelta. panic "token_location_widenR: EpaDelta" ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -2011,14 +2011,14 @@ printMinimalImports hsc_src imports_w_usage to_ie_post_rn_var :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn_var (L l n) - | isDataOcc $ occName n = L l (IEPattern (EpaSpan $ la2r l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isDataOcc $ occName n = L l (IEPattern (la2e l) (L (la2na l) n)) + | otherwise = L l (IEName noExtField (L (la2na l) n)) to_ie_post_rn :: LocatedA (IdP GhcRn) -> LIEWrappedName GhcRn to_ie_post_rn (L l n) - | isTcOcc occ && isSymOcc occ = L l (IEType (EpaSpan $ la2r l) (L (la2na l) n)) - | otherwise = L l (IEName noExtField (L (la2na l) n)) + | isTcOcc occ && isSymOcc occ = L l (IEType (la2e l) (L (la2na l) n)) + | otherwise = L l (IEName noExtField (L (la2na l) n)) where occ = occName n {- ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -16,6 +16,8 @@ import GHC.IO (catchException) import GHC.CmmToLlvm.Config (LlvmVersion, llvmVersionStr, supportedLlvmVersionUpperBound, parseLlvmVersion, supportedLlvmVersionLowerBound) +import GHC.Settings + import GHC.SysTools.Process import GHC.SysTools.Info @@ -362,15 +364,15 @@ runAr logger dflags cwd args = traceSystoolCommand logger "ar" $ do let ar = pgm_ar dflags runSomethingFiltered logger id "Ar" ar args cwd Nothing -askOtool :: Logger -> DynFlags -> Maybe FilePath -> [Option] -> IO String -askOtool logger dflags mb_cwd args = do - let otool = pgm_otool dflags +askOtool :: Logger -> ToolSettings -> Maybe FilePath -> [Option] -> IO String +askOtool logger toolSettings mb_cwd args = do + let otool = toolSettings_pgm_otool toolSettings runSomethingWith logger "otool" otool args $ \real_args -> readCreateProcessWithExitCode' (proc otool real_args){ cwd = mb_cwd } -runInstallNameTool :: Logger -> DynFlags -> [Option] -> IO () -runInstallNameTool logger dflags args = do - let tool = pgm_install_name_tool dflags +runInstallNameTool :: Logger -> ToolSettings -> [Option] -> IO () +runInstallNameTool logger toolSettings args = do + let tool = toolSettings_pgm_install_name_tool toolSettings runSomethingFiltered logger id "Install Name Tool" tool args Nothing Nothing runRanlib :: Logger -> DynFlags -> [Option] -> IO () ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -70,6 +70,7 @@ module GHC.Types.SrcLoc ( BufSpan(..), getBufSpan, removeBufSpan, + combineBufSpans, -- * Located Located, ===================================== compiler/ghc.cabal.in ===================================== @@ -421,6 +421,7 @@ Library GHC.Driver.Config.HsToCore GHC.Driver.Config.HsToCore.Ticks GHC.Driver.Config.HsToCore.Usage + GHC.Driver.Config.Linker GHC.Driver.Config.Logger GHC.Driver.Config.Parser GHC.Driver.Config.Stg.Debug @@ -529,6 +530,7 @@ Library GHC.JS.Syntax GHC.JS.Transform GHC.Linker + GHC.Linker.Config GHC.Linker.Dynamic GHC.Linker.ExtraObj GHC.Linker.Loader ===================================== hadrian/doc/user-settings.md ===================================== @@ -25,7 +25,7 @@ data Flavour = Flavour { packages :: Stage -> Action [Package], -- | Bignum backend: 'native', 'gmp', 'ffi', etc. bignumBackend :: String, - -- | Check bignum backend against native + -- | Check selected bignum backend against native backend bignumCheck :: Bool, -- | Build libraries these ways. libraryWays :: Ways, @@ -34,15 +34,20 @@ data Flavour = Flavour { -- | Build dynamic GHC programs. dynamicGhcPrograms :: Action Bool, -- | Enable GHCi debugger. - ghciWithDebugger :: Bool, + ghciWithDebugger :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build profiled GHC. - ghcProfiled :: Bool, + ghcProfiled :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build GHC with the debug RTS. - ghcDebugged :: Bool, + ghcDebugged :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build GHC with debug assertions (-DDEBUG). - ghcDebugAssertions :: Bool, + ghcDebugAssertions :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build the GHC executable against the threaded runtime system. - ghcThreaded :: Bool, + ghcThreaded :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Whether to build docs and which ones -- (haddocks, user manual, haddock manual) ghcDocs :: Action DocTargets } ===================================== hadrian/src/Flavour/Type.hs ===================================== @@ -18,9 +18,9 @@ data Flavour = Flavour { args :: Args, -- | Build these packages. packages :: Stage -> Action [Package], - -- | 'native', 'gmp', 'ffi'. + -- | Bignum backend: 'native', 'gmp', 'ffi', etc. bignumBackend :: String, - -- | Check selected backend against native backend + -- | Check selected bignum backend against native backend bignumCheck :: Bool, -- | Build libraries these ways. libraryWays :: Ways, @@ -29,15 +29,20 @@ data Flavour = Flavour { -- | Build dynamic GHC programs. dynamicGhcPrograms :: Action Bool, -- | Enable GHCi debugger. - ghciWithDebugger :: Stage -> Bool, + ghciWithDebugger :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build profiled GHC. - ghcProfiled :: Stage -> Bool, + ghcProfiled :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build GHC with the debug RTS. - ghcDebugged :: Stage -> Bool, - -- | Build GHC with debug assertions. - ghcDebugAssertions :: Stage -> Bool, + ghcDebugged :: Stage -- ^ stage of the /built/ compiler + -> Bool, + -- | Build GHC with debug assertions (-DDEBUG). + ghcDebugAssertions :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build the GHC executable against the threaded runtime system. - ghcThreaded :: Stage -> Bool, + ghcThreaded :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Whether to build docs and which ones -- (haddocks, user manual, haddock manual) ghcDocs :: Action DocTargets } ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -101,7 +101,7 @@ inTreeCompilerArgs stg = do unregisterised <- flag GhcUnregisterised tables_next_to_code <- flag TablesNextToCode withSMP <- targetSupportsSMP - debugAssertions <- ($ stg) . ghcDebugAssertions <$> flavour + debugAssertions <- ($ succStage stg) . ghcDebugAssertions <$> flavour profiled <- ghcProfiled <$> flavour <*> pure stg os <- setting HostOs ===================================== hadrian/src/Settings/Flavours/Development.hs ===================================== @@ -16,12 +16,12 @@ developmentFlavour ghcStage = defaultFlavour , libraryWays = pure $ Set.fromList [vanilla] , rtsWays = Set.fromList <$> mconcat [pure [vanilla, debug], targetSupportsThreadedRts ? pure [threaded, threadedDebug]] , dynamicGhcPrograms = return False - , ghcDebugAssertions = (>= Stage2) } + , ghcDebugAssertions = (== ghcStage) } where stageString Stage2 = "2" stageString Stage1 = "1" stageString Stage3 = "3" - stageString s = error ("developmentFlavour not support for " ++ show s) + stageString s = error ("developmentFlavour not supported for " ++ show s) developmentArgs :: Stage -> Args developmentArgs ghcStage = do ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -13,7 +13,6 @@ packageArgs :: Args packageArgs = do stage <- getStage path <- getBuildPath - root <- getBuildRoot compilerPath <- expr $ buildPath (vanillaContext stage compiler) let -- Do not bind the result to a Boolean: this forces the configure rule @@ -29,7 +28,10 @@ packageArgs = do cursesLibraryDir <- getSetting CursesLibDir ffiIncludeDir <- getSetting FfiIncludeDir ffiLibraryDir <- getSetting FfiLibDir - debugAssertions <- ghcDebugAssertions <$> expr flavour + debugAssertions <- ( `ghcDebugAssertions` (succStage stage) ) <$> expr flavour + -- NB: in this function, "stage" is the stage of the compiler we are + -- using to build, but ghcDebugAssertions wants the stage of the compiler + -- we are building, which we get using succStage. mconcat --------------------------------- base --------------------------------- @@ -52,7 +54,7 @@ packageArgs = do [ builder Alex ? arg "--latin1" , builder (Ghc CompileHs) ? mconcat - [ debugAssertions stage ? arg "-DDEBUG" + [ debugAssertions ? arg "-DDEBUG" , inputs ["**/GHC.hs", "**/GHC/Driver/Make.hs"] ? arg "-fprof-auto" , input "**/Parser.hs" ? @@ -83,7 +85,7 @@ packageArgs = do , package ghc ? mconcat [ builder Ghc ? mconcat [ arg ("-I" ++ compilerPath) - , debugAssertions stage ? arg "-DDEBUG" ] + , debugAssertions ? arg "-DDEBUG" ] , builder (Cabal Flags) ? mconcat [ andM [expr ghcWithInterpreter, notStage0] `cabalFlag` "internal-interpreter" ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -543,7 +543,7 @@ printStringAtAAL (EpAnn anc an cs) l str = do printStringAtAAC :: (Monad m, Monoid w) => CaptureComments -> EpaLocation -> String -> EP w m EpaLocation -printStringAtAAC capture (EpaSpan r) s = printStringAtRsC capture r s +printStringAtAAC capture (EpaSpan r _) s = printStringAtRsC capture r s printStringAtAAC capture (EpaDelta d cs) s = do mapM_ (printOneComment . tokComment) cs pe1 <- getPriorEndD @@ -4108,7 +4108,7 @@ printUnicode anc n = do s -> s loc <- printStringAtAAC NoCaptureComments (EpaDelta (SameLine 0) []) str case loc of - EpaSpan _ -> return anc + EpaSpan _ _ -> return anc EpaDelta dp [] -> return anc { anchor_op = MovedAnchor dp } EpaDelta _ _cs -> error "printUnicode should not capture comments" ===================================== utils/check-exact/Parsers.hs ===================================== @@ -285,7 +285,7 @@ fixModuleTrailingComments (GHC.L l p) = GHC.L l p' rebalance al cs = cs' where cs' = case GHC.al_close al of - Just (GHC.AddEpAnn _ (GHC.EpaSpan ss)) -> + Just (GHC.AddEpAnn _ (GHC.EpaSpan ss _)) -> let pc = GHC.priorComments cs fc = GHC.getFollowingComments cs ===================================== utils/check-exact/Transform.hs ===================================== @@ -213,7 +213,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H L (SrcSpanAnn EpAnnNotUsed ll) _ -> realSrcSpan ll L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor? dc' = case dca of - EpaSpan r -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) + EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) EpaDelta _ _ -> AddEpAnn kw dca -- --------------------------------- @@ -223,7 +223,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H (L (SrcSpanAnn EpAnnNotUsed ll) b) -> let op = case dca of - EpaSpan r -> MovedAnchor (ss2delta (ss2posEnd r) (realSrcSpan ll)) + EpaSpan r _ -> MovedAnchor (ss2delta (ss2posEnd r) (realSrcSpan ll)) EpaDelta _ _ -> MovedAnchor (SameLine 1) in (L (SrcSpanAnn (EpAnn (Anchor (realSrcSpan ll) op) mempty emptyComments) ll) b) (L (SrcSpanAnn (EpAnn (Anchor r op) a c) ll) b) @@ -231,7 +231,7 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H op' = case op of MovedAnchor _ -> op _ -> case dca of - EpaSpan dcr -> MovedAnchor (ss2delta (ss2posEnd dcr) r) + EpaSpan dcr _ -> MovedAnchor (ss2delta (ss2posEnd dcr) r) EpaDelta _ _ -> MovedAnchor (SameLine 1) in (L (SrcSpanAnn (EpAnn (Anchor r op') a c) ll) b) @@ -341,13 +341,13 @@ getEntryDP _ = SameLine 1 addEpaLocationDelta :: LayoutStartCol -> RealSrcSpan -> EpaLocation -> EpaLocation addEpaLocationDelta _off _anc (EpaDelta d cs) = EpaDelta d cs -addEpaLocationDelta off anc (EpaSpan r) +addEpaLocationDelta off anc (EpaSpan r _) = EpaDelta (adjustDeltaForOffset off (ss2deltaEnd anc r)) [] -- Set the entry DP for an element coming after an existing keyword annotation setEntryDPFromAnchor :: LayoutStartCol -> EpaLocation -> LocatedA t -> LocatedA t setEntryDPFromAnchor _off (EpaDelta _ _) (L la a) = L la a -setEntryDPFromAnchor off (EpaSpan anc) ll@(L la _) = setEntryDP ll dp' +setEntryDPFromAnchor off (EpaSpan anc _) ll@(L la _) = setEntryDP ll dp' where r = case la of (SrcSpanAnn EpAnnNotUsed l) -> realSrcSpan l @@ -944,7 +944,7 @@ instance HasDecls (LocatedA (HsExpr GhcPs)) where (L (TokenLoc l) ls, L (TokenLoc i) is) -> let off = case l of - (EpaSpan r) -> LayoutStartCol $ snd $ ss2pos r + (EpaSpan r _) -> LayoutStartCol $ snd $ ss2pos r (EpaDelta (SameLine _) _) -> LayoutStartCol 0 (EpaDelta (DifferentLine _ c) _) -> LayoutStartCol c ex'' = setEntryDPFromAnchor off i ex ===================================== utils/check-exact/Utils.hs ===================================== @@ -119,7 +119,7 @@ undelta (l,_) (DifferentLine dl dc) (LayoutStartCol co) = (fl,fc) fc = co + dc undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn -undeltaSpan anchor kw dp = AddEpAnn kw (EpaSpan sp) +undeltaSpan anchor kw dp = AddEpAnn kw (EpaSpan sp Strict.Nothing) where (l,c) = undelta (ss2pos anchor) dp (LayoutStartCol 0) len = length (keywordToString kw) @@ -256,7 +256,7 @@ sortEpaComments cs = sortBy cmp cs -- | Makes a comment which originates from a specific keyword. mkKWComment :: AnnKeywordId -> EpaLocation -> Comment -mkKWComment kw (EpaSpan ss) +mkKWComment kw (EpaSpan ss _) = Comment (keywordToString kw) (Anchor ss UnchangedAnchor) ss (Just kw) mkKWComment kw (EpaDelta dp _) = Comment (keywordToString kw) (Anchor placeholderRealSpan (MovedAnchor dp)) placeholderRealSpan (Just kw) @@ -373,7 +373,7 @@ addEpAnnLoc (AddEpAnn _ l) = l -- TODO: move this to GHC anchorToEpaLocation :: Anchor -> EpaLocation -anchorToEpaLocation (Anchor r UnchangedAnchor) = EpaSpan r +anchorToEpaLocation (Anchor r UnchangedAnchor) = EpaSpan r Strict.Nothing anchorToEpaLocation (Anchor _ (MovedAnchor dp)) = EpaDelta dp [] -- --------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1edc25795ae09bfd39e5c0e5e185c64553f290c3...3610891d555379d2f79fdcbb3ada56d95032dbaa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1edc25795ae09bfd39e5c0e5e185c64553f290c3...3610891d555379d2f79fdcbb3ada56d95032dbaa You're receiving 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 Dec 6 12:28:33 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 06 Dec 2022 07:28:33 -0500 Subject: [Git][ghc/ghc][wip/andreask/pinned] Don't consider large byte arrays/compact regions pinned. Message-ID: <638f3571d25af_17512e805d85c41324231@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/pinned at Glasgow Haskell Compiler / GHC Commits: 3940339e by Andreas Klebinger at 2022-12-06T13:26:33+01:00 Don't consider large byte arrays/compact regions pinned. Workaround for #22255 which showed how treating large/compact regions as pinned could cause segfaults. - - - - - 5 changed files: - libraries/ghc-prim/changelog.md - rts/PrimOps.cmm - testsuite/tests/rts/T13894.hs - testsuite/tests/rts/T14900.hs - testsuite/tests/rts/T14900.stdout Changes: ===================================== libraries/ghc-prim/changelog.md ===================================== @@ -21,6 +21,13 @@ - The `threadLabel#` primop was added, allowing the user to query the label of a given `ThreadId#`. +- `isByteArrayPinned#` now only considers an array pinned if it was explicitly pinned + by the user. This is required to avoid ghc issue [#22255](https://gitlab.haskell.org/ghc/ghc/-/issues/22255) + which showed that the old behaviour could cause segfaults when used in combination + with compact regions. + We are working on ways to allow users and library authors to get back the + performance benefits of the old behaviour where possible. + ## 0.9.0 *August 2022* - Shipped with GHC 9.4.1 ===================================== rts/PrimOps.cmm ===================================== @@ -209,7 +209,10 @@ stg_isByteArrayPinnedzh ( gcptr ba ) // See the comment in Storage.c:allocatePinned. // We also consider BF_COMPACT objects to be immovable. See #14900. flags = TO_W_(bdescr_flags(bd)); - return (flags & (BF_PINNED | BF_LARGE | BF_COMPACT) != 0); + + // We used to also consider BF_LARGE pinned, but stopped doing so + // because it interacted badly with compact regions. See #22255 + return (flags & BF_PINNED != 0); } stg_isMutableByteArrayPinnedzh ( gcptr mba ) ===================================== testsuite/tests/rts/T13894.hs ===================================== @@ -1,5 +1,5 @@ --- Test that isByteArray# returns True for large but not explicitly pinned byte --- arrays +-- Test that isByteArray# returns False for large but not explicitly pinned byte +-- arrays, see #22255 {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} @@ -15,4 +15,4 @@ main = do (# s1, arr# #) -> case isMutableByteArrayPinned# arr# of n# -> (# s1, isTrue# n# #) - unless pinned $ putStrLn "BAD" + when pinned $ putStrLn "BAD" ===================================== testsuite/tests/rts/T14900.hs ===================================== @@ -13,6 +13,8 @@ newByteArray (I# sz) = IO $ \s -> case newByteArray# sz s of { (# s', arr# #) -> case unsafeFreezeByteArray# arr# s of { (# s'', barr# #) -> (# s', ByteArray barr# #) }} +-- Currently we expect large/compact regions not to count as pinned. +-- See #22255 for the reasoning. main :: IO () main = do ByteArray arr1# <- fmap getCompact $ newByteArray 65000 >>= compact ===================================== testsuite/tests/rts/T14900.stdout ===================================== @@ -1,3 +1,3 @@ -1 -1 +0 +0 Finished View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3940339e9f141aa27bf9f284e47004a41a18b62a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3940339e9f141aa27bf9f284e47004a41a18b62a You're receiving 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 Dec 6 12:29:19 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 06 Dec 2022 07:29:19 -0500 Subject: [Git][ghc/ghc][wip/T22264] 6 commits: rts: Drop racy assertion Message-ID: <638f359f9d389_17512e7eb4863c13280cc@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC Commits: b57fd39a by Ben Gamari at 2022-12-06T07:29:00-05:00 rts: Drop racy assertion 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object. - - - - - 4fc3d778 by Ben Gamari at 2022-12-06T07:29:00-05:00 rts: Drop SM spinlock - - - - - 8334376c by Ben Gamari at 2022-12-06T07:29:00-05:00 rts: C++ typing issues Make the RTS compilable with a C++ compiler by inserting necessary casts. - - - - - d4209888 by Ben Gamari at 2022-12-06T07:29:00-05:00 CheckGC - - - - - 9828dd44 by Ben Gamari at 2022-12-06T07:29:00-05:00 setNumCapabilities - - - - - 14f1045d by Ben Gamari at 2022-12-06T07:29:00-05:00 nonmoving: Disable shortcutting - - - - - 26 changed files: - libraries/base/GHC/Conc/Sync.hs - rts/Capability.h - rts/CheckUnload.c - rts/Schedule.c - rts/Schedule.h - rts/Sparks.h - rts/Stats.c - rts/Trace.h - rts/include/rts/Threads.h - rts/include/rts/storage/MBlock.h - rts/rts.cabal.in - rts/sm/BlockAlloc.c - + rts/sm/CheckGc.cpp - rts/sm/GC.c - rts/sm/GC.h - rts/sm/GCUtils.c - rts/sm/GCUtils.h - rts/sm/HeapAlloc.h - rts/sm/MarkStack.h - rts/sm/NonMoving.c - rts/sm/NonMovingMark.c - rts/sm/NonMovingMark.h - rts/sm/NonMovingShortcut.c - rts/sm/Sanity.h - rts/sm/Scav.c - rts/sm/Storage.c Changes: ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -380,10 +380,15 @@ to avoid contention with other processes in the machine. setNumCapabilities :: Int -> IO () setNumCapabilities i | i <= 0 = failIO $ "setNumCapabilities: Capability count ("++show i++") must be positive" - | otherwise = c_setNumCapabilities (fromIntegral i) + | otherwise = do + ret <- c_setNumCapabilities (fromIntegral i) + case ret of + 0 -> return () + 1 -> yield >> setNumCapabilities i + _ -> failIO $ "setNumCapabilities: Unknown result" foreign import ccall safe "setNumCapabilities" - c_setNumCapabilities :: CUInt -> IO () + c_setNumCapabilities :: CUInt -> IO CInt -- | Returns the number of CPUs that the machine has -- ===================================== rts/Capability.h ===================================== @@ -20,10 +20,10 @@ #pragma once -#include "sm/GC.h" // for evac_fn #include "Task.h" #include "Sparks.h" -#include "sm/NonMovingMark.h" // for MarkQueue +#include "sm/GC.h" // for evac_fn +#include "sm/NonMovingMark.h" // for UpdRemSet #include "IOManager.h" // for CapIOManager #include "BeginPrivate.h" ===================================== rts/CheckUnload.c ===================================== @@ -15,6 +15,7 @@ #include "Hash.h" #include "LinkerInternals.h" #include "CheckUnload.h" +#include "sm/HeapAlloc.h" #include "sm/Storage.h" #include "sm/GCThread.h" #include "sm/HeapUtils.h" ===================================== rts/Schedule.c ===================================== @@ -2225,9 +2225,12 @@ forkProcess(HsStablePtr *entry * Finally we release the Capabilities we are holding, and start * worker Tasks on the new Capabilities we created. * + * One wrinkle here is that we must also ensure that we don't change the + * capability count while the nonmoving mark thread is active. + * * ------------------------------------------------------------------------- */ -void +int setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) { #if !defined(THREADED_RTS) @@ -2247,11 +2250,15 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) Capability *old_capabilities = NULL; uint32_t old_n_capabilities = n_capabilities; + if (RELAXED_LOAD(&concurrent_coll_running)) { + return 1; + } + if (new_n_capabilities == enabled_capabilities) { - return; + return 0; } else if (new_n_capabilities <= 0) { errorBelch("setNumCapabilities: Capability count must be positive"); - return; + return 1; } @@ -2353,6 +2360,7 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) rts_unlock(cap); + return 0; #endif // THREADED_RTS } ===================================== rts/Schedule.h ===================================== @@ -131,7 +131,7 @@ setRecentActivity(enum RecentActivity new_value) INLINE_HEADER enum RecentActivity getRecentActivity(void) { - return RELAXED_LOAD_ALWAYS(&recent_activity); + return (enum RecentActivity) RELAXED_LOAD_ALWAYS(&recent_activity); } extern bool heap_overflow; ===================================== rts/Sparks.h ===================================== @@ -8,6 +8,7 @@ #pragma once +#include "sm/GC.h" // for evac_fn #include "WSDeque.h" #include "BeginPrivate.h" ===================================== rts/Stats.c ===================================== @@ -963,11 +963,6 @@ static void report_summary(const RTSSummaryStats* sum) , col_width[1], "SpinLock" , col_width[2], "Spins" , col_width[3], "Yields"); - statsPrintf("%*s" "%*s" "%*" FMT_Word64 "%*" FMT_Word64 "\n" - , col_width[0], "" - , col_width[1], "gc_alloc_block_sync" - , col_width[2], gc_alloc_block_sync.spin - , col_width[3], gc_alloc_block_sync.yield); statsPrintf("%*s" "%*s" "%*" FMT_Word64 "%*s\n" , col_width[0], "" , col_width[1], "whitehole_gc" @@ -1142,10 +1137,6 @@ static void report_machine_readable (const RTSSummaryStats * sum) // next, internal counters #if defined(PROF_SPIN) - MR_STAT("gc_alloc_block_sync_spin", FMT_Word64, gc_alloc_block_sync.spin); - MR_STAT("gc_alloc_block_sync_yield", FMT_Word64, - gc_alloc_block_sync.yield); - MR_STAT("gc_alloc_block_sync_spin", FMT_Word64, gc_alloc_block_sync.spin); MR_STAT("waitForGcThreads_spin", FMT_Word64, waitForGcThreads_spin); MR_STAT("waitForGcThreads_yield", FMT_Word64, waitForGcThreads_yield); @@ -1572,9 +1563,6 @@ SpinLock: Not all of these are actual SpinLocks, see the details below. Actual SpinLocks: -* gc_alloc_block: - This SpinLock protects the block allocator and free list manager. See - BlockAlloc.c. * gen[g].sync: These SpinLocks, one per generation, protect the generations[g] data structure during garbage collection. ===================================== rts/Trace.h ===================================== @@ -33,7 +33,9 @@ void tracingAddCapapilities (uint32_t from, uint32_t to); #endif /* TRACING */ typedef StgWord32 CapsetID; +#if !defined(__cplusplus) typedef StgWord16 CapsetType; +#endif enum CapsetType { CapsetTypeCustom = CAPSET_TYPE_CUSTOM, CapsetTypeOsProcess = CAPSET_TYPE_OSPROCESS, CapsetTypeClockdomain = CAPSET_TYPE_CLOCKDOMAIN }; ===================================== rts/include/rts/Threads.h ===================================== @@ -85,4 +85,4 @@ extern Capability MainCapability; // Change the number of capabilities (only supports increasing the // current value at the moment). // -extern void setNumCapabilities (uint32_t new_); +extern int setNumCapabilities (uint32_t new_); ===================================== rts/include/rts/storage/MBlock.h ===================================== @@ -26,7 +26,3 @@ extern void freeAllMBlocks(void); extern void *getFirstMBlock(void **state); extern void *getNextMBlock(void **state, void *mblock); -#if defined(THREADED_RTS) -// needed for HEAP_ALLOCED below -extern SpinLock gc_alloc_block_sync; -#endif ===================================== rts/rts.cabal.in ===================================== @@ -619,6 +619,7 @@ library linker/elf_tlsgd.c linker/elf_util.c sm/BlockAlloc.c + sm/CheckGc.cpp sm/CNF.c sm/Compact.c sm/Evac.c ===================================== rts/sm/BlockAlloc.c ===================================== @@ -438,6 +438,7 @@ alloc_mega_group (uint32_t node, StgWord mblocks) bdescr *best, *bd; StgWord n; + ASSERT_SM_LOCK(); n = MBLOCK_GROUP_BLOCKS(mblocks); if(defer_mblock_frees) @@ -496,6 +497,7 @@ allocGroupOnNode (uint32_t node, W_ n) bdescr *bd, *rem; StgWord ln; + ASSERT_SM_LOCK(); if (n == 0) barf("allocGroup: requested zero blocks"); if (n >= BLOCKS_PER_MBLOCK) @@ -709,6 +711,7 @@ bdescr* allocLargeChunkOnNode (uint32_t node, W_ min, W_ max) { bdescr *bd; StgWord ln, lnmax; + ASSERT_SM_LOCK(); if (min >= BLOCKS_PER_MBLOCK) { return allocGroupOnNode(node,max); @@ -933,8 +936,7 @@ freeGroup(bdescr *p) StgWord ln; uint32_t node; - // not true in multithreaded GC: - // ASSERT_SM_LOCK(); + ASSERT_SM_LOCK(); ASSERT(RELAXED_LOAD(&p->free) != (P_)-1); ===================================== rts/sm/CheckGc.cpp ===================================== @@ -0,0 +1,973 @@ +extern "C" { +#include "Rts.h" +#include "StableName.h" /* for FOR_EACH_STABLE_NAME */ +#include "StablePtr.h" /* for markStablePtrTable */ +#include "Schedule.h" /* for markScheduler */ +#include "Capability.h" +#include "HeapAlloc.h" +#include "STM.h" +} + +#include +#include +#include +#include +#include +#include + +class TaggedClosurePtr { + StgClosure *ptr; +public: + TaggedClosurePtr(StgClosure* ptr) : ptr(ptr) {} + TaggedClosurePtr(StgClosure* ptr, uint8_t tag) : TaggedClosurePtr(TAG_CLOSURE(tag, ptr)) {} + + StgClosure *get_tagged() const { + return ptr; + } + StgClosure *untag() const { + return UNTAG_CLOSURE(ptr); + } + uint8_t get_tag() const { + return (StgWord) ptr & TAG_MASK; + } + + //inline StgClosure& operator->() { return *untag(); } + + friend inline bool operator==(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { + return lhs.ptr == rhs.ptr; + } + friend inline bool operator!=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs == rhs); } + friend inline bool operator< (const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { + return lhs.ptr < rhs.ptr; + } + friend inline bool operator> (const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return rhs < lhs; } + friend inline bool operator<=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs > rhs); } + friend inline bool operator>=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs < rhs); } +}; + +template<> +struct std::hash { + std::size_t operator()(TaggedClosurePtr const& p) const noexcept { + return std::hash{}(p.get_tagged()); + } +}; + +class HeapVisitor { +public: + // Visit an SRT + virtual void visit_srt(StgClosure* c); + + // Visit a normal closure + virtual void visit_closure(TaggedClosurePtr c); + + virtual void visit_thunk(StgThunk *thunk, size_t n_ptrs); + virtual void visit_fun(StgClosure *constr, size_t n_ptrs); + virtual void visit_constr(StgClosure *constr, size_t n_ptrs); + virtual void visit_array(StgMutArrPtrs *arr); + virtual void visit_small_array(StgSmallMutArrPtrs *arr); + virtual void visit_bytearray(StgArrBytes* arr); + + virtual void visit_stack(StgPtr sp, StgPtr end); + virtual void visit_tso(StgTSO* tso); + virtual void visit_weak(StgWeak* w); + virtual void visit_mvar(StgMVar* mvar); + virtual void visit_tvar(StgTVar* tvar); + virtual void visit_trec_header(StgTRecHeader *trec); + virtual void visit_trec_chunk(StgTRecChunk* tc); + virtual void visit_continuation(StgContinuation* tc); + + virtual void visit_small_bitmap(StgClosure *const *payload, StgWord bitmap, StgWord size); + virtual void visit_large_bitmap(StgClosure *const *payload, const StgLargeBitmap *bitmap, StgWord size); + void visit_pap_payload(StgClosure *fun, StgClosure **payload, StgWord n_args); + + virtual void visit_invalid(StgClosure *const c); +}; + +void HeapVisitor::visit_thunk(StgThunk *thunk, size_t n_ptrs) +{ + const StgInfoTable *info = get_itbl((StgClosure *) thunk); + const StgThunkInfoTable *thunk_info = itbl_to_thunk_itbl(info); + if (thunk_info->i.srt) { + StgClosure *srt = (StgClosure*) GET_SRT(thunk_info); + visit_srt(srt); + }; + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(thunk->payload[i]); + } +} + +void HeapVisitor::visit_fun(StgClosure *fun, size_t n_ptrs) +{ + const StgInfoTable *info = get_itbl(fun); + const StgFunInfoTable *fun_info = itbl_to_fun_itbl(info); + if (fun_info->i.srt) { + StgClosure *srt = (StgClosure*) GET_SRT(fun_info); + visit_srt(srt); + }; + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(fun->payload[i]); + } +} + +void HeapVisitor::visit_constr(StgClosure *constr, size_t n_ptrs) +{ + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(constr->payload[i]); + } +} + +void HeapVisitor::visit_srt(StgClosure* c) +{ + visit_closure(c); +} + +void HeapVisitor::visit_invalid(StgClosure *const _c) +{ + abort(); +} + +void HeapVisitor::visit_weak(StgWeak* w) +{ + visit_closure(w->key); + visit_closure(w->value); + visit_closure(w->finalizer); + visit_closure(w->cfinalizers); +} + +void HeapVisitor::visit_mvar(StgMVar* mvar) +{ + visit_closure((StgClosure*) mvar->head); + visit_closure((StgClosure*) mvar->tail); + visit_closure(mvar->value); +} + +void HeapVisitor::visit_small_array(StgSmallMutArrPtrs *arr) +{ + for (StgWord i=0; i < arr->ptrs; i++) { + visit_closure(arr->payload[i]); + } +} + +void HeapVisitor::visit_array(StgMutArrPtrs *arr) +{ + for (StgWord i=0; i < arr->ptrs; i++) { + visit_closure(arr->payload[i]); + } +} + +void HeapVisitor::visit_bytearray(StgArrBytes* _arr) { } + +void HeapVisitor::visit_tso(StgTSO *tso) +{ + if (tso->bound != NULL) { + + visit_closure((StgClosure*) tso->bound->tso); + } + if (tso->label != NULL) { + visit_closure({(StgClosure*) tso->label}); + } + visit_closure((StgClosure*) tso->blocked_exceptions); + visit_closure((StgClosure*) tso->bq); + visit_closure((StgClosure*) tso->stackobj); + visit_closure((StgClosure*) tso->_link); + visit_trec_header(tso->trec); + + switch (tso->why_blocked) { + case BlockedOnMVar: + case BlockedOnMVarRead: + case BlockedOnBlackHole: + case BlockedOnMsgThrowTo: + case NotBlocked: + visit_closure(tso->block_info.closure); + break; + default: + break; + } +} + +void HeapVisitor::visit_continuation(StgContinuation *cont) +{ + visit_stack(cont->stack, cont->stack + cont->stack_size); +} + +void HeapVisitor::visit_tvar(StgTVar *tvar) +{ + visit_closure(tvar->current_value); + visit_closure((StgClosure*) tvar->first_watch_queue_entry); +} + +void HeapVisitor::visit_trec_header(StgTRecHeader *trec) +{ + if (trec == NO_TREC) { + return; + } + visit_trec_chunk(trec->current_chunk); + visit_closure((StgClosure*) trec->enclosing_trec); +} + +void HeapVisitor::visit_trec_chunk(StgTRecChunk *tc) +{ + if (tc->prev_chunk != END_STM_CHUNK_LIST) { + visit_closure((StgClosure*) tc->prev_chunk); + } + + for (uint32_t i = 0; i < tc->next_entry_idx; i++) { + TRecEntry *e = &tc->entries[i]; + visit_closure((StgClosure*)e->tvar); + visit_closure(e->expected_value); + visit_closure(e->new_value); + } +} + +void HeapVisitor::visit_stack(StgPtr p, StgPtr stack_end) +{ + while (p < stack_end) { + const StgRetInfoTable* info = get_ret_itbl((StgClosure *) p); + + auto add_srt_ptrs = [&] () { + if (info->i.srt) { + StgClosure *srt = (StgClosure*)GET_SRT(info); + visit_srt(srt); + } + }; + + switch (info->i.type) { + + case UPDATE_FRAME: + { + StgUpdateFrame *frame = (StgUpdateFrame *)p; + visit_closure(frame->updatee); + p += sizeofW(StgUpdateFrame); + continue; + } + + case CATCH_STM_FRAME: + case CATCH_RETRY_FRAME: + case ATOMICALLY_FRAME: + case UNDERFLOW_FRAME: + case STOP_FRAME: + case CATCH_FRAME: + case RET_SMALL: + { + StgWord bitmap = BITMAP_BITS(info->i.layout.bitmap); + StgWord size = BITMAP_SIZE(info->i.layout.bitmap); + // NOTE: the payload starts immediately after the info-ptr, we + // don't have an StgHeader in the same sense as a heap closure. + p++; + visit_small_bitmap((StgClosure**) p, bitmap, size); + p += size; + add_srt_ptrs(); + continue; + } + + case RET_BCO: + { + p++; + StgBCO *bco = (StgBCO *)*p; + visit_closure((StgClosure *) bco); + p++; + StgWord size = BCO_BITMAP_SIZE(bco); + visit_large_bitmap((StgClosure**) p, BCO_BITMAP(bco), size); + p += size; + continue; + } + + case RET_BIG: + { + StgWord size = GET_LARGE_BITMAP(&info->i)->size; + p++; + visit_large_bitmap((StgClosure**) p, GET_LARGE_BITMAP(&info->i), size); + p += size; + // and don't forget to follow the SRT + add_srt_ptrs(); + break; + } + + case RET_FUN: + { + StgRetFun *ret_fun = (StgRetFun *)p; + visit_closure(ret_fun->fun); + + const StgFunInfoTable *fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + switch (fun_info->f.fun_type) { + case ARG_GEN: + { + StgWord bitmap = BITMAP_BITS(fun_info->f.b.bitmap); + StgWord size = BITMAP_SIZE(fun_info->f.b.bitmap); + visit_small_bitmap(ret_fun->payload, bitmap, size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + case ARG_GEN_BIG: + { + StgWord size = GET_FUN_LARGE_BITMAP(fun_info)->size; + visit_large_bitmap(ret_fun->payload, GET_FUN_LARGE_BITMAP(fun_info), size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + default: + { + StgWord bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); + StgWord size = BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type]); + visit_small_bitmap(ret_fun->payload, bitmap, size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + } + add_srt_ptrs(); + break; + } + default: + abort(); + } + } +} + +void HeapVisitor::visit_small_bitmap( + StgClosure *const *payload, + StgWord bitmap, + StgWord size) +{ + while (size > 0) { + if ((bitmap & 1) == 0) { + visit_closure(*payload); + } + payload++; + bitmap = bitmap >> 1; + size--; + } +} + +void HeapVisitor::visit_large_bitmap( + StgClosure *const * payload, + const StgLargeBitmap *large_bitmap, + StgWord size) +{ + // Bitmap may have more bits than `size` when scavenging PAP payloads. See + // comments around StgPAP. + ASSERT(large_bitmap->size >= size); + + uint32_t b = 0; + for (uint32_t i = 0; i < size; b++) { + StgWord bitmap = large_bitmap->bitmap[b]; + uint32_t j = stg_min(size-i, BITS_IN(W_)); + i += j; + for (; j > 0; j--, payload++) { + if ((bitmap & 1) == 0) { + visit_closure(*payload); + } + bitmap = bitmap >> 1; + } + } +} + +void HeapVisitor::visit_pap_payload( + StgClosure *fun, + StgClosure **payload, + StgWord n_args) +{ + fun = UNTAG_CLOSURE(fun); + const StgFunInfoTable *fun_info = get_fun_itbl(fun); + ASSERT(fun_info->i.type != PAP); + switch (fun_info->f.fun_type) { + case ARG_GEN: + visit_small_bitmap(payload, BITMAP_BITS(fun_info->f.b.bitmap), n_args); + break; + case ARG_GEN_BIG: + visit_large_bitmap(payload, GET_FUN_LARGE_BITMAP(fun_info), n_args); + break; + case ARG_BCO: + visit_large_bitmap(payload, BCO_BITMAP(fun), n_args); + break; + default: + { + StgWord bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); + visit_small_bitmap(payload, bitmap, n_args); + } + } +} + +void HeapVisitor::visit_closure(TaggedClosurePtr tagged) +{ + StgClosure *c = tagged.untag(); + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa || !LOOKS_LIKE_CLOSURE_PTR(c)) { + visit_invalid(c); + return; + } + + const StgInfoTable *info = get_itbl(c); + auto generic_closure = [&] () { + for (StgClosure **p = &c->payload[0]; p < &c->payload[info->layout.payload.ptrs]; p++) { + visit_closure(*p); + } + }; + + switch (info->type) { + + case MVAR_CLEAN: + case MVAR_DIRTY: + visit_mvar((StgMVar *) c); + break; + case TVAR: + visit_tvar((StgTVar *) c); + break; + + case IND: + case IND_STATIC: + visit_closure(((StgInd *) c)->indirectee); + break; + + case THUNK_0_1: + case THUNK_0_2: + visit_thunk((StgThunk*) c, 0); + break; + case THUNK_1_1: + case THUNK_1_0: + visit_thunk((StgThunk*) c, 1); + break; + case THUNK_2_0: + visit_thunk((StgThunk*) c, 2); + break; + case THUNK: + visit_thunk((StgThunk*) c, info->layout.payload.ptrs); + break; + case THUNK_STATIC: + visit_thunk((StgThunk*) c, 0); + break; + + case FUN_1_0: + visit_fun(c, 1); + break; + case FUN_0_1: + case FUN_0_2: + visit_fun(c, 0); + break; + case FUN_1_1: + visit_fun(c, 1); + break; + case FUN_2_0: + visit_fun(c, 2); + break; + case FUN: + case FUN_STATIC: + visit_fun(c, info->layout.payload.ptrs); + break; + + case CONSTR_0_1: + case CONSTR_0_2: + visit_constr(c, 0); + break; + case CONSTR_1_0: + case CONSTR_1_1: + visit_constr(c, 1); + break; + case CONSTR_2_0: + visit_constr(c, 2); + break; + case CONSTR: + case CONSTR_NOCAF: + visit_constr(c, info->layout.payload.ptrs); + break; + + case PRIM: + generic_closure(); + break; + case WEAK: + visit_weak((StgWeak*) c); + break; + case BCO: + { + StgBCO *bco = (StgBCO *)c; + visit_closure((StgClosure*) bco->instrs); + visit_closure((StgClosure*) bco->literals); + visit_closure((StgClosure*) bco->ptrs); + break; + } + case BLACKHOLE: + { + StgInd *ind = (StgInd*) c; + visit_closure(ind->indirectee); + break; + } + case MUT_VAR_CLEAN: + case MUT_VAR_DIRTY: + { + StgMutVar *mv = (StgMutVar*) c; + visit_closure(mv->var); + break; + } + case BLOCKING_QUEUE: + { + StgBlockingQueue *bq = (StgBlockingQueue *)c; + visit_closure((StgClosure*) bq->bh); + visit_closure((StgClosure*) bq->owner); + visit_closure((StgClosure*) bq->queue); + visit_closure((StgClosure*) bq->link); + break; + } + case THUNK_SELECTOR: + { + StgSelector *s = (StgSelector *)c; + visit_closure(s->selectee); + break; + } + case AP_STACK: + { + StgAP_STACK *ap = (StgAP_STACK *)c; + visit_closure(ap->fun); + visit_stack((StgPtr) ap->payload, (StgPtr) ap->payload + ap->size); + break; + } + case PAP: + { + StgPAP *pap = (StgPAP*) c; + visit_closure(pap->fun); + visit_pap_payload(pap->fun, (StgClosure**) pap->payload, pap->n_args); + break; + } + case AP: + { + StgAP *ap = (StgAP*) c; + visit_closure(ap->fun); + visit_pap_payload(ap->fun, (StgClosure**) ap->payload, ap->n_args); + break; + } + case ARR_WORDS: + visit_bytearray((StgArrBytes *) c); + break; + case MUT_ARR_PTRS_CLEAN: + case MUT_ARR_PTRS_DIRTY: + case MUT_ARR_PTRS_FROZEN_DIRTY: + case MUT_ARR_PTRS_FROZEN_CLEAN: + visit_array((StgMutArrPtrs *) c); + break; + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + visit_small_array((StgSmallMutArrPtrs *) c); + break; + case TSO: + visit_tso((StgTSO *) c); + break; + case STACK: + { + StgStack *stack = (StgStack *) c; + visit_stack(stack->sp, stack->stack + stack->stack_size); + break; + } + case MUT_PRIM: + generic_closure(); + break; + case TREC_CHUNK: + visit_trec_chunk((StgTRecChunk *) c); + break; + case CONTINUATION: + visit_continuation((StgContinuation *) c); + break; + default: + visit_invalid(c); + break; + } +} + +class PredicatedHeapVisitor : HeapVisitor { + bool should_visit(StgClosure *); + + virtual void visit_srt(StgClosure* c) { + if (should_visit(c)) { HeapVisitor::visit_srt(c); } + } + + virtual void visit_closure(TaggedClosurePtr c) { + if (should_visit(c.untag())) { HeapVisitor::visit_closure(c); } + } +}; + +// Collect direct pointers +struct CollectPointers : HeapVisitor { + std::set accum; + bool invalid; + CollectPointers() : accum(), invalid(false) {} + void visit_root(StgClosure *c) { + HeapVisitor::visit_closure(c); + } + void visit_closure(TaggedClosurePtr c) { + accum.insert(c); + } + void visit_invalid(StgClosure *const _c) { invalid = true; } +}; + +static std::set collect_pointers(StgClosure* c) +{ + CollectPointers v; + v.visit_root(c); + return v.accum; +} + + + +struct Error { + StgClosure *closure; + std::string what; + Error(StgClosure *closure, std::string what) : closure(closure), what(what) {} +}; + +static std::ostream& operator<<(std::ostream& os, const Error& err) { + os << std::hex << "0x" << (StgWord) err.closure << ": " << err.what << "\n"; + return os; +} + +class CheckVisitor : HeapVisitor { + std::vector errors; + uint8_t tag; + void visit_constr(StgClosure* c) { + const StgInfoTable *info = get_itbl(c); + if (tag != 0) { + uint8_t constr_tag = info->srt; // zero-based + if (tag != std::min(TAG_MASK, constr_tag+1)) { + errors.push_back(Error(c, "invalid tag")); + } + } + } + + void visit_closure(TaggedClosurePtr c) { } +public: + const std::vector& get_errors() const { return errors; } + + void check_closure(TaggedClosurePtr c) { + tag = c.get_tag(); + HeapVisitor::visit_closure(c); + } +}; + +struct CheckGc { + std::queue queue; + std::unordered_set enqueued; + + void enqueue(TaggedClosurePtr ptr) { + ASSERT(ptr != NULL); + if (!is_enqueued(ptr)) { + queue.push(ptr); + enqueued.insert(ptr); + } + } + + bool finished() { + return queue.empty(); + } + + TaggedClosurePtr pop() { + TaggedClosurePtr p = queue.front(); + queue.pop(); + return p; + } + + bool is_enqueued(TaggedClosurePtr ptr) { + return enqueued.find(ptr) != enqueued.end(); + } +}; + +static void enqueue_root(void *user_data, StgClosure **root) +{ + CheckGc* env = (CheckGc*) user_data; + env->enqueue(*root); +} + +static void enqueue_roots(CheckGc& env) +{ + FOR_EACH_STABLE_NAME(p, if (p->sn_obj) env.enqueue(p->sn_obj);); + markStablePtrTable(enqueue_root, &env); + for (uint32_t n = 0; n < getNumCapabilities(); n++) { + markCapability(enqueue_root, (void*) &env, getCapability(n), false/*mark sparks*/); + } + markCAFs(enqueue_root, &env); + markScheduler(enqueue_root, &env); + + for (StgWeak *w = nonmoving_weak_ptr_list; w != NULL; w = w->link) { + env.enqueue((StgClosure *) w); + } + + for (uint32_t g = 0; g <= N; g++) { + generation *gen = &generations[g]; + for (StgWeak *w = gen->weak_ptr_list; w != NULL; w = RELAXED_LOAD(&w->link)) { + env.enqueue((StgClosure *) w); + } + } +} + +extern "C" { +void check_gc(); +} + +struct NodeName { + const StgClosure *c; + NodeName(const StgClosure *c) : c(c) {} +}; + +static std::ostream& operator<<(std::ostream& os, const NodeName& n) { + os << std::hex << "\"" << n.c << "\"" << std::dec; + return os; +} + +static void dump_heap(std::ofstream& of) +{ + of << "digraph {\n"; + CheckGc env; + enqueue_roots(env); + while (!env.finished()) { + TaggedClosurePtr tagged = env.pop(); + StgClosure* c = tagged.untag(); + NodeName n(c); + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa) { + of << n << " [type=invalid];\n"; + continue; + } + + const StgInfoTable *info = get_itbl(c); + switch (info->type) { + case CONSTR: + case CONSTR_1_0: + case CONSTR_0_1: + case CONSTR_2_0: + case CONSTR_1_1: + case CONSTR_0_2: + case CONSTR_NOCAF: + { + const StgConInfoTable *con_info = get_con_itbl(c); + of << n << " [type=CONSTR constr=\"" << GET_CON_DESC(con_info) << "\"];\n"; + break; + } + case FUN: + case FUN_1_0: + case FUN_0_1: + case FUN_2_0: + case FUN_1_1: + case FUN_0_2: + of << n << " [type=FUN];\n"; + break; + case FUN_STATIC: + of << n << " [type=FUN_STATIC];\n"; + break; + case THUNK: + case THUNK_1_0: + case THUNK_0_1: + case THUNK_1_1: + case THUNK_0_2: + case THUNK_2_0: + of << n << " [type=THUNK];\n"; + break; + case THUNK_STATIC: + of << n << " [type=THUNK_STATIC];\n"; + break; + case THUNK_SELECTOR: + of << n << " [type=THUNK_SEL];\n"; + break; + case BCO: + of << n << " [type=BCO];\n"; + break; + case AP: + of << n << " [type=AP];\n"; + break; + case PAP: + of << n << " [type=PAP];\n"; + break; + case AP_STACK: + of << n << " [type=AP_STACK];\n"; + break; + case IND: + of << n << " [type=IND];\n"; + break; + case IND_STATIC: + of << n << " [type=IND_STATIC];\n"; + break; + case BLOCKING_QUEUE: + of << n << " [type=BLOCKING_QUEUE];\n"; + break; + case BLACKHOLE: + of << n << " [type=BLACKHOLE];\n"; + break; + case MVAR_CLEAN: + case MVAR_DIRTY: + of << n << " [type=MVAR];\n"; + break; + case TVAR: + of << n << " [type=TVAR];\n"; + break; + case ARR_WORDS: + of << n << " [type=ARR_WORDS];\n"; + break; + case MUT_ARR_PTRS_CLEAN: + case MUT_ARR_PTRS_DIRTY: + case MUT_ARR_PTRS_FROZEN_CLEAN: + case MUT_ARR_PTRS_FROZEN_DIRTY: + of << n << " [type=MUT_ARR_PTRS];\n"; + break; + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + of << n << " [type=SMALL_MUT_ARR_PTRS];\n"; + break; + case MUT_VAR_CLEAN: + case MUT_VAR_DIRTY: + of << n << " [type=MUT_VAR];\n"; + break; + case WEAK: + of << n << " [type=WEAK];\n"; + break; + case PRIM: + of << n << " [type=PRIM];\n"; + break; + case MUT_PRIM: + of << n << " [type=MUT_PRIM];\n"; + break; + case TSO: + of << n << " [type=TSO];\n"; + break; + case STACK: + of << n << " [type=STACK];\n"; + break; + case TREC_CHUNK: + of << n << " [type=TREC_CHUNK];\n"; + break; + case WHITEHOLE: + of << n << " [type=WHITEHOLE];\n"; + break; + case COMPACT_NFDATA: + of << n << " [type=COMPACT_NFDATA];\n"; + break; + case CONTINUATION: + of << n << " [type=CONTINUATION];\n"; + break; + default: + of << n << " [type=unknown];\n"; + break; + } + + if (!HEAP_ALLOCED((StgPtr) c)) { + of << n << " [static=yes];\n"; + } else { + bdescr *bd = Bdescr((StgPtr) c); + of << n << " [gen=" << bd->gen_no << "];\n"; + if (bd->flags & BF_EVACUATED) { + of << n << " [evacuated=yes];\n"; + } + if (bd->flags & BF_PINNED) { + of << n << " [pinned=yes];\n"; + } + if (bd->flags & BF_LARGE) { + of << n << " [large=yes];\n"; + } else if (bd->flags & BF_NONMOVING) { + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) c); + nonmoving_block_idx block_idx = nonmovingGetBlockIdx((StgPtr) c); + uint8_t mark = nonmovingGetMark(seg, block_idx); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (c > snapshot_loc) { + of << n << " [nonmoving=yes new=yes mark=" << (StgWord) mark << "];\n"; + } else { + of << n << " [nonmoving=yes mark=" << (StgWord) mark << "];\n"; + } + } else { + of << n << " [moving=yes];\n"; + } + } + for (TaggedClosurePtr p : collect_pointers(c)) { + of << n << " -> " << NodeName(p.untag()) << ";\n"; + env.enqueue(p); + } + } + of << "}\n"; +} + +void dump_heap_to(const char *fname); +void dump_heap_to(const char *fname) +{ + std::ofstream out(fname); + dump_heap(out); + out.flush(); +} + +void check_gc() +{ + CheckGc env; + enqueue_roots(env); + std::vector errors; + + while (!env.finished()) { + TaggedClosurePtr tagged = env.pop(); + StgClosure* c = tagged.untag(); + + { + CheckVisitor check; + check.check_closure(tagged); + for (const Error& e : check.get_errors()) { + errors.push_back(e); + } + } + + for (TaggedClosurePtr p : collect_pointers(c)) { + env.enqueue(p); + } + + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa) { + errors.push_back(Error(c, "is invalid closure")); + continue; + } + + const StgInfoTable *info = get_itbl(c); + if (!HEAP_ALLOCED((StgPtr) c)) { + switch (info->type) { + case THUNK_STATIC: + if (info->srt != 0) { + + } + } + } else { + bdescr *bd = Bdescr((StgPtr) c); + if (bd->gen_no < 1) { + /* nothing to check as we are focused on post nonmoving-GC checking */ + } else if (bd->flags & BF_NONMOVING && bd->flags & BF_LARGE) { + if (bd->flags & BF_NONMOVING_SWEEPING && !(bd->flags & BF_MARKED)) { + errors.push_back(Error(c, "is not marked yet being swept")); + } + } else if (bd->flags & BF_NONMOVING) { + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) c); + nonmoving_block_idx block_idx = nonmovingGetBlockIdx((StgPtr) c); + uint8_t mark = nonmovingGetMark(seg, block_idx); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (bd->flags & BF_NONMOVING_SWEEPING) { + /* in a swept segment */ + if (mark != nonmovingMarkEpoch) { + errors.push_back(Error(c, "is unmarked nonmoving object being swept")); + } + } else if (c < snapshot_loc) { + /* not in a swept segment but in the snapshot */ + if (mark != nonmovingMarkEpoch) { + errors.push_back(Error(c, "is unmarked nonmoving object in the snapshot")); + } + } else { + /* not in the snapshot; nothing to assert */ + } + } else if (bd->flags & BF_LARGE) { + if (! (bd->flags & BF_MARKED)) { + errors.push_back(Error(c, "is unmarked large object")); + } + } else { + if (!(bd->flags & BF_EVACUATED)) { + //errors.push_back(Error(c, "is in from-space block")); + } + } + } + } + + if (!errors.empty()) { + for (auto err : errors) { + std::cerr << err << "\n"; + } + dump_heap_to("heap.dot"); + abort(); + } +} + ===================================== rts/sm/GC.c ===================================== @@ -312,8 +312,6 @@ GarbageCollect (uint32_t collect_gen, CostCentreStack *save_CCS[getNumCapabilities()]; #endif - ACQUIRE_SM_LOCK; - #if defined(RTS_USER_SIGNALS) if (RtsFlags.MiscFlags.install_signal_handlers) { // block signals @@ -589,9 +587,7 @@ GarbageCollect (uint32_t collect_gen, // the current garbage collection, so we invoke LdvCensusForDead(). if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_LDV || RtsFlags.ProfFlags.bioSelector != NULL) { - RELEASE_SM_LOCK; // LdvCensusForDead may need to take the lock LdvCensusForDead(N); - ACQUIRE_SM_LOCK; } #endif @@ -760,7 +756,7 @@ GarbageCollect (uint32_t collect_gen, } else // not compacted { - freeChain(gen->old_blocks); + freeChain_lock(gen->old_blocks); } gen->old_blocks = NULL; @@ -771,7 +767,7 @@ GarbageCollect (uint32_t collect_gen, * collection from large_objects. Any objects left on the * large_objects list are therefore dead, so we free them here. */ - freeChain(gen->large_objects); + freeChain_lock(gen->large_objects); gen->large_objects = gen->scavenged_large_objects; gen->n_large_blocks = gen->n_scavenged_large_blocks; gen->n_large_words = countOccupied(gen->large_objects); @@ -890,7 +886,7 @@ GarbageCollect (uint32_t collect_gen, if (mark_stack_top_bd != NULL) { debugTrace(DEBUG_gc, "mark stack: %d blocks", countBlocks(mark_stack_top_bd)); - freeChain(mark_stack_top_bd); + freeChain_lock(mark_stack_top_bd); } // Free any bitmaps. @@ -942,9 +938,7 @@ GarbageCollect (uint32_t collect_gen, // Start any pending finalizers. Must be after // updateStableTables() and stableUnlock() (see #4221). - RELEASE_SM_LOCK; scheduleFinalizers(cap, dead_weak_ptr_list); - ACQUIRE_SM_LOCK; // check sanity after GC // before resurrectThreads(), because that might overwrite some @@ -959,9 +953,7 @@ GarbageCollect (uint32_t collect_gen, // behind. if (do_heap_census) { debugTrace(DEBUG_sched, "performing heap census"); - RELEASE_SM_LOCK; heapCensus(mut_time); - ACQUIRE_SM_LOCK; } #if defined(TICKY_TICKY) @@ -975,14 +967,14 @@ GarbageCollect (uint32_t collect_gen, #endif // send exceptions to any threads which were about to die - RELEASE_SM_LOCK; resurrectThreads(resurrected_threads); - ACQUIRE_SM_LOCK; // Finally free the deferred mblocks by sorting the deferred free list and // merging it into the actual sorted free list. This needs to happen here so // that the `returnMemoryToOS` call down below can successfully free memory. + ACQUIRE_SM_LOCK; commitMBlockFreeing(); + RELEASE_SM_LOCK; if (major_gc) { W_ need_prealloc, need_live, need, got; @@ -1095,8 +1087,6 @@ GarbageCollect (uint32_t collect_gen, } #endif - RELEASE_SM_LOCK; - SET_GCT(saved_gct); } @@ -1146,7 +1136,7 @@ new_gc_thread (uint32_t n, gc_thread *t) // but can't, because it uses gct which isn't set up at this point. // Hence, allocate a block for todo_bd manually: { - bdescr *bd = allocBlockOnNode(capNoToNumaNode(n)); + bdescr *bd = allocBlockOnNode_lock(capNoToNumaNode(n)); // no lock, locks aren't initialised yet initBdescr(bd, ws->gen, ws->gen->to); bd->flags = BF_EVACUATED; @@ -1605,7 +1595,7 @@ static void stash_mut_list (Capability *cap, uint32_t gen_no) { cap->saved_mut_lists[gen_no] = cap->mut_lists[gen_no]; - RELEASE_STORE(&cap->mut_lists[gen_no], allocBlockOnNode_sync(cap->node)); + RELEASE_STORE(&cap->mut_lists[gen_no], allocBlockOnNode_lock(cap->node)); } /* ---------------------------------------------------------------------------- @@ -1632,9 +1622,9 @@ prepare_collected_gen (generation *gen) // a check for NULL in recordMutable(). for (i = 0; i < getNumCapabilities(); i++) { bdescr *old = RELAXED_LOAD(&getCapability(i)->mut_lists[g]); - freeChain(old); + freeChain_lock(old); - bdescr *new = allocBlockOnNode(capNoToNumaNode(i)); + bdescr *new = allocBlockOnNode_lock(capNoToNumaNode(i)); RELAXED_STORE(&getCapability(i)->mut_lists[g], new); } } @@ -1717,7 +1707,7 @@ prepare_collected_gen (generation *gen) bitmap_size = gen->n_old_blocks * BLOCK_SIZE / BITS_IN(W_); if (bitmap_size > 0) { - bitmap_bdescr = allocGroup((StgWord)BLOCK_ROUND_UP(bitmap_size) + bitmap_bdescr = allocGroup_lock((StgWord)BLOCK_ROUND_UP(bitmap_size) / BLOCK_SIZE); gen->bitmap = bitmap_bdescr; bitmap = bitmap_bdescr->start; ===================================== rts/sm/GC.h ===================================== @@ -13,8 +13,6 @@ #pragma once -#include "HeapAlloc.h" - #include "BeginPrivate.h" void GarbageCollect (uint32_t collect_gen, ===================================== rts/sm/GCUtils.c ===================================== @@ -26,38 +26,15 @@ #include "WSDeque.h" #endif -#if defined(THREADED_RTS) -SpinLock gc_alloc_block_sync; -#endif - static void push_todo_block(bdescr *bd, gen_workspace *ws); -bdescr* allocGroup_sync(uint32_t n) -{ - bdescr *bd; - uint32_t node = capNoToNumaNode(gct->thread_index); - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); - bd = allocGroupOnNode(node,n); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); - return bd; -} - -bdescr* allocGroupOnNode_sync(uint32_t node, uint32_t n) -{ - bdescr *bd; - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); - bd = allocGroupOnNode(node,n); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); - return bd; -} - static uint32_t -allocBlocks_sync(uint32_t n, bdescr **hd) +allocBlocks_lock(uint32_t n, bdescr **hd) { bdescr *bd; uint32_t i; uint32_t node = capNoToNumaNode(gct->thread_index); - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); + ACQUIRE_SM_LOCK; bd = allocLargeChunkOnNode(node,1,n); // NB. allocLargeChunk, rather than allocGroup(n), to allocate in a // fragmentation-friendly way. @@ -70,27 +47,11 @@ allocBlocks_sync(uint32_t n, bdescr **hd) bd[n-1].link = NULL; // We have to hold the lock until we've finished fiddling with the metadata, // otherwise the block allocator can get confused. - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); + RELEASE_SM_LOCK; *hd = bd; return n; } -void -freeChain_sync(bdescr *bd) -{ - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); - freeChain(bd); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); -} - -void -freeGroup_sync(bdescr *bd) -{ - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); - freeGroup(bd); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); -} - /* ----------------------------------------------------------------------------- Workspace utilities -------------------------------------------------------------------------- */ @@ -303,7 +264,7 @@ todo_block_full (uint32_t size, gen_workspace *ws) // object. However, if the object we're copying is // larger than a block, then we might have an empty // block here. - freeGroup_sync(bd); + freeGroup_lock(bd); } else { push_scanned_block(bd, ws); } @@ -343,14 +304,14 @@ alloc_todo_block (gen_workspace *ws, uint32_t size) else { if (size > BLOCK_SIZE_W) { - bd = allocGroup_sync((W_)BLOCK_ROUND_UP(size*sizeof(W_)) + bd = allocGroup_lock((W_)BLOCK_ROUND_UP(size*sizeof(W_)) / BLOCK_SIZE); } else { if (gct->free_blocks) { bd = gct->free_blocks; gct->free_blocks = bd->link; } else { - allocBlocks_sync(16, &bd); + allocBlocks_lock(16, &bd); gct->free_blocks = bd->link; } } ===================================== rts/sm/GCUtils.h ===================================== @@ -17,22 +17,6 @@ #include "BeginPrivate.h" -bdescr* allocGroup_sync(uint32_t n); -bdescr* allocGroupOnNode_sync(uint32_t node, uint32_t n); - -INLINE_HEADER bdescr *allocBlock_sync(void) -{ - return allocGroup_sync(1); -} - -INLINE_HEADER bdescr *allocBlockOnNode_sync(uint32_t node) -{ - return allocGroupOnNode_sync(node,1); -} - -void freeChain_sync(bdescr *bd); -void freeGroup_sync(bdescr *bd); - void push_scanned_block (bdescr *bd, gen_workspace *ws); StgPtr todo_block_full (uint32_t size, gen_workspace *ws); StgPtr alloc_todo_block (gen_workspace *ws, uint32_t size); @@ -62,7 +46,7 @@ recordMutableGen_GC (StgClosure *p, uint32_t gen_no) bd = gct->mut_lists[gen_no]; if (bd->free >= bd->start + BLOCK_SIZE_W) { bdescr *new_bd; - new_bd = allocBlock_sync(); + new_bd = allocBlock_lock(); new_bd->link = bd; bd = new_bd; gct->mut_lists[gen_no] = bd; ===================================== rts/sm/HeapAlloc.h ===================================== @@ -10,6 +10,8 @@ #include "BeginPrivate.h" +#include "Storage.h" + /* ----------------------------------------------------------------------------- The HEAP_ALLOCED() test. @@ -210,9 +212,9 @@ StgBool HEAP_ALLOCED_GC(const void *p) } else { // putting the rest out of line turned out to be a slight // performance improvement: - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); + ACQUIRE_SM_LOCK; // TODO: this may be too expensive b = HEAP_ALLOCED_miss(mblock,p); - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); + RELEASE_SM_LOCK; return b; } } ===================================== rts/sm/MarkStack.h ===================================== @@ -32,7 +32,7 @@ push_mark_stack(StgPtr p) } else { - bd = allocBlock_sync(); + bd = allocBlock_lock(); bd->link = mark_stack_bd; bd->u.back = NULL; mark_stack_bd->u.back = bd; // double-link the new block on ===================================== rts/sm/NonMoving.c ===================================== @@ -597,14 +597,10 @@ static struct NonmovingSegment *nonmovingAllocSegment(uint32_t node) // Nothing in the free list, allocate a new segment... if (ret == NULL) { - // Take gc spinlock: another thread may be scavenging a moving - // generation and call `todo_block_full` - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); bdescr *bd = allocAlignedGroupOnNode(node, NONMOVING_SEGMENT_BLOCKS); // See Note [Live data accounting in nonmoving collector]. oldest_gen->n_blocks += bd->blocks; oldest_gen->n_words += BLOCK_SIZE_W * bd->blocks; - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); for (StgWord32 i = 0; i < bd->blocks; ++i) { initBdescr(&bd[i], oldest_gen, oldest_gen); @@ -667,7 +663,7 @@ static struct NonmovingSegment *pop_active_segment(struct NonmovingAllocator *al } } -/* Allocate a block in the nonmoving heap. Caller must hold SM_MUTEX. sz is in words */ +/* Allocate a block in the nonmoving heap. sz is in words */ GNUC_ATTR_HOT void *nonmovingAllocate(Capability *cap, StgWord sz) { @@ -707,7 +703,9 @@ void *nonmovingAllocate(Capability *cap, StgWord sz) // there are no active segments, allocate new segment if (new_current == NULL) { + ACQUIRE_SM_LOCK; new_current = nonmovingAllocSegment(cap->node); + RELEASE_SM_LOCK; nonmovingInitSegment(new_current, log_block_size); } @@ -790,14 +788,13 @@ void nonmovingExit(void) /* * Assumes that no garbage collector or mutator threads are running to safely * resize the nonmoving_allocators. - * - * Must hold sm_mutex. */ void nonmovingAddCapabilities(uint32_t new_n_caps) { unsigned int old_n_caps = nonmovingHeap.n_caps; struct NonmovingAllocator **allocs = nonmovingHeap.allocators; + ACQUIRE_SM_LOCK; for (unsigned int i = 0; i < NONMOVING_ALLOCA_CNT; i++) { struct NonmovingAllocator *old = allocs[i]; allocs[i] = alloc_nonmoving_allocator(new_n_caps); @@ -819,6 +816,7 @@ void nonmovingAddCapabilities(uint32_t new_n_caps) } } nonmovingHeap.n_caps = new_n_caps; + RELEASE_SM_LOCK; } void nonmovingClearBitmap(struct NonmovingSegment *seg) @@ -1238,6 +1236,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) && defined(NONCONCURRENT_SWEEP) #if defined(DEBUG) + check_gc(); checkNonmovingHeap(&nonmovingHeap); checkSanity(true, true); #endif ===================================== rts/sm/NonMovingMark.c ===================================== @@ -295,10 +295,8 @@ static void nonmovingAddUpdRemSetBlocks_lock(MarkQueue *rset) nonmovingAddUpdRemSetBlocks_(rset); // Reset the state of the remembered set. - ACQUIRE_SM_LOCK; init_mark_queue_(rset); rset->is_upd_rem_set = true; - RELEASE_SM_LOCK; } /* @@ -472,9 +470,7 @@ push (MarkQueue *q, const MarkQueueEnt *ent) } /* A variant of push to be used by the minor GC when it encounters a reference - * to an object in the non-moving heap. In contrast to the other push - * operations this uses the gc_alloc_block_sync spinlock instead of the - * SM_LOCK to allocate new blocks in the event that the mark queue is full. + * to an object in the non-moving heap. */ void markQueuePushClosureGC (MarkQueue *q, StgClosure *p) @@ -495,13 +491,13 @@ markQueuePushClosureGC (MarkQueue *q, StgClosure *p) if (q->top->head == MARK_QUEUE_BLOCK_ENTRIES) { // Yes, this block is full. // allocate a fresh block. - ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); + ACQUIRE_SM_LOCK; bdescr *bd = allocGroup(MARK_QUEUE_BLOCKS); bd->link = q->blocks; q->blocks = bd; q->top = (MarkQueueBlock *) bd->start; q->top->head = 0; - RELEASE_SPIN_LOCK(&gc_alloc_block_sync); + RELEASE_SM_LOCK; } MarkQueueEnt ent = { @@ -932,7 +928,7 @@ static MarkQueueEnt markQueuePop (MarkQueue *q) /* Must hold sm_mutex. */ static void init_mark_queue_ (MarkQueue *queue) { - bdescr *bd = allocGroup(MARK_QUEUE_BLOCKS); + bdescr *bd = allocGroup_lock(MARK_QUEUE_BLOCKS); ASSERT(queue->blocks == NULL); queue->blocks = bd; queue->top = (MarkQueueBlock *) bd->start; @@ -943,14 +939,12 @@ static void init_mark_queue_ (MarkQueue *queue) #endif } -/* Must hold sm_mutex. */ void initMarkQueue (MarkQueue *queue) { init_mark_queue_(queue); queue->is_upd_rem_set = false; } -/* Must hold sm_mutex. */ void nonmovingInitUpdRemSet (UpdRemSet *rset) { init_mark_queue_(&rset->queue); @@ -1610,7 +1604,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) // selectee unreachable. However, we must mark the selectee regardless // to satisfy the snapshot invariant. PUSH_FIELD(sel, selectee); - nonmoving_eval_thunk_selector(queue, sel, origin); + //nonmoving_eval_thunk_selector(queue, sel, origin); break; } ===================================== rts/sm/NonMovingMark.h ===================================== @@ -9,10 +9,11 @@ #pragma once #include "Task.h" -#include "NonMoving.h" #include "BeginPrivate.h" +struct NonMovingHeap; + enum EntryType { NULL_ENTRY = 0, MARK_CLOSURE = 1, @@ -63,7 +64,7 @@ INLINE_HEADER enum EntryType nonmovingMarkQueueEntryType(MarkQueueEnt *ent) { uintptr_t tag = (uintptr_t) ent->null_entry.p & TAG_MASK; ASSERT(tag <= MARK_ARRAY); - return tag; + return (enum EntryType) tag; } typedef struct { @@ -155,7 +156,7 @@ void markQueueAddRoot(MarkQueue* q, StgClosure** root); void initMarkQueue(MarkQueue *queue); void freeMarkQueue(MarkQueue *queue); -void nonmovingMark(struct MarkQueue_ *restrict queue); +void nonmovingMark(struct MarkQueue_ *__restrict__ queue); void nonmovingMarkWeakPtrList(struct MarkQueue_ *queue); bool nonmovingTidyWeaks(struct MarkQueue_ *queue); ===================================== rts/sm/NonMovingShortcut.c ===================================== @@ -10,6 +10,7 @@ #include "Rts.h" #include "GC.h" #include "SMPClosureOps.h" +#include "NonMoving.h" #include "NonMovingMark.h" #include "NonMovingShortcut.h" #include "Printer.h" ===================================== rts/sm/Sanity.h ===================================== @@ -19,6 +19,8 @@ # define MAX_SLOTS 100000 # endif +struct NonmovingHeap; + /* debugging routines */ void checkSanity ( bool after_gc, bool major_gc ); void checkNurserySanity ( nursery *nursery ); ===================================== rts/sm/Scav.c ===================================== @@ -1730,7 +1730,7 @@ scavenge_capability_mut_lists (Capability *cap) if (RtsFlags.GcFlags.useNonmoving && major_gc) { uint32_t g = oldest_gen->no; scavenge_mutable_list(cap->saved_mut_lists[g], oldest_gen); - freeChain_sync(cap->saved_mut_lists[g]); + freeChain_lock(cap->saved_mut_lists[g]); cap->saved_mut_lists[g] = NULL; return; } @@ -1743,7 +1743,7 @@ scavenge_capability_mut_lists (Capability *cap) */ for (uint32_t g = RtsFlags.GcFlags.generations-1; g > N; g--) { scavenge_mutable_list(cap->saved_mut_lists[g], &generations[g]); - freeChain_sync(cap->saved_mut_lists[g]); + freeChain_lock(cap->saved_mut_lists[g]); cap->saved_mut_lists[g] = NULL; } } ===================================== rts/sm/Storage.c ===================================== @@ -193,14 +193,13 @@ initStorage (void) initMutex(&sm_mutex); #endif - ACQUIRE_SM_LOCK; - /* allocate generation info array */ generations = (generation *)stgMallocBytes(RtsFlags.GcFlags.generations * sizeof(struct generation_), "initStorage: gens"); /* Initialise all generations */ + ACQUIRE_SM_LOCK; for(g = 0; g < RtsFlags.GcFlags.generations; g++) { initGeneration(&generations[g], g); } @@ -214,16 +213,11 @@ initStorage (void) generations[g].to = &generations[g+1]; } oldest_gen->to = oldest_gen; + RELEASE_SM_LOCK; // Nonmoving heap uses oldest_gen so initialize it after initializing oldest_gen nonmovingInit(); -#if defined(THREADED_RTS) - // nonmovingAddCapabilities allocates segments, which requires taking the gc - // sync lock, so initialize it before nonmovingAddCapabilities - initSpinLock(&gc_alloc_block_sync); -#endif - if (RtsFlags.GcFlags.useNonmoving) nonmovingAddCapabilities(getNumCapabilities()); @@ -261,8 +255,6 @@ initStorage (void) IF_DEBUG(gc, statDescribeGens()); - RELEASE_SM_LOCK; - traceInitEvent(traceHeapInfo); } @@ -314,12 +306,14 @@ void storageAddCapabilities (uint32_t from, uint32_t to) assignNurseriesToCapabilities(from,to); // allocate a block for each mut list + ACQUIRE_SM_LOCK; for (n = from; n < to; n++) { for (g = 1; g < RtsFlags.GcFlags.generations; g++) { getCapability(n)->mut_lists[g] = allocBlockOnNode(capNoToNumaNode(n)); } } + RELEASE_SM_LOCK; // Initialize NonmovingAllocators and UpdRemSets if (RtsFlags.GcFlags.useNonmoving) { @@ -565,9 +559,7 @@ lockCAF (StgRegTable *reg, StgIndStatic *caf) // Allocate the blackhole indirection closure if (RtsFlags.GcFlags.useNonmoving) { // See Note [Static objects under the nonmoving collector]. - ACQUIRE_SM_LOCK; bh = (StgInd *)nonmovingAllocate(cap, sizeofW(*bh)); - RELEASE_SM_LOCK; recordMutableCap((StgClosure*)bh, regTableToCapability(reg), oldest_gen->no); } else { @@ -725,6 +717,7 @@ allocNursery (uint32_t node, bdescr *tail, W_ blocks) // automatic prefetching works across nursery blocks. This is a // tiny optimisation (~0.5%), but it's free. + ACQUIRE_SM_LOCK; while (blocks > 0) { n = stg_min(BLOCKS_PER_MBLOCK, blocks); // allocLargeChunk will prefer large chunks, but will pick up @@ -760,6 +753,7 @@ allocNursery (uint32_t node, bdescr *tail, W_ blocks) tail = &bd[0]; } + RELEASE_SM_LOCK; return &bd[0]; } @@ -879,7 +873,7 @@ resizeNurseriesEach (W_ blocks) next_bd = bd->link; next_bd->u.back = NULL; nursery_blocks -= bd->blocks; // might be a large block - freeGroup(bd); + freeGroup_lock(bd); bd = next_bd; } nursery->blocks = bd; @@ -1300,9 +1294,7 @@ allocatePinned (Capability *cap, W_ n /*words*/, W_ alignment /*bytes*/, W_ alig if (bd == NULL) { // The pinned block list is empty: allocate a fresh block (we can't fail // here). - ACQUIRE_SM_LOCK; bd = allocNursery(cap->node, NULL, PINNED_EMPTY_SIZE); - RELEASE_SM_LOCK; } // Bump up the nursery pointer to avoid the pathological situation @@ -1405,8 +1397,6 @@ allocatePinned (Capability *cap, W_ n /*words*/, W_ alignment /*bytes*/, W_ alig void dirty_MUT_VAR(StgRegTable *reg, StgMutVar *mvar, StgClosure *old) { - ASSERT(RELAXED_LOAD(&mvar->header.info) == &stg_MUT_VAR_CLEAN_info); - Capability *cap = regTableToCapability(reg); // No barrier required here as no other heap object fields are read. See // Note [Heap memory barriers] in SMP.h. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b4207f32fd4c0a6995e2be1a59bf2b3eff53d51...14f1045d178417cd7d508c3b72cd70ce5b681d1a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b4207f32fd4c0a6995e2be1a59bf2b3eff53d51...14f1045d178417cd7d508c3b72cd70ce5b681d1a You're receiving 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 Dec 6 12:34:09 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 06 Dec 2022 07:34:09 -0500 Subject: [Git][ghc/ghc][wip/T22264] 3 commits: CheckGC Message-ID: <638f36c197f94_17512e52be8133011a@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC Commits: 5e6b7dbb by Ben Gamari at 2022-12-06T07:33:55-05:00 CheckGC - - - - - 16192f22 by Ben Gamari at 2022-12-06T07:33:55-05:00 setNumCapabilities - - - - - 11038286 by Ben Gamari at 2022-12-06T07:33:55-05:00 nonmoving: Disable shortcutting - - - - - 7 changed files: - libraries/base/GHC/Conc/Sync.hs - rts/Schedule.c - rts/include/rts/Threads.h - rts/rts.cabal.in - + rts/sm/CheckGc.cpp - rts/sm/NonMoving.c - rts/sm/NonMovingMark.c Changes: ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -380,10 +380,15 @@ to avoid contention with other processes in the machine. setNumCapabilities :: Int -> IO () setNumCapabilities i | i <= 0 = failIO $ "setNumCapabilities: Capability count ("++show i++") must be positive" - | otherwise = c_setNumCapabilities (fromIntegral i) + | otherwise = do + ret <- c_setNumCapabilities (fromIntegral i) + case ret of + 0 -> return () + 1 -> yield >> setNumCapabilities i + _ -> failIO $ "setNumCapabilities: Unknown result" foreign import ccall safe "setNumCapabilities" - c_setNumCapabilities :: CUInt -> IO () + c_setNumCapabilities :: CUInt -> IO CInt -- | Returns the number of CPUs that the machine has -- ===================================== rts/Schedule.c ===================================== @@ -2225,9 +2225,12 @@ forkProcess(HsStablePtr *entry * Finally we release the Capabilities we are holding, and start * worker Tasks on the new Capabilities we created. * + * One wrinkle here is that we must also ensure that we don't change the + * capability count while the nonmoving mark thread is active. + * * ------------------------------------------------------------------------- */ -void +int setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) { #if !defined(THREADED_RTS) @@ -2247,11 +2250,15 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) Capability *old_capabilities = NULL; uint32_t old_n_capabilities = n_capabilities; + if (RELAXED_LOAD(&concurrent_coll_running)) { + return 1; + } + if (new_n_capabilities == enabled_capabilities) { - return; + return 0; } else if (new_n_capabilities <= 0) { errorBelch("setNumCapabilities: Capability count must be positive"); - return; + return 1; } @@ -2353,6 +2360,7 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) rts_unlock(cap); + return 0; #endif // THREADED_RTS } ===================================== rts/include/rts/Threads.h ===================================== @@ -85,4 +85,4 @@ extern Capability MainCapability; // Change the number of capabilities (only supports increasing the // current value at the moment). // -extern void setNumCapabilities (uint32_t new_); +extern int setNumCapabilities (uint32_t new_); ===================================== rts/rts.cabal.in ===================================== @@ -619,6 +619,7 @@ library linker/elf_tlsgd.c linker/elf_util.c sm/BlockAlloc.c + sm/CheckGc.cpp sm/CNF.c sm/Compact.c sm/Evac.c ===================================== rts/sm/CheckGc.cpp ===================================== @@ -0,0 +1,971 @@ +extern "C" { +#include "Rts.h" +#include "StableName.h" /* for FOR_EACH_STABLE_NAME */ +#include "StablePtr.h" /* for markStablePtrTable */ +#include "Capability.h" +#include "HeapAlloc.h" +#include "STM.h" +} + +#include +#include +#include +#include +#include +#include + +class TaggedClosurePtr { + StgClosure *ptr; +public: + TaggedClosurePtr(StgClosure* ptr) : ptr(ptr) {} + TaggedClosurePtr(StgClosure* ptr, uint8_t tag) : TaggedClosurePtr(TAG_CLOSURE(tag, ptr)) {} + + StgClosure *get_tagged() const { + return ptr; + } + StgClosure *untag() const { + return UNTAG_CLOSURE(ptr); + } + uint8_t get_tag() const { + return (StgWord) ptr & TAG_MASK; + } + + //inline StgClosure& operator->() { return *untag(); } + + friend inline bool operator==(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { + return lhs.ptr == rhs.ptr; + } + friend inline bool operator!=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs == rhs); } + friend inline bool operator< (const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { + return lhs.ptr < rhs.ptr; + } + friend inline bool operator> (const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return rhs < lhs; } + friend inline bool operator<=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs > rhs); } + friend inline bool operator>=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs < rhs); } +}; + +template<> +struct std::hash { + std::size_t operator()(TaggedClosurePtr const& p) const noexcept { + return std::hash{}(p.get_tagged()); + } +}; + +class HeapVisitor { +public: + // Visit an SRT + virtual void visit_srt(StgClosure* c); + + // Visit a normal closure + virtual void visit_closure(TaggedClosurePtr c); + + virtual void visit_thunk(StgThunk *thunk, size_t n_ptrs); + virtual void visit_fun(StgClosure *constr, size_t n_ptrs); + virtual void visit_constr(StgClosure *constr, size_t n_ptrs); + virtual void visit_array(StgMutArrPtrs *arr); + virtual void visit_small_array(StgSmallMutArrPtrs *arr); + virtual void visit_bytearray(StgArrBytes* arr); + + virtual void visit_stack(StgPtr sp, StgPtr end); + virtual void visit_tso(StgTSO* tso); + virtual void visit_weak(StgWeak* w); + virtual void visit_mvar(StgMVar* mvar); + virtual void visit_tvar(StgTVar* tvar); + virtual void visit_trec_header(StgTRecHeader *trec); + virtual void visit_trec_chunk(StgTRecChunk* tc); + virtual void visit_continuation(StgContinuation* tc); + + virtual void visit_small_bitmap(StgClosure *const *payload, StgWord bitmap, StgWord size); + virtual void visit_large_bitmap(StgClosure *const *payload, const StgLargeBitmap *bitmap, StgWord size); + void visit_pap_payload(StgClosure *fun, StgClosure **payload, StgWord n_args); + + virtual void visit_invalid(StgClosure *const c); +}; + +void HeapVisitor::visit_thunk(StgThunk *thunk, size_t n_ptrs) +{ + const StgInfoTable *info = get_itbl((StgClosure *) thunk); + const StgThunkInfoTable *thunk_info = itbl_to_thunk_itbl(info); + if (thunk_info->i.srt) { + StgClosure *srt = (StgClosure*) GET_SRT(thunk_info); + visit_srt(srt); + }; + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(thunk->payload[i]); + } +} + +void HeapVisitor::visit_fun(StgClosure *fun, size_t n_ptrs) +{ + const StgInfoTable *info = get_itbl(fun); + const StgFunInfoTable *fun_info = itbl_to_fun_itbl(info); + if (fun_info->i.srt) { + StgClosure *srt = (StgClosure*) GET_SRT(fun_info); + visit_srt(srt); + }; + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(fun->payload[i]); + } +} + +void HeapVisitor::visit_constr(StgClosure *constr, size_t n_ptrs) +{ + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(constr->payload[i]); + } +} + +void HeapVisitor::visit_srt(StgClosure* c) +{ + visit_closure(c); +} + +void HeapVisitor::visit_invalid(StgClosure *const _c) +{ + abort(); +} + +void HeapVisitor::visit_weak(StgWeak* w) +{ + visit_closure(w->key); + visit_closure(w->value); + visit_closure(w->finalizer); + visit_closure(w->cfinalizers); +} + +void HeapVisitor::visit_mvar(StgMVar* mvar) +{ + visit_closure((StgClosure*) mvar->head); + visit_closure((StgClosure*) mvar->tail); + visit_closure(mvar->value); +} + +void HeapVisitor::visit_small_array(StgSmallMutArrPtrs *arr) +{ + for (StgWord i=0; i < arr->ptrs; i++) { + visit_closure(arr->payload[i]); + } +} + +void HeapVisitor::visit_array(StgMutArrPtrs *arr) +{ + for (StgWord i=0; i < arr->ptrs; i++) { + visit_closure(arr->payload[i]); + } +} + +void HeapVisitor::visit_bytearray(StgArrBytes* _arr) { } + +void HeapVisitor::visit_tso(StgTSO *tso) +{ + if (tso->bound != NULL) { + + visit_closure((StgClosure*) tso->bound->tso); + } + if (tso->label != NULL) { + visit_closure({(StgClosure*) tso->label}); + } + visit_closure((StgClosure*) tso->blocked_exceptions); + visit_closure((StgClosure*) tso->bq); + visit_closure((StgClosure*) tso->stackobj); + visit_closure((StgClosure*) tso->_link); + visit_trec_header(tso->trec); + + switch (tso->why_blocked) { + case BlockedOnMVar: + case BlockedOnMVarRead: + case BlockedOnBlackHole: + case BlockedOnMsgThrowTo: + case NotBlocked: + visit_closure(tso->block_info.closure); + break; + default: + break; + } +} + +void HeapVisitor::visit_continuation(StgContinuation *cont) +{ + visit_stack(cont->stack, cont->stack + cont->stack_size); +} + +void HeapVisitor::visit_tvar(StgTVar *tvar) +{ + visit_closure(tvar->current_value); + visit_closure((StgClosure*) tvar->first_watch_queue_entry); +} + +void HeapVisitor::visit_trec_header(StgTRecHeader *trec) +{ + if (trec == NO_TREC) { + return; + } + visit_trec_chunk(trec->current_chunk); + visit_closure((StgClosure*) trec->enclosing_trec); +} + +void HeapVisitor::visit_trec_chunk(StgTRecChunk *tc) +{ + if (tc->prev_chunk != END_STM_CHUNK_LIST) { + visit_closure((StgClosure*) tc->prev_chunk); + } + + for (uint32_t i = 0; i < tc->next_entry_idx; i++) { + TRecEntry *e = &tc->entries[i]; + visit_closure((StgClosure*)e->tvar); + visit_closure(e->expected_value); + visit_closure(e->new_value); + } +} + +void HeapVisitor::visit_stack(StgPtr p, StgPtr stack_end) +{ + while (p < stack_end) { + const StgRetInfoTable* info = get_ret_itbl((StgClosure *) p); + + auto add_srt_ptrs = [&] () { + if (info->i.srt) { + StgClosure *srt = (StgClosure*)GET_SRT(info); + visit_srt(srt); + } + }; + + switch (info->i.type) { + + case UPDATE_FRAME: + { + StgUpdateFrame *frame = (StgUpdateFrame *)p; + visit_closure(frame->updatee); + p += sizeofW(StgUpdateFrame); + continue; + } + + case CATCH_STM_FRAME: + case CATCH_RETRY_FRAME: + case ATOMICALLY_FRAME: + case UNDERFLOW_FRAME: + case STOP_FRAME: + case CATCH_FRAME: + case RET_SMALL: + { + StgWord bitmap = BITMAP_BITS(info->i.layout.bitmap); + StgWord size = BITMAP_SIZE(info->i.layout.bitmap); + // NOTE: the payload starts immediately after the info-ptr, we + // don't have an StgHeader in the same sense as a heap closure. + p++; + visit_small_bitmap((StgClosure**) p, bitmap, size); + p += size; + add_srt_ptrs(); + continue; + } + + case RET_BCO: + { + p++; + StgBCO *bco = (StgBCO *)*p; + visit_closure((StgClosure *) bco); + p++; + StgWord size = BCO_BITMAP_SIZE(bco); + visit_large_bitmap((StgClosure**) p, BCO_BITMAP(bco), size); + p += size; + continue; + } + + case RET_BIG: + { + StgWord size = GET_LARGE_BITMAP(&info->i)->size; + p++; + visit_large_bitmap((StgClosure**) p, GET_LARGE_BITMAP(&info->i), size); + p += size; + // and don't forget to follow the SRT + add_srt_ptrs(); + break; + } + + case RET_FUN: + { + StgRetFun *ret_fun = (StgRetFun *)p; + visit_closure(ret_fun->fun); + + const StgFunInfoTable *fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + switch (fun_info->f.fun_type) { + case ARG_GEN: + { + StgWord bitmap = BITMAP_BITS(fun_info->f.b.bitmap); + StgWord size = BITMAP_SIZE(fun_info->f.b.bitmap); + visit_small_bitmap(ret_fun->payload, bitmap, size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + case ARG_GEN_BIG: + { + StgWord size = GET_FUN_LARGE_BITMAP(fun_info)->size; + visit_large_bitmap(ret_fun->payload, GET_FUN_LARGE_BITMAP(fun_info), size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + default: + { + StgWord bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); + StgWord size = BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type]); + visit_small_bitmap(ret_fun->payload, bitmap, size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + } + add_srt_ptrs(); + break; + } + default: + abort(); + } + } +} + +void HeapVisitor::visit_small_bitmap( + StgClosure *const *payload, + StgWord bitmap, + StgWord size) +{ + while (size > 0) { + if ((bitmap & 1) == 0) { + visit_closure(*payload); + } + payload++; + bitmap = bitmap >> 1; + size--; + } +} + +void HeapVisitor::visit_large_bitmap( + StgClosure *const * payload, + const StgLargeBitmap *large_bitmap, + StgWord size) +{ + // Bitmap may have more bits than `size` when scavenging PAP payloads. See + // comments around StgPAP. + ASSERT(large_bitmap->size >= size); + + uint32_t b = 0; + for (uint32_t i = 0; i < size; b++) { + StgWord bitmap = large_bitmap->bitmap[b]; + uint32_t j = stg_min(size-i, BITS_IN(W_)); + i += j; + for (; j > 0; j--, payload++) { + if ((bitmap & 1) == 0) { + visit_closure(*payload); + } + bitmap = bitmap >> 1; + } + } +} + +void HeapVisitor::visit_pap_payload( + StgClosure *fun, + StgClosure **payload, + StgWord n_args) +{ + fun = UNTAG_CLOSURE(fun); + const StgFunInfoTable *fun_info = get_fun_itbl(fun); + ASSERT(fun_info->i.type != PAP); + switch (fun_info->f.fun_type) { + case ARG_GEN: + visit_small_bitmap(payload, BITMAP_BITS(fun_info->f.b.bitmap), n_args); + break; + case ARG_GEN_BIG: + visit_large_bitmap(payload, GET_FUN_LARGE_BITMAP(fun_info), n_args); + break; + case ARG_BCO: + visit_large_bitmap(payload, BCO_BITMAP(fun), n_args); + break; + default: + { + StgWord bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); + visit_small_bitmap(payload, bitmap, n_args); + } + } +} + +void HeapVisitor::visit_closure(TaggedClosurePtr tagged) +{ + StgClosure *c = tagged.untag(); + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa || !LOOKS_LIKE_CLOSURE_PTR(c)) { + visit_invalid(c); + return; + } + + const StgInfoTable *info = get_itbl(c); + auto generic_closure = [&] () { + for (StgClosure **p = &c->payload[0]; p < &c->payload[info->layout.payload.ptrs]; p++) { + visit_closure(*p); + } + }; + + switch (info->type) { + + case MVAR_CLEAN: + case MVAR_DIRTY: + visit_mvar((StgMVar *) c); + break; + case TVAR: + visit_tvar((StgTVar *) c); + break; + + case IND: + case IND_STATIC: + visit_closure(((StgInd *) c)->indirectee); + break; + + case THUNK_0_1: + case THUNK_0_2: + visit_thunk((StgThunk*) c, 0); + break; + case THUNK_1_1: + case THUNK_1_0: + visit_thunk((StgThunk*) c, 1); + break; + case THUNK_2_0: + visit_thunk((StgThunk*) c, 2); + break; + case THUNK: + visit_thunk((StgThunk*) c, info->layout.payload.ptrs); + break; + case THUNK_STATIC: + visit_thunk((StgThunk*) c, 0); + break; + + case FUN_1_0: + visit_fun(c, 1); + break; + case FUN_0_1: + case FUN_0_2: + visit_fun(c, 0); + break; + case FUN_1_1: + visit_fun(c, 1); + break; + case FUN_2_0: + visit_fun(c, 2); + break; + case FUN: + case FUN_STATIC: + visit_fun(c, info->layout.payload.ptrs); + break; + + case CONSTR_0_1: + case CONSTR_0_2: + visit_constr(c, 0); + break; + case CONSTR_1_0: + case CONSTR_1_1: + visit_constr(c, 1); + break; + case CONSTR_2_0: + visit_constr(c, 2); + break; + case CONSTR: + case CONSTR_NOCAF: + visit_constr(c, info->layout.payload.ptrs); + break; + + case PRIM: + generic_closure(); + break; + case WEAK: + visit_weak((StgWeak*) c); + break; + case BCO: + { + StgBCO *bco = (StgBCO *)c; + visit_closure((StgClosure*) bco->instrs); + visit_closure((StgClosure*) bco->literals); + visit_closure((StgClosure*) bco->ptrs); + break; + } + case BLACKHOLE: + { + StgInd *ind = (StgInd*) c; + visit_closure(ind->indirectee); + break; + } + case MUT_VAR_CLEAN: + case MUT_VAR_DIRTY: + { + StgMutVar *mv = (StgMutVar*) c; + visit_closure(mv->var); + break; + } + case BLOCKING_QUEUE: + { + StgBlockingQueue *bq = (StgBlockingQueue *)c; + visit_closure((StgClosure*) bq->bh); + visit_closure((StgClosure*) bq->owner); + visit_closure((StgClosure*) bq->queue); + visit_closure((StgClosure*) bq->link); + break; + } + case THUNK_SELECTOR: + { + StgSelector *s = (StgSelector *)c; + visit_closure(s->selectee); + break; + } + case AP_STACK: + { + StgAP_STACK *ap = (StgAP_STACK *)c; + visit_closure(ap->fun); + visit_stack((StgPtr) ap->payload, (StgPtr) ap->payload + ap->size); + break; + } + case PAP: + { + StgPAP *pap = (StgPAP*) c; + visit_closure(pap->fun); + visit_pap_payload(pap->fun, (StgClosure**) pap->payload, pap->n_args); + break; + } + case AP: + { + StgAP *ap = (StgAP*) c; + visit_closure(ap->fun); + visit_pap_payload(ap->fun, (StgClosure**) ap->payload, ap->n_args); + break; + } + case ARR_WORDS: + visit_bytearray((StgArrBytes *) c); + break; + case MUT_ARR_PTRS_CLEAN: + case MUT_ARR_PTRS_DIRTY: + case MUT_ARR_PTRS_FROZEN_DIRTY: + case MUT_ARR_PTRS_FROZEN_CLEAN: + visit_array((StgMutArrPtrs *) c); + break; + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + visit_small_array((StgSmallMutArrPtrs *) c); + break; + case TSO: + visit_tso((StgTSO *) c); + break; + case STACK: + { + StgStack *stack = (StgStack *) c; + visit_stack(stack->sp, stack->stack + stack->stack_size); + break; + } + case MUT_PRIM: + generic_closure(); + break; + case TREC_CHUNK: + visit_trec_chunk((StgTRecChunk *) c); + break; + case CONTINUATION: + visit_continuation((StgContinuation *) c); + break; + default: + visit_invalid(c); + break; + } +} + +class PredicatedHeapVisitor : HeapVisitor { + bool should_visit(StgClosure *); + + virtual void visit_srt(StgClosure* c) { + if (should_visit(c)) { HeapVisitor::visit_srt(c); } + } + + virtual void visit_closure(TaggedClosurePtr c) { + if (should_visit(c.untag())) { HeapVisitor::visit_closure(c); } + } +}; + +// Collect direct pointers +struct CollectPointers : HeapVisitor { + std::set accum; + bool invalid; + CollectPointers() : accum(), invalid(false) {} + void visit_root(StgClosure *c) { + HeapVisitor::visit_closure(c); + } + void visit_closure(TaggedClosurePtr c) { + accum.insert(c); + } + void visit_invalid(StgClosure *const _c) { invalid = true; } +}; + +static std::set collect_pointers(StgClosure* c) +{ + CollectPointers v; + v.visit_root(c); + return v.accum; +} + + + +struct Error { + StgClosure *closure; + std::string what; + Error(StgClosure *closure, std::string what) : closure(closure), what(what) {} +}; + +static std::ostream& operator<<(std::ostream& os, const Error& err) { + os << std::hex << "0x" << (StgWord) err.closure << ": " << err.what << "\n"; + return os; +} + +class CheckVisitor : HeapVisitor { + std::vector errors; + uint8_t tag; + void visit_constr(StgClosure* c) { + const StgInfoTable *info = get_itbl(c); + if (tag != 0) { + uint8_t constr_tag = info->srt; // zero-based + if (tag != std::min(TAG_MASK, constr_tag+1)) { + errors.push_back(Error(c, "invalid tag")); + } + } + } + + void visit_closure(TaggedClosurePtr c) { } +public: + const std::vector& get_errors() const { return errors; } + + void check_closure(TaggedClosurePtr c) { + tag = c.get_tag(); + HeapVisitor::visit_closure(c); + } +}; + +struct CheckGc { + std::queue queue; + std::unordered_set enqueued; + + void enqueue(TaggedClosurePtr ptr) { + ASSERT(ptr != NULL); + if (!is_enqueued(ptr)) { + queue.push(ptr); + enqueued.insert(ptr); + } + } + + bool finished() { + return queue.empty(); + } + + TaggedClosurePtr pop() { + TaggedClosurePtr p = queue.front(); + queue.pop(); + return p; + } + + bool is_enqueued(TaggedClosurePtr ptr) { + return enqueued.find(ptr) != enqueued.end(); + } +}; + +static void enqueue_root(void *user_data, StgClosure **root) +{ + CheckGc* env = (CheckGc*) user_data; + env->enqueue(*root); +} + +static void enqueue_roots(CheckGc& env) +{ + FOR_EACH_STABLE_NAME(p, if (p->sn_obj) env.enqueue(p->sn_obj);); + markStablePtrTable(enqueue_root, &env); + for (uint32_t n = 0; n < getNumCapabilities(); n++) { + markCapability(enqueue_root, (void*) &env, getCapability(n), false/*mark sparks*/); + } + markCAFs(enqueue_root, &env); + + for (StgWeak *w = nonmoving_weak_ptr_list; w != NULL; w = w->link) { + env.enqueue((StgClosure *) w); + } + + for (uint32_t g = 0; g <= N; g++) { + generation *gen = &generations[g]; + for (StgWeak *w = gen->weak_ptr_list; w != NULL; w = RELAXED_LOAD(&w->link)) { + env.enqueue((StgClosure *) w); + } + } +} + +extern "C" { +void check_gc(); +} + +struct NodeName { + const StgClosure *c; + NodeName(const StgClosure *c) : c(c) {} +}; + +static std::ostream& operator<<(std::ostream& os, const NodeName& n) { + os << std::hex << "\"" << n.c << "\"" << std::dec; + return os; +} + +static void dump_heap(std::ofstream& of) +{ + of << "digraph {\n"; + CheckGc env; + enqueue_roots(env); + while (!env.finished()) { + TaggedClosurePtr tagged = env.pop(); + StgClosure* c = tagged.untag(); + NodeName n(c); + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa) { + of << n << " [type=invalid];\n"; + continue; + } + + const StgInfoTable *info = get_itbl(c); + switch (info->type) { + case CONSTR: + case CONSTR_1_0: + case CONSTR_0_1: + case CONSTR_2_0: + case CONSTR_1_1: + case CONSTR_0_2: + case CONSTR_NOCAF: + { + const StgConInfoTable *con_info = get_con_itbl(c); + of << n << " [type=CONSTR constr=\"" << GET_CON_DESC(con_info) << "\"];\n"; + break; + } + case FUN: + case FUN_1_0: + case FUN_0_1: + case FUN_2_0: + case FUN_1_1: + case FUN_0_2: + of << n << " [type=FUN];\n"; + break; + case FUN_STATIC: + of << n << " [type=FUN_STATIC];\n"; + break; + case THUNK: + case THUNK_1_0: + case THUNK_0_1: + case THUNK_1_1: + case THUNK_0_2: + case THUNK_2_0: + of << n << " [type=THUNK];\n"; + break; + case THUNK_STATIC: + of << n << " [type=THUNK_STATIC];\n"; + break; + case THUNK_SELECTOR: + of << n << " [type=THUNK_SEL];\n"; + break; + case BCO: + of << n << " [type=BCO];\n"; + break; + case AP: + of << n << " [type=AP];\n"; + break; + case PAP: + of << n << " [type=PAP];\n"; + break; + case AP_STACK: + of << n << " [type=AP_STACK];\n"; + break; + case IND: + of << n << " [type=IND];\n"; + break; + case IND_STATIC: + of << n << " [type=IND_STATIC];\n"; + break; + case BLOCKING_QUEUE: + of << n << " [type=BLOCKING_QUEUE];\n"; + break; + case BLACKHOLE: + of << n << " [type=BLACKHOLE];\n"; + break; + case MVAR_CLEAN: + case MVAR_DIRTY: + of << n << " [type=MVAR];\n"; + break; + case TVAR: + of << n << " [type=TVAR];\n"; + break; + case ARR_WORDS: + of << n << " [type=ARR_WORDS];\n"; + break; + case MUT_ARR_PTRS_CLEAN: + case MUT_ARR_PTRS_DIRTY: + case MUT_ARR_PTRS_FROZEN_CLEAN: + case MUT_ARR_PTRS_FROZEN_DIRTY: + of << n << " [type=MUT_ARR_PTRS];\n"; + break; + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + of << n << " [type=SMALL_MUT_ARR_PTRS];\n"; + break; + case MUT_VAR_CLEAN: + case MUT_VAR_DIRTY: + of << n << " [type=MUT_VAR];\n"; + break; + case WEAK: + of << n << " [type=WEAK];\n"; + break; + case PRIM: + of << n << " [type=PRIM];\n"; + break; + case MUT_PRIM: + of << n << " [type=MUT_PRIM];\n"; + break; + case TSO: + of << n << " [type=TSO];\n"; + break; + case STACK: + of << n << " [type=STACK];\n"; + break; + case TREC_CHUNK: + of << n << " [type=TREC_CHUNK];\n"; + break; + case WHITEHOLE: + of << n << " [type=WHITEHOLE];\n"; + break; + case COMPACT_NFDATA: + of << n << " [type=COMPACT_NFDATA];\n"; + break; + case CONTINUATION: + of << n << " [type=CONTINUATION];\n"; + break; + default: + of << n << " [type=unknown];\n"; + break; + } + + if (!HEAP_ALLOCED((StgPtr) c)) { + of << n << " [static=yes];\n"; + } else { + bdescr *bd = Bdescr((StgPtr) c); + of << n << " [gen=" << bd->gen_no << "];\n"; + if (bd->flags & BF_EVACUATED) { + of << n << " [evacuated=yes];\n"; + } + if (bd->flags & BF_PINNED) { + of << n << " [pinned=yes];\n"; + } + if (bd->flags & BF_LARGE) { + of << n << " [large=yes];\n"; + } else if (bd->flags & BF_NONMOVING) { + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) c); + nonmoving_block_idx block_idx = nonmovingGetBlockIdx((StgPtr) c); + uint8_t mark = nonmovingGetMark(seg, block_idx); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (c > snapshot_loc) { + of << n << " [nonmoving=yes new=yes mark=" << (StgWord) mark << "];\n"; + } else { + of << n << " [nonmoving=yes mark=" << (StgWord) mark << "];\n"; + } + } else { + of << n << " [moving=yes];\n"; + } + } + for (TaggedClosurePtr p : collect_pointers(c)) { + of << n << " -> " << NodeName(p.untag()) << ";\n"; + env.enqueue(p); + } + } + of << "}\n"; +} + +void dump_heap_to(const char *fname); +void dump_heap_to(const char *fname) +{ + std::ofstream out(fname); + dump_heap(out); + out.flush(); +} + +void check_gc() +{ + CheckGc env; + enqueue_roots(env); + std::vector errors; + + while (!env.finished()) { + TaggedClosurePtr tagged = env.pop(); + StgClosure* c = tagged.untag(); + + { + CheckVisitor check; + check.check_closure(tagged); + for (const Error& e : check.get_errors()) { + errors.push_back(e); + } + } + + for (TaggedClosurePtr p : collect_pointers(c)) { + env.enqueue(p); + } + + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa) { + errors.push_back(Error(c, "is invalid closure")); + continue; + } + + const StgInfoTable *info = get_itbl(c); + if (!HEAP_ALLOCED((StgPtr) c)) { + switch (info->type) { + case THUNK_STATIC: + if (info->srt != 0) { + + } + } + } else { + bdescr *bd = Bdescr((StgPtr) c); + if (bd->gen_no < 1) { + /* nothing to check as we are focused on post nonmoving-GC checking */ + } else if (bd->flags & BF_NONMOVING && bd->flags & BF_LARGE) { + if (bd->flags & BF_NONMOVING_SWEEPING && !(bd->flags & BF_MARKED)) { + errors.push_back(Error(c, "is not marked yet being swept")); + } + } else if (bd->flags & BF_NONMOVING) { + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) c); + nonmoving_block_idx block_idx = nonmovingGetBlockIdx((StgPtr) c); + uint8_t mark = nonmovingGetMark(seg, block_idx); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (bd->flags & BF_NONMOVING_SWEEPING) { + /* in a swept segment */ + if (mark != nonmovingMarkEpoch) { + errors.push_back(Error(c, "is unmarked nonmoving object being swept")); + } + } else if (c < snapshot_loc) { + /* not in a swept segment but in the snapshot */ + if (mark != nonmovingMarkEpoch) { + errors.push_back(Error(c, "is unmarked nonmoving object in the snapshot")); + } + } else { + /* not in the snapshot; nothing to assert */ + } + } else if (bd->flags & BF_LARGE) { + if (! (bd->flags & BF_MARKED)) { + errors.push_back(Error(c, "is unmarked large object")); + } + } else { + if (!(bd->flags & BF_EVACUATED)) { + //errors.push_back(Error(c, "is in from-space block")); + } + } + } + } + + if (!errors.empty()) { + for (auto err : errors) { + std::cerr << err << "\n"; + } + dump_heap_to("heap.dot"); + abort(); + } +} + ===================================== rts/sm/NonMoving.c ===================================== @@ -1236,6 +1236,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) && defined(NONCONCURRENT_SWEEP) #if defined(DEBUG) + check_gc(); checkNonmovingHeap(&nonmovingHeap); checkSanity(true, true); #endif ===================================== rts/sm/NonMovingMark.c ===================================== @@ -1604,7 +1604,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) // selectee unreachable. However, we must mark the selectee regardless // to satisfy the snapshot invariant. PUSH_FIELD(sel, selectee); - nonmoving_eval_thunk_selector(queue, sel, origin); + //nonmoving_eval_thunk_selector(queue, sel, origin); break; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14f1045d178417cd7d508c3b72cd70ce5b681d1a...110382863a713dc40f483e0fdc454077772dad4a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/14f1045d178417cd7d508c3b72cd70ce5b681d1a...110382863a713dc40f483e0fdc454077772dad4a You're receiving 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 Dec 6 12:47:13 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 06 Dec 2022 07:47:13 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22549 Message-ID: <638f39d1d5de4_17512e240afea0134195b@gitlab.mail> Sebastian Graf pushed new branch wip/T22549 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22549 You're receiving 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 Dec 6 12:50:18 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 06 Dec 2022 07:50:18 -0500 Subject: [Git][ghc/ghc][wip/T22549] Do not strictify a DFun's parameter dictionaries (#22549) Message-ID: <638f3a8a89361_17512e7eb4863c134211e@gitlab.mail> Sebastian Graf pushed to branch wip/T22549 at Glasgow Haskell Compiler / GHC Commits: 6bf9ad13 by Sebastian Graf at 2022-12-06T13:50:12+01:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/CoreToStg/Prep.hs - + testsuite/tests/stranal/should_run/T22549.hs - + testsuite/tests/stranal/should_run/T22549.stdout - testsuite/tests/stranal/should_run/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -290,8 +290,10 @@ dmdAnalBind dmdAnalBind top_lvl env dmd bind anal_body = case bind of NonRec id rhs | useLetUp top_lvl id - -> dmdAnalBindLetUp top_lvl env id rhs anal_body - _ -> dmdAnalBindLetDown top_lvl env dmd bind anal_body + -> dmdAnalBindLetUp top_lvl env_rhs id rhs anal_body + _ -> dmdAnalBindLetDown top_lvl env_rhs dmd bind anal_body + where + env_rhs = enterDFun bind env -- | Annotates uninteresting top level functions ('isInterestingTopLevelFn') -- with 'topDmd', the rest with the given demand. @@ -1759,6 +1761,10 @@ We never unbox class dictionaries in worker/wrapper. occur without INLINABLE, when we use -fexpose-all-unfoldings and -fspecialise-aggressively to do vigorous cross-module specialisation. +3. #18421 found that unboxing a dictionary can also make the worker less likely + to inline; the inlining heuristics seem to prefer to inline a function + applied to a dictionary over a function applied to a bunch of functions. + TL;DR we /never/ unbox class dictionaries. Unboxing the dictionary, and passing a raft of higher-order functions isn't a huge win anyway -- you really want to specialise the function. @@ -2242,14 +2248,6 @@ addLazyFVs dmd_ty lazy_fvs -- L demand doesn't get both'd with the Bot coming up from the inner -- call to f. So we just get an L demand for x for g. -{- -Note [Do not strictify the argument dictionaries of a dfun] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The typechecker can tie recursive knots involving dfuns, so we do the -conservative thing and refrain from strictifying a dfun's argument -dictionaries. --} - setBndrsDemandInfo :: HasCallStack => [Var] -> [Demand] -> [Var] setBndrsDemandInfo (b:bs) ds | isTyVar b = b : setBndrsDemandInfo bs ds @@ -2362,6 +2360,8 @@ data AnalEnv = AE , ae_fam_envs :: !FamInstEnvs , ae_rec_dc :: DataCon -> IsRecDataConResult -- ^ Memoised result of 'GHC.Core.Opt.WorkWrap.Utils.isRecDataCon' + , ae_in_dfun :: !Bool + -- ^ Whether we analyse the RHS of a DFun } -- We use the se_env to tell us whether to @@ -2386,8 +2386,15 @@ emptyAnalEnv opts fam_envs , ae_virgin = True , ae_fam_envs = fam_envs , ae_rec_dc = memoiseUniqueFun (isRecDataCon fam_envs 3) + , ae_in_dfun = False } +-- | Sets the 'ae_in_dfun' flag if any of the given bindings is a DFun binding. +-- Part of the mechanism that detects +-- Note [Do not strictify a DFun's parameter dictionaries]. +enterDFun :: CoreBind -> AnalEnv -> AnalEnv +enterDFun bind env = env { ae_in_dfun = ae_in_dfun env || any isDFunId (bindersOf bind) } + emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv @@ -2439,31 +2446,30 @@ findBndrDmd env dmd_ty id id_ty = idType id strictify dmd - -- See Note [Making dictionaries strict] + -- See Note [Making dictionary parameters strict] + -- and Note [Do not strictify a DFun's parameter dictionaries] | dmd_strict_dicts (ae_opts env) - -- We never want to strictify a recursive let. At the moment - -- findBndrDmd is never called for recursive lets; if that - -- changes, we need a RecFlag parameter and another guard here. + , not (ae_in_dfun env) = strictifyDictDmd id_ty dmd | otherwise = dmd fam_envs = ae_fam_envs env -{- Note [Making dictionaries strict] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Making dictionary parameters strict] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? * Generally CBV is more efficient. -* Dictionaries are always non-bottom; and never take much work to - compute. E.g. a dfun from an instance decl always returns a dictionary +* A datatype dictionary is always non-bottom and never takes much work to + compute. E.g. a DFun from an instance decl always returns a dictionary record immediately. See DFunUnfolding in CoreSyn. See also Note [Recursive superclasses] in TcInstDcls. -* The strictness analyser will then unbox dictionaries and pass the - methods individually, rather than in a bundle. If there are a lot of - methods that might be bad; but worker/wrapper already does throttling. +See #17758 for more background and perf numbers. + +There are a few related issues: * A newtype dictionary is *not* always non-bottom. E.g. class C a where op :: a -> a @@ -2471,26 +2477,48 @@ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? Now a value of type (C Int) is just a newtype wrapper (a cast) around the error thunk. Don't strictify these! -See #17758 for more background and perf numbers. +* Strictifying DFuns risks destroying the invariant that DFuns never take much + work to compute, so we don't do it. + See Note [Do not strictify a DFun's parameter dictionaries] for details. + +* Although worker/wrapper *could* unbox strictly used dictionaries, we stopped + doing so. See Note [Do not unbox class dictionaries]. The implementation is extremely simple: just make the strictness analyser strictify the demand on a dictionary binder in -'findBndrDmd'. - -However there is one case where this can make performance worse. -For the principle consider some function at the core level: - myEq :: Eq a => a -> a -> Bool - myEq eqDict x y = ((==) eqDict) x y -If we make the dictionary strict then WW can fire turning this into: - $wmyEq :: (a -> a -> Bool) -> a -> a -> Bool - $wmyEq eq x y = eq x y -Which *usually* performs better. However if the dictionary is known we -are far more likely to inline a function applied to the dictionary than -to inline one applied to a function. Sometimes this makes just enough -of a difference to stop a function from inlining. This is documented in #18421. - -It's somewhat similar to Note [Do not unbox class dictionaries] although -here our problem is with the inliner, not the specializer. +'findBndrDmd' if the binder does not belong to a DFun. + +Note [Do not strictify a DFun's parameter dictionaries] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The typechecker can tie recursive knots involving (non-recursive) DFuns, so +we do not strictify a DFun's parameter dictionaries. T22549 has an example +involving undecidable instances that <>s when we strictify the DFun of, +e.g., `$fEqSeqT`: + + Main.$fEqSeqT + = \ (@(m_a19S :: * -> *)) + (@a_a19T) + ($dEq_a19U :: Eq (m_a19S (ViewT m_a19S a_a19T))) + ($dMonad_a19V :: Monad m_a19S) -> + GHC.Classes.C:Eq + @(SeqT m_a19S a_a19T) + ($c==_a19X @m_a19S @a_a19T $dEq_a19U $dMonad_a19V) + ($c/=_a1ad @m_a19S @a_a19T $dEq_a19U $dMonad_a19V) + + Rec { + $dEq_a17i = Main.$fEqSeqT @Identity @Int $dEq_a1co Main.$fMonadIdentity + $dEq_a1co = ... $dEq_a17i ... + } + +If we make `$fEqSeqT` strict in `$dEq_a19U`, we'll collapse the Rec group into a +giant, <>ing thunk. + +To prevent that, we never strictify dictionary params when inside a DFun. +Whether we are inside the RHS of a DFun is tracked in 'ae_in_dfun'. + +See also Note [Speculative evaluation] which has a rather similar example in +#20836. We may never speculate *arguments* of (recursive) DFun calls, likewise +we should not mark *formal parameters* of recursive DFuns as strict. Note [Initialising strictness] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1708,6 +1708,10 @@ Fortunately, pce_rec_ids already has all the information we need in that case. The problem is very similar to Note [Eta reduction in recursive RHSs]. Here as well as there it is *unsound* to change the termination properties of the very function whose termination properties we are exploiting. + +It is also similar to Note [Do not strictify a DFun's parameter dictionaries], +where marking recursive DFuns (of undecidable *instances*) strict in dictionary +*parameters* leads to quite the same change in termination as above. -} data FloatingBind ===================================== testsuite/tests/stranal/should_run/T22549.hs ===================================== @@ -0,0 +1,37 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE DeriveFunctor #-} + +import Data.Function (on) + +newtype Identity a = Identity a deriving (Eq, Functor) +instance Applicative Identity where + pure = Identity + Identity f <*> Identity a = Identity $ f a +instance Monad Identity where + Identity a >>= f = f a + +data ViewT m a + = Empty + | a :< SeqT m a +newtype SeqT m a = SeqT [m (ViewT m a)] + +toViewT :: Monad m => SeqT m a -> m (ViewT m a) +toViewT (SeqT []) = pure Empty +toViewT (SeqT (h : t)) = h >>= \case + Empty -> toViewT (SeqT t) + hi :< SeqT ti -> pure (hi :< SeqT (ti ++ t)) + +instance (Eq (m (ViewT m a)), Monad m) => Eq (SeqT m a) where + (==) = (==) `on` toViewT + +deriving instance (Eq a, Eq (SeqT m a)) => Eq (ViewT m a) + +example :: SeqT Identity Int +example = SeqT [] + +main :: IO () +main = print (example == example) ===================================== testsuite/tests/stranal/should_run/T22549.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== testsuite/tests/stranal/should_run/all.T ===================================== @@ -30,3 +30,5 @@ test('T19053', normal, compile_and_run, ['']) test('T21717b', normal, compile_and_run, ['']) test('T22475', normal, compile_and_run, ['']) test('T22475b', normal, compile_and_run, ['']) +# T22549: Do not strictify DFuns, otherwise we will <> +test('T22549', normal, compile_and_run, ['-fdicts-strict -fno-specialise']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6bf9ad13c5a911c5dbf04999ebf04960d797cd09 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6bf9ad13c5a911c5dbf04999ebf04960d797cd09 You're receiving 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 Dec 6 12:54:55 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 06 Dec 2022 07:54:55 -0500 Subject: [Git][ghc/ghc][wip/T22264] 3 commits: setNumCapabilities Message-ID: <638f3b9fde6a7_17512e52be813478c9@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC Commits: b24ba0f7 by Ben Gamari at 2022-12-06T07:54:42-05:00 setNumCapabilities - - - - - 5832809f by Ben Gamari at 2022-12-06T07:54:42-05:00 nonmoving: Disable shortcutting - - - - - 22cd7bb7 by Ben Gamari at 2022-12-06T07:54:42-05:00 CheckGC - - - - - 7 changed files: - libraries/base/GHC/Conc/Sync.hs - rts/Schedule.c - rts/include/rts/Threads.h - rts/rts.cabal.in - + rts/sm/CheckGc.cpp - rts/sm/NonMoving.c - rts/sm/NonMovingMark.c Changes: ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -380,10 +380,15 @@ to avoid contention with other processes in the machine. setNumCapabilities :: Int -> IO () setNumCapabilities i | i <= 0 = failIO $ "setNumCapabilities: Capability count ("++show i++") must be positive" - | otherwise = c_setNumCapabilities (fromIntegral i) + | otherwise = do + ret <- c_setNumCapabilities (fromIntegral i) + case ret of + 0 -> return () + 1 -> yield >> setNumCapabilities i + _ -> failIO $ "setNumCapabilities: Unknown result" foreign import ccall safe "setNumCapabilities" - c_setNumCapabilities :: CUInt -> IO () + c_setNumCapabilities :: CUInt -> IO CInt -- | Returns the number of CPUs that the machine has -- ===================================== rts/Schedule.c ===================================== @@ -2225,9 +2225,12 @@ forkProcess(HsStablePtr *entry * Finally we release the Capabilities we are holding, and start * worker Tasks on the new Capabilities we created. * + * One wrinkle here is that we must also ensure that we don't change the + * capability count while the nonmoving mark thread is active. + * * ------------------------------------------------------------------------- */ -void +int setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) { #if !defined(THREADED_RTS) @@ -2247,11 +2250,15 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) Capability *old_capabilities = NULL; uint32_t old_n_capabilities = n_capabilities; + if (RELAXED_LOAD(&concurrent_coll_running)) { + return 1; + } + if (new_n_capabilities == enabled_capabilities) { - return; + return 0; } else if (new_n_capabilities <= 0) { errorBelch("setNumCapabilities: Capability count must be positive"); - return; + return 1; } @@ -2353,6 +2360,7 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) rts_unlock(cap); + return 0; #endif // THREADED_RTS } ===================================== rts/include/rts/Threads.h ===================================== @@ -85,4 +85,4 @@ extern Capability MainCapability; // Change the number of capabilities (only supports increasing the // current value at the moment). // -extern void setNumCapabilities (uint32_t new_); +extern int setNumCapabilities (uint32_t new_); ===================================== rts/rts.cabal.in ===================================== @@ -619,6 +619,7 @@ library linker/elf_tlsgd.c linker/elf_util.c sm/BlockAlloc.c + sm/CheckGc.cpp sm/CNF.c sm/Compact.c sm/Evac.c ===================================== rts/sm/CheckGc.cpp ===================================== @@ -0,0 +1,974 @@ +extern "C" { +#include "Rts.h" +#include "StableName.h" /* for FOR_EACH_STABLE_NAME */ +#include "StablePtr.h" /* for markStablePtrTable */ +#include "Capability.h" +#include "HeapAlloc.h" +#include "STM.h" +#include "sm/NonMoving.h" +} + +#include +#include +#include +#include +#include +#include + +extern uint8_t nonmovingMarkEpoch; + +class TaggedClosurePtr { + StgClosure *ptr; +public: + TaggedClosurePtr(StgClosure* ptr) : ptr(ptr) {} + TaggedClosurePtr(StgClosure* ptr, uint8_t tag) : TaggedClosurePtr(TAG_CLOSURE(tag, ptr)) {} + + StgClosure *get_tagged() const { + return ptr; + } + StgClosure *untag() const { + return UNTAG_CLOSURE(ptr); + } + uint8_t get_tag() const { + return (StgWord) ptr & TAG_MASK; + } + + //inline StgClosure& operator->() { return *untag(); } + + friend inline bool operator==(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { + return lhs.ptr == rhs.ptr; + } + friend inline bool operator!=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs == rhs); } + friend inline bool operator< (const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { + return lhs.ptr < rhs.ptr; + } + friend inline bool operator> (const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return rhs < lhs; } + friend inline bool operator<=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs > rhs); } + friend inline bool operator>=(const TaggedClosurePtr& lhs, const TaggedClosurePtr& rhs) { return !(lhs < rhs); } +}; + +template<> +struct std::hash { + std::size_t operator()(TaggedClosurePtr const& p) const noexcept { + return std::hash{}(p.get_tagged()); + } +}; + +class HeapVisitor { +public: + // Visit an SRT + virtual void visit_srt(StgClosure* c); + + // Visit a normal closure + virtual void visit_closure(TaggedClosurePtr c); + + virtual void visit_thunk(StgThunk *thunk, size_t n_ptrs); + virtual void visit_fun(StgClosure *constr, size_t n_ptrs); + virtual void visit_constr(StgClosure *constr, size_t n_ptrs); + virtual void visit_array(StgMutArrPtrs *arr); + virtual void visit_small_array(StgSmallMutArrPtrs *arr); + virtual void visit_bytearray(StgArrBytes* arr); + + virtual void visit_stack(StgPtr sp, StgPtr end); + virtual void visit_tso(StgTSO* tso); + virtual void visit_weak(StgWeak* w); + virtual void visit_mvar(StgMVar* mvar); + virtual void visit_tvar(StgTVar* tvar); + virtual void visit_trec_header(StgTRecHeader *trec); + virtual void visit_trec_chunk(StgTRecChunk* tc); + virtual void visit_continuation(StgContinuation* tc); + + virtual void visit_small_bitmap(StgClosure *const *payload, StgWord bitmap, StgWord size); + virtual void visit_large_bitmap(StgClosure *const *payload, const StgLargeBitmap *bitmap, StgWord size); + void visit_pap_payload(StgClosure *fun, StgClosure **payload, StgWord n_args); + + virtual void visit_invalid(StgClosure *const c); +}; + +void HeapVisitor::visit_thunk(StgThunk *thunk, size_t n_ptrs) +{ + const StgInfoTable *info = get_itbl((StgClosure *) thunk); + const StgThunkInfoTable *thunk_info = itbl_to_thunk_itbl(info); + if (thunk_info->i.srt) { + StgClosure *srt = (StgClosure*) GET_SRT(thunk_info); + visit_srt(srt); + }; + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(thunk->payload[i]); + } +} + +void HeapVisitor::visit_fun(StgClosure *fun, size_t n_ptrs) +{ + const StgInfoTable *info = get_itbl(fun); + const StgFunInfoTable *fun_info = itbl_to_fun_itbl(info); + if (fun_info->i.srt) { + StgClosure *srt = (StgClosure*) GET_SRT(fun_info); + visit_srt(srt); + }; + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(fun->payload[i]); + } +} + +void HeapVisitor::visit_constr(StgClosure *constr, size_t n_ptrs) +{ + for (size_t i=0; i < n_ptrs; i++) { + visit_closure(constr->payload[i]); + } +} + +void HeapVisitor::visit_srt(StgClosure* c) +{ + visit_closure(c); +} + +void HeapVisitor::visit_invalid(StgClosure *const _c) +{ + abort(); +} + +void HeapVisitor::visit_weak(StgWeak* w) +{ + visit_closure(w->key); + visit_closure(w->value); + visit_closure(w->finalizer); + visit_closure(w->cfinalizers); +} + +void HeapVisitor::visit_mvar(StgMVar* mvar) +{ + visit_closure((StgClosure*) mvar->head); + visit_closure((StgClosure*) mvar->tail); + visit_closure(mvar->value); +} + +void HeapVisitor::visit_small_array(StgSmallMutArrPtrs *arr) +{ + for (StgWord i=0; i < arr->ptrs; i++) { + visit_closure(arr->payload[i]); + } +} + +void HeapVisitor::visit_array(StgMutArrPtrs *arr) +{ + for (StgWord i=0; i < arr->ptrs; i++) { + visit_closure(arr->payload[i]); + } +} + +void HeapVisitor::visit_bytearray(StgArrBytes* _arr) { } + +void HeapVisitor::visit_tso(StgTSO *tso) +{ + if (tso->bound != NULL) { + + visit_closure((StgClosure*) tso->bound->tso); + } + if (tso->label != NULL) { + visit_closure({(StgClosure*) tso->label}); + } + visit_closure((StgClosure*) tso->blocked_exceptions); + visit_closure((StgClosure*) tso->bq); + visit_closure((StgClosure*) tso->stackobj); + visit_closure((StgClosure*) tso->_link); + visit_trec_header(tso->trec); + + switch (tso->why_blocked) { + case BlockedOnMVar: + case BlockedOnMVarRead: + case BlockedOnBlackHole: + case BlockedOnMsgThrowTo: + case NotBlocked: + visit_closure(tso->block_info.closure); + break; + default: + break; + } +} + +void HeapVisitor::visit_continuation(StgContinuation *cont) +{ + visit_stack(cont->stack, cont->stack + cont->stack_size); +} + +void HeapVisitor::visit_tvar(StgTVar *tvar) +{ + visit_closure(tvar->current_value); + visit_closure((StgClosure*) tvar->first_watch_queue_entry); +} + +void HeapVisitor::visit_trec_header(StgTRecHeader *trec) +{ + if (trec == NO_TREC) { + return; + } + visit_trec_chunk(trec->current_chunk); + visit_closure((StgClosure*) trec->enclosing_trec); +} + +void HeapVisitor::visit_trec_chunk(StgTRecChunk *tc) +{ + if (tc->prev_chunk != END_STM_CHUNK_LIST) { + visit_closure((StgClosure*) tc->prev_chunk); + } + + for (uint32_t i = 0; i < tc->next_entry_idx; i++) { + TRecEntry *e = &tc->entries[i]; + visit_closure((StgClosure*)e->tvar); + visit_closure(e->expected_value); + visit_closure(e->new_value); + } +} + +void HeapVisitor::visit_stack(StgPtr p, StgPtr stack_end) +{ + while (p < stack_end) { + const StgRetInfoTable* info = get_ret_itbl((StgClosure *) p); + + auto add_srt_ptrs = [&] () { + if (info->i.srt) { + StgClosure *srt = (StgClosure*)GET_SRT(info); + visit_srt(srt); + } + }; + + switch (info->i.type) { + + case UPDATE_FRAME: + { + StgUpdateFrame *frame = (StgUpdateFrame *)p; + visit_closure(frame->updatee); + p += sizeofW(StgUpdateFrame); + continue; + } + + case CATCH_STM_FRAME: + case CATCH_RETRY_FRAME: + case ATOMICALLY_FRAME: + case UNDERFLOW_FRAME: + case STOP_FRAME: + case CATCH_FRAME: + case RET_SMALL: + { + StgWord bitmap = BITMAP_BITS(info->i.layout.bitmap); + StgWord size = BITMAP_SIZE(info->i.layout.bitmap); + // NOTE: the payload starts immediately after the info-ptr, we + // don't have an StgHeader in the same sense as a heap closure. + p++; + visit_small_bitmap((StgClosure**) p, bitmap, size); + p += size; + add_srt_ptrs(); + continue; + } + + case RET_BCO: + { + p++; + StgBCO *bco = (StgBCO *)*p; + visit_closure((StgClosure *) bco); + p++; + StgWord size = BCO_BITMAP_SIZE(bco); + visit_large_bitmap((StgClosure**) p, BCO_BITMAP(bco), size); + p += size; + continue; + } + + case RET_BIG: + { + StgWord size = GET_LARGE_BITMAP(&info->i)->size; + p++; + visit_large_bitmap((StgClosure**) p, GET_LARGE_BITMAP(&info->i), size); + p += size; + // and don't forget to follow the SRT + add_srt_ptrs(); + break; + } + + case RET_FUN: + { + StgRetFun *ret_fun = (StgRetFun *)p; + visit_closure(ret_fun->fun); + + const StgFunInfoTable *fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + switch (fun_info->f.fun_type) { + case ARG_GEN: + { + StgWord bitmap = BITMAP_BITS(fun_info->f.b.bitmap); + StgWord size = BITMAP_SIZE(fun_info->f.b.bitmap); + visit_small_bitmap(ret_fun->payload, bitmap, size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + case ARG_GEN_BIG: + { + StgWord size = GET_FUN_LARGE_BITMAP(fun_info)->size; + visit_large_bitmap(ret_fun->payload, GET_FUN_LARGE_BITMAP(fun_info), size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + default: + { + StgWord bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); + StgWord size = BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type]); + visit_small_bitmap(ret_fun->payload, bitmap, size); + p = (StgPtr) ((StgClosure **) &ret_fun->payload + size); + break; + } + } + add_srt_ptrs(); + break; + } + default: + abort(); + } + } +} + +void HeapVisitor::visit_small_bitmap( + StgClosure *const *payload, + StgWord bitmap, + StgWord size) +{ + while (size > 0) { + if ((bitmap & 1) == 0) { + visit_closure(*payload); + } + payload++; + bitmap = bitmap >> 1; + size--; + } +} + +void HeapVisitor::visit_large_bitmap( + StgClosure *const * payload, + const StgLargeBitmap *large_bitmap, + StgWord size) +{ + // Bitmap may have more bits than `size` when scavenging PAP payloads. See + // comments around StgPAP. + ASSERT(large_bitmap->size >= size); + + uint32_t b = 0; + for (uint32_t i = 0; i < size; b++) { + StgWord bitmap = large_bitmap->bitmap[b]; + uint32_t j = stg_min(size-i, BITS_IN(W_)); + i += j; + for (; j > 0; j--, payload++) { + if ((bitmap & 1) == 0) { + visit_closure(*payload); + } + bitmap = bitmap >> 1; + } + } +} + +void HeapVisitor::visit_pap_payload( + StgClosure *fun, + StgClosure **payload, + StgWord n_args) +{ + fun = UNTAG_CLOSURE(fun); + const StgFunInfoTable *fun_info = get_fun_itbl(fun); + ASSERT(fun_info->i.type != PAP); + switch (fun_info->f.fun_type) { + case ARG_GEN: + visit_small_bitmap(payload, BITMAP_BITS(fun_info->f.b.bitmap), n_args); + break; + case ARG_GEN_BIG: + visit_large_bitmap(payload, GET_FUN_LARGE_BITMAP(fun_info), n_args); + break; + case ARG_BCO: + visit_large_bitmap(payload, BCO_BITMAP(fun), n_args); + break; + default: + { + StgWord bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); + visit_small_bitmap(payload, bitmap, n_args); + } + } +} + +void HeapVisitor::visit_closure(TaggedClosurePtr tagged) +{ + StgClosure *c = tagged.untag(); + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa || !LOOKS_LIKE_CLOSURE_PTR(c)) { + visit_invalid(c); + return; + } + + const StgInfoTable *info = get_itbl(c); + auto generic_closure = [&] () { + for (StgClosure **p = &c->payload[0]; p < &c->payload[info->layout.payload.ptrs]; p++) { + visit_closure(*p); + } + }; + + switch (info->type) { + + case MVAR_CLEAN: + case MVAR_DIRTY: + visit_mvar((StgMVar *) c); + break; + case TVAR: + visit_tvar((StgTVar *) c); + break; + + case IND: + case IND_STATIC: + visit_closure(((StgInd *) c)->indirectee); + break; + + case THUNK_0_1: + case THUNK_0_2: + visit_thunk((StgThunk*) c, 0); + break; + case THUNK_1_1: + case THUNK_1_0: + visit_thunk((StgThunk*) c, 1); + break; + case THUNK_2_0: + visit_thunk((StgThunk*) c, 2); + break; + case THUNK: + visit_thunk((StgThunk*) c, info->layout.payload.ptrs); + break; + case THUNK_STATIC: + visit_thunk((StgThunk*) c, 0); + break; + + case FUN_1_0: + visit_fun(c, 1); + break; + case FUN_0_1: + case FUN_0_2: + visit_fun(c, 0); + break; + case FUN_1_1: + visit_fun(c, 1); + break; + case FUN_2_0: + visit_fun(c, 2); + break; + case FUN: + case FUN_STATIC: + visit_fun(c, info->layout.payload.ptrs); + break; + + case CONSTR_0_1: + case CONSTR_0_2: + visit_constr(c, 0); + break; + case CONSTR_1_0: + case CONSTR_1_1: + visit_constr(c, 1); + break; + case CONSTR_2_0: + visit_constr(c, 2); + break; + case CONSTR: + case CONSTR_NOCAF: + visit_constr(c, info->layout.payload.ptrs); + break; + + case PRIM: + generic_closure(); + break; + case WEAK: + visit_weak((StgWeak*) c); + break; + case BCO: + { + StgBCO *bco = (StgBCO *)c; + visit_closure((StgClosure*) bco->instrs); + visit_closure((StgClosure*) bco->literals); + visit_closure((StgClosure*) bco->ptrs); + break; + } + case BLACKHOLE: + { + StgInd *ind = (StgInd*) c; + visit_closure(ind->indirectee); + break; + } + case MUT_VAR_CLEAN: + case MUT_VAR_DIRTY: + { + StgMutVar *mv = (StgMutVar*) c; + visit_closure(mv->var); + break; + } + case BLOCKING_QUEUE: + { + StgBlockingQueue *bq = (StgBlockingQueue *)c; + visit_closure((StgClosure*) bq->bh); + visit_closure((StgClosure*) bq->owner); + visit_closure((StgClosure*) bq->queue); + visit_closure((StgClosure*) bq->link); + break; + } + case THUNK_SELECTOR: + { + StgSelector *s = (StgSelector *)c; + visit_closure(s->selectee); + break; + } + case AP_STACK: + { + StgAP_STACK *ap = (StgAP_STACK *)c; + visit_closure(ap->fun); + visit_stack((StgPtr) ap->payload, (StgPtr) ap->payload + ap->size); + break; + } + case PAP: + { + StgPAP *pap = (StgPAP*) c; + visit_closure(pap->fun); + visit_pap_payload(pap->fun, (StgClosure**) pap->payload, pap->n_args); + break; + } + case AP: + { + StgAP *ap = (StgAP*) c; + visit_closure(ap->fun); + visit_pap_payload(ap->fun, (StgClosure**) ap->payload, ap->n_args); + break; + } + case ARR_WORDS: + visit_bytearray((StgArrBytes *) c); + break; + case MUT_ARR_PTRS_CLEAN: + case MUT_ARR_PTRS_DIRTY: + case MUT_ARR_PTRS_FROZEN_DIRTY: + case MUT_ARR_PTRS_FROZEN_CLEAN: + visit_array((StgMutArrPtrs *) c); + break; + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + visit_small_array((StgSmallMutArrPtrs *) c); + break; + case TSO: + visit_tso((StgTSO *) c); + break; + case STACK: + { + StgStack *stack = (StgStack *) c; + visit_stack(stack->sp, stack->stack + stack->stack_size); + break; + } + case MUT_PRIM: + generic_closure(); + break; + case TREC_CHUNK: + visit_trec_chunk((StgTRecChunk *) c); + break; + case CONTINUATION: + visit_continuation((StgContinuation *) c); + break; + default: + visit_invalid(c); + break; + } +} + +class PredicatedHeapVisitor : HeapVisitor { + bool should_visit(StgClosure *); + + virtual void visit_srt(StgClosure* c) { + if (should_visit(c)) { HeapVisitor::visit_srt(c); } + } + + virtual void visit_closure(TaggedClosurePtr c) { + if (should_visit(c.untag())) { HeapVisitor::visit_closure(c); } + } +}; + +// Collect direct pointers +struct CollectPointers : HeapVisitor { + std::set accum; + bool invalid; + CollectPointers() : accum(), invalid(false) {} + void visit_root(StgClosure *c) { + HeapVisitor::visit_closure(c); + } + void visit_closure(TaggedClosurePtr c) { + accum.insert(c); + } + void visit_invalid(StgClosure *const _c) { invalid = true; } +}; + +static std::set collect_pointers(StgClosure* c) +{ + CollectPointers v; + v.visit_root(c); + return v.accum; +} + + + +struct Error { + StgClosure *closure; + std::string what; + Error(StgClosure *closure, std::string what) : closure(closure), what(what) {} +}; + +static std::ostream& operator<<(std::ostream& os, const Error& err) { + os << std::hex << "0x" << (StgWord) err.closure << ": " << err.what << "\n"; + return os; +} + +class CheckVisitor : HeapVisitor { + std::vector errors; + uint8_t tag; + void visit_constr(StgClosure* c) { + const StgInfoTable *info = get_itbl(c); + if (tag != 0) { + uint8_t constr_tag = info->srt; // zero-based + if (tag != std::min(TAG_MASK, constr_tag+1)) { + errors.push_back(Error(c, "invalid tag")); + } + } + } + + void visit_closure(TaggedClosurePtr c) { } +public: + const std::vector& get_errors() const { return errors; } + + void check_closure(TaggedClosurePtr c) { + tag = c.get_tag(); + HeapVisitor::visit_closure(c); + } +}; + +struct CheckGc { + std::queue queue; + std::unordered_set enqueued; + + void enqueue(TaggedClosurePtr ptr) { + ASSERT(ptr != NULL); + if (!is_enqueued(ptr)) { + queue.push(ptr); + enqueued.insert(ptr); + } + } + + bool finished() { + return queue.empty(); + } + + TaggedClosurePtr pop() { + TaggedClosurePtr p = queue.front(); + queue.pop(); + return p; + } + + bool is_enqueued(TaggedClosurePtr ptr) { + return enqueued.find(ptr) != enqueued.end(); + } +}; + +static void enqueue_root(void *user_data, StgClosure **root) +{ + CheckGc* env = (CheckGc*) user_data; + env->enqueue(*root); +} + +static void enqueue_roots(CheckGc& env) +{ + FOR_EACH_STABLE_NAME(p, if (p->sn_obj) env.enqueue(p->sn_obj);); + markStablePtrTable(enqueue_root, &env); + for (uint32_t n = 0; n < getNumCapabilities(); n++) { + markCapability(enqueue_root, (void*) &env, getCapability(n), false/*mark sparks*/); + } + markCAFs(enqueue_root, &env); + + for (StgWeak *w = nonmoving_weak_ptr_list; w != NULL; w = w->link) { + env.enqueue((StgClosure *) w); + } + + for (uint32_t g = 0; g <= N; g++) { + generation *gen = &generations[g]; + for (StgWeak *w = gen->weak_ptr_list; w != NULL; w = RELAXED_LOAD(&w->link)) { + env.enqueue((StgClosure *) w); + } + } +} + +extern "C" { +void check_gc(); +} + +struct NodeName { + const StgClosure *c; + NodeName(const StgClosure *c) : c(c) {} +}; + +static std::ostream& operator<<(std::ostream& os, const NodeName& n) { + os << std::hex << "\"" << n.c << "\"" << std::dec; + return os; +} + +static void dump_heap(std::ofstream& of) +{ + of << "digraph {\n"; + CheckGc env; + enqueue_roots(env); + while (!env.finished()) { + TaggedClosurePtr tagged = env.pop(); + StgClosure* c = tagged.untag(); + NodeName n(c); + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa) { + of << n << " [type=invalid];\n"; + continue; + } + + const StgInfoTable *info = get_itbl(c); + switch (info->type) { + case CONSTR: + case CONSTR_1_0: + case CONSTR_0_1: + case CONSTR_2_0: + case CONSTR_1_1: + case CONSTR_0_2: + case CONSTR_NOCAF: + { + const StgConInfoTable *con_info = get_con_itbl(c); + of << n << " [type=CONSTR constr=\"" << GET_CON_DESC(con_info) << "\"];\n"; + break; + } + case FUN: + case FUN_1_0: + case FUN_0_1: + case FUN_2_0: + case FUN_1_1: + case FUN_0_2: + of << n << " [type=FUN];\n"; + break; + case FUN_STATIC: + of << n << " [type=FUN_STATIC];\n"; + break; + case THUNK: + case THUNK_1_0: + case THUNK_0_1: + case THUNK_1_1: + case THUNK_0_2: + case THUNK_2_0: + of << n << " [type=THUNK];\n"; + break; + case THUNK_STATIC: + of << n << " [type=THUNK_STATIC];\n"; + break; + case THUNK_SELECTOR: + of << n << " [type=THUNK_SEL];\n"; + break; + case BCO: + of << n << " [type=BCO];\n"; + break; + case AP: + of << n << " [type=AP];\n"; + break; + case PAP: + of << n << " [type=PAP];\n"; + break; + case AP_STACK: + of << n << " [type=AP_STACK];\n"; + break; + case IND: + of << n << " [type=IND];\n"; + break; + case IND_STATIC: + of << n << " [type=IND_STATIC];\n"; + break; + case BLOCKING_QUEUE: + of << n << " [type=BLOCKING_QUEUE];\n"; + break; + case BLACKHOLE: + of << n << " [type=BLACKHOLE];\n"; + break; + case MVAR_CLEAN: + case MVAR_DIRTY: + of << n << " [type=MVAR];\n"; + break; + case TVAR: + of << n << " [type=TVAR];\n"; + break; + case ARR_WORDS: + of << n << " [type=ARR_WORDS];\n"; + break; + case MUT_ARR_PTRS_CLEAN: + case MUT_ARR_PTRS_DIRTY: + case MUT_ARR_PTRS_FROZEN_CLEAN: + case MUT_ARR_PTRS_FROZEN_DIRTY: + of << n << " [type=MUT_ARR_PTRS];\n"; + break; + case SMALL_MUT_ARR_PTRS_CLEAN: + case SMALL_MUT_ARR_PTRS_DIRTY: + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + case SMALL_MUT_ARR_PTRS_FROZEN_DIRTY: + of << n << " [type=SMALL_MUT_ARR_PTRS];\n"; + break; + case MUT_VAR_CLEAN: + case MUT_VAR_DIRTY: + of << n << " [type=MUT_VAR];\n"; + break; + case WEAK: + of << n << " [type=WEAK];\n"; + break; + case PRIM: + of << n << " [type=PRIM];\n"; + break; + case MUT_PRIM: + of << n << " [type=MUT_PRIM];\n"; + break; + case TSO: + of << n << " [type=TSO];\n"; + break; + case STACK: + of << n << " [type=STACK];\n"; + break; + case TREC_CHUNK: + of << n << " [type=TREC_CHUNK];\n"; + break; + case WHITEHOLE: + of << n << " [type=WHITEHOLE];\n"; + break; + case COMPACT_NFDATA: + of << n << " [type=COMPACT_NFDATA];\n"; + break; + case CONTINUATION: + of << n << " [type=CONTINUATION];\n"; + break; + default: + of << n << " [type=unknown];\n"; + break; + } + + if (!HEAP_ALLOCED((StgPtr) c)) { + of << n << " [static=yes];\n"; + } else { + bdescr *bd = Bdescr((StgPtr) c); + of << n << " [gen=" << bd->gen_no << "];\n"; + if (bd->flags & BF_EVACUATED) { + of << n << " [evacuated=yes];\n"; + } + if (bd->flags & BF_PINNED) { + of << n << " [pinned=yes];\n"; + } + if (bd->flags & BF_LARGE) { + of << n << " [large=yes];\n"; + } else if (bd->flags & BF_NONMOVING) { + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) c); + nonmoving_block_idx block_idx = nonmovingGetBlockIdx((StgPtr) c); + uint8_t mark = nonmovingGetMark(seg, block_idx); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (c > snapshot_loc) { + of << n << " [nonmoving=yes new=yes mark=" << (StgWord) mark << "];\n"; + } else { + of << n << " [nonmoving=yes mark=" << (StgWord) mark << "];\n"; + } + } else { + of << n << " [moving=yes];\n"; + } + } + for (TaggedClosurePtr p : collect_pointers(c)) { + of << n << " -> " << NodeName(p.untag()) << ";\n"; + env.enqueue(p); + } + } + of << "}\n"; +} + +void dump_heap_to(const char *fname); +void dump_heap_to(const char *fname) +{ + std::ofstream out(fname); + dump_heap(out); + out.flush(); +} + +void check_gc() +{ + CheckGc env; + enqueue_roots(env); + std::vector errors; + + while (!env.finished()) { + TaggedClosurePtr tagged = env.pop(); + StgClosure* c = tagged.untag(); + + { + CheckVisitor check; + check.check_closure(tagged); + for (const Error& e : check.get_errors()) { + errors.push_back(e); + } + } + + for (TaggedClosurePtr p : collect_pointers(c)) { + env.enqueue(p); + } + + if (c->header.info == (StgInfoTable *) 0xaaaaaaaaaaaaaaaa) { + errors.push_back(Error(c, "is invalid closure")); + continue; + } + + const StgInfoTable *info = get_itbl(c); + if (!HEAP_ALLOCED((StgPtr) c)) { + switch (info->type) { + case THUNK_STATIC: + if (info->srt != 0) { + + } + } + } else { + bdescr *bd = Bdescr((StgPtr) c); + if (bd->gen_no < 1) { + /* nothing to check as we are focused on post nonmoving-GC checking */ + } else if (bd->flags & BF_NONMOVING && bd->flags & BF_LARGE) { + if (bd->flags & BF_NONMOVING_SWEEPING && !(bd->flags & BF_MARKED)) { + errors.push_back(Error(c, "is not marked yet being swept")); + } + } else if (bd->flags & BF_NONMOVING) { + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) c); + nonmoving_block_idx block_idx = nonmovingGetBlockIdx((StgPtr) c); + uint8_t mark = nonmovingGetMark(seg, block_idx); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (bd->flags & BF_NONMOVING_SWEEPING) { + /* in a swept segment */ + if (mark != nonmovingMarkEpoch) { + errors.push_back(Error(c, "is unmarked nonmoving object being swept")); + } + } else if (c < snapshot_loc) { + /* not in a swept segment but in the snapshot */ + if (mark != nonmovingMarkEpoch) { + errors.push_back(Error(c, "is unmarked nonmoving object in the snapshot")); + } + } else { + /* not in the snapshot; nothing to assert */ + } + } else if (bd->flags & BF_LARGE) { + if (! (bd->flags & BF_MARKED)) { + errors.push_back(Error(c, "is unmarked large object")); + } + } else { + if (!(bd->flags & BF_EVACUATED)) { + //errors.push_back(Error(c, "is in from-space block")); + } + } + } + } + + if (!errors.empty()) { + for (auto err : errors) { + std::cerr << err << "\n"; + } + dump_heap_to("heap.dot"); + abort(); + } +} + ===================================== rts/sm/NonMoving.c ===================================== @@ -1236,6 +1236,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) && defined(NONCONCURRENT_SWEEP) #if defined(DEBUG) + check_gc(); checkNonmovingHeap(&nonmovingHeap); checkSanity(true, true); #endif ===================================== rts/sm/NonMovingMark.c ===================================== @@ -1604,7 +1604,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) // selectee unreachable. However, we must mark the selectee regardless // to satisfy the snapshot invariant. PUSH_FIELD(sel, selectee); - nonmoving_eval_thunk_selector(queue, sel, origin); + //nonmoving_eval_thunk_selector(queue, sel, origin); break; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/110382863a713dc40f483e0fdc454077772dad4a...22cd7bb71e1565a48c43d38fe044c517d0aa1d30 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/110382863a713dc40f483e0fdc454077772dad4a...22cd7bb71e1565a48c43d38fe044c517d0aa1d30 You're receiving 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 Dec 6 12:56:45 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 06 Dec 2022 07:56:45 -0500 Subject: [Git][ghc/ghc][wip/tsan/nonmoving] 22 commits: rts: Encapsulate sched_state Message-ID: <638f3c0de5f08_17512e2fdaf3701348278@gitlab.mail> Ben Gamari pushed to branch wip/tsan/nonmoving at Glasgow Haskell Compiler / GHC Commits: 16a95a38 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Encapsulate sched_state - - - - - 6a4fd558 by Ben Gamari at 2022-12-06T07:56:28-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 149a91be by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Style fix - - - - - c5b78290 by Ben Gamari at 2022-12-06T07:56:28-05:00 compiler: Use release store in eager blackholing - - - - - ab656ae7 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Fix ordering of makeStableName - - - - - 93265cc3 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a6ca5913 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 60ffe15f by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 5e565a67 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Note race with wakeBlockingQueue - - - - - 1e04cf59 by Ben Gamari at 2022-12-06T07:56:28-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 2f938591 by Ben Gamari at 2022-12-06T07:56:28-05:00 nonmoving: Fix segment list races - - - - - 2726d722 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - d3cd49cf by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Eliminate race in bump_static_flag To ensure that we don't race with a mutator entering a new CAF we take the SM mutex before touching static_flag. The other option here would be to instead modify newCAF to use a CAS but the present approach is a bit safer. - - - - - 6f52b643 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 947feeab by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Fix races in collector status tracking Mark a number of accesses to do with tracking of the status of the concurrent collection thread as atomic. No interesting races here, merely necessary to satisfy TSAN. - - - - - 5b09ee54 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Make segment state updates atomic - - - - - 651f6f3f by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex by not dropping the SM_MUTEX in nonmovingCollect. This requires quite a bit of rejiggering but it does seem like a better strategy. - - - - - b2b2008f by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - c868eee0 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Make bitmap accesses atomic This is a benign race on any sensible hard since these are byte accesses. Nevertheless, atomic accesses are necessary to satisfy TSAN. - - - - - 87e3d20d by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Fix benign race in update remembered set check Relaxed load is fine here since we will take the lock before looking at the list. - - - - - a5b1d1d2 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Fix race in shortcutting We must use an acquire load to read the info table pointer since if we find an indirection we must be certain that we see the indirectee. - - - - - e090f105 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - 24 changed files: - compiler/GHC/StgToCmm/Bind.hs - rts/Capability.c - rts/Capability.h - rts/PrimOps.cmm - rts/Schedule.c - rts/Schedule.h - rts/StgMiscClosures.cmm - rts/eventlog/EventLog.c - rts/include/Cmm.h - rts/include/rts/Config.h - rts/include/rts/storage/ClosureMacros.h - rts/include/stg/SMP.h - rts/posix/Select.c - rts/posix/Signals.c - rts/sm/GC.c - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/NonMovingMark.h - rts/sm/NonMovingShortcut.c - rts/sm/Storage.c - rts/win32/AsyncMIO.c - rts/win32/AwaitEvent.c - rts/win32/ConsoleHandler.c Changes: ===================================== compiler/GHC/StgToCmm/Bind.hs ===================================== @@ -703,8 +703,8 @@ emitBlackHoleCode node = do whenUpdRemSetEnabled $ emitUpdRemSetPushThunk node emitStore (cmmOffsetW platform node (fixedHdrSizeW profile)) currentTSOExpr -- See Note [Heap memory barriers] in SMP.h. - emitPrimCall [] MO_WriteBarrier [] - emitStore node (CmmReg (CmmGlobal EagerBlackholeInfo)) + let w = wordWidth platform + emitPrimCall [] (MO_AtomicWrite w MemOrderRelease) [node, CmmReg (CmmGlobal EagerBlackholeInfo)] setupUpdate :: ClosureInfo -> LocalReg -> FCode () -> FCode () -- Nota Bene: this function does not change Node (even if it's a CAF), ===================================== rts/Capability.c ===================================== @@ -45,7 +45,7 @@ uint32_t enabled_capabilities = 0; // Capabilities, because there may be pointers to them in use // (e.g. threads in waitForCapability(), see #8209), so this is // an array of Capability* rather than an array of Capability. -Capability **capabilities = NULL; +Capability *capabilities[MAX_N_CAPABILITIES]; // Holds the Capability which last became free. This is used so that // an in-call has a chance of quickly finding a free Capability. @@ -82,7 +82,7 @@ Capability * rts_unsafeGetMyCapability (void) STATIC_INLINE bool globalWorkToDo (void) { - return RELAXED_LOAD(&sched_state) >= SCHED_INTERRUPTING + return getSchedState() >= SCHED_INTERRUPTING || getRecentActivity() == ACTIVITY_INACTIVE; // need to check for deadlock } #endif @@ -387,6 +387,12 @@ void initCapabilities (void) } #endif + if (RtsFlags.ParFlags.nCapabilities > MAX_N_CAPABILITIES) { + errorBelch("warning: this GHC runtime system only supports up to %d capabilities", + MAX_N_CAPABILITIES); + RtsFlags.ParFlags.nCapabilities = MAX_N_CAPABILITIES; + } + n_capabilities = 0; moreCapabilities(0, RtsFlags.ParFlags.nCapabilities); n_capabilities = RtsFlags.ParFlags.nCapabilities; @@ -394,7 +400,6 @@ void initCapabilities (void) #else /* !THREADED_RTS */ n_capabilities = 1; - capabilities = stgMallocBytes(sizeof(Capability*), "initCapabilities"); capabilities[0] = &MainCapability; initCapability(&MainCapability, 0); @@ -415,8 +420,6 @@ void moreCapabilities (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) { #if defined(THREADED_RTS) - Capability **new_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 @@ -428,30 +431,22 @@ moreCapabilities (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) // 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. - new_capabilities[0] = &MainCapability; + capabilities[0] = &MainCapability; initCapability(&MainCapability, 0); } else { for (uint32_t i = 0; i < to; i++) { - if (i < from) { - new_capabilities[i] = capabilities[i]; - } else { - new_capabilities[i] = stgMallocBytes(sizeof(Capability), + if (i >= from) { + capabilities[i] = stgMallocBytes(sizeof(Capability), "moreCapabilities"); - initCapability(new_capabilities[i], i); + initCapability(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 } @@ -581,7 +576,7 @@ releaseCapability_ (Capability* cap, // is interrupted, we only create a worker task if there // are threads that need to be completed. If the system is // shutting down, we never create a new worker. - if (RELAXED_LOAD(&sched_state) < SCHED_SHUTTING_DOWN || !emptyRunQueue(cap)) { + if (getSchedState() < SCHED_SHUTTING_DOWN || !emptyRunQueue(cap)) { debugTrace(DEBUG_sched, "starting new worker on capability %d", cap->no); startWorkerTask(cap); @@ -1153,7 +1148,7 @@ shutdownCapability (Capability *cap USED_IF_THREADS, // isn't safe, for one thing). for (i = 0; /* i < 50 */; i++) { - ASSERT(sched_state == SCHED_SHUTTING_DOWN); + ASSERT(getSchedState() == SCHED_SHUTTING_DOWN); debugTrace(DEBUG_sched, "shutting down capability %d, attempt %d", cap->no, i); @@ -1285,7 +1280,6 @@ freeCapabilities (void) #else freeCapability(&MainCapability); #endif - stgFree(capabilities); traceCapsetDelete(CAPSET_OSPROCESS_DEFAULT); traceCapsetDelete(CAPSET_CLOCKDOMAIN_DEFAULT); } ===================================== rts/Capability.h ===================================== @@ -261,11 +261,11 @@ INLINE_HEADER void releaseCapability_ (Capability* cap STG_UNUSED, // extern uint32_t enabled_capabilities; // Array of all the capabilities -extern Capability **capabilities; +extern Capability *capabilities[MAX_N_CAPABILITIES]; INLINE_HEADER Capability *getCapability(uint32_t i) { - return RELAXED_LOAD(&capabilities)[i]; + return RELAXED_LOAD(&capabilities[i]); } // ===================================== rts/PrimOps.cmm ===================================== @@ -776,7 +776,7 @@ stg_atomicModifyMutVar2zh ( gcptr mv, gcptr f ) StgThunk_payload(y,0) = z; retry: - x = StgMutVar_var(mv); + x = %relaxed StgMutVar_var(mv); StgThunk_payload(z,1) = x; #if defined(THREADED_RTS) (h) = prim %cmpxchgW(mv + SIZEOF_StgHeader + OFFSET_StgMutVar_var, x, y); @@ -829,7 +829,7 @@ stg_atomicModifyMutVarzuzh ( gcptr mv, gcptr f ) StgThunk_payload(z,0) = f; retry: - x = StgMutVar_var(mv); + x = %relaxed StgMutVar_var(mv); StgThunk_payload(z,1) = x; #if defined(THREADED_RTS) (h) = prim %cmpxchgW(mv + SIZEOF_StgHeader + OFFSET_StgMutVar_var, x, z); @@ -1728,7 +1728,7 @@ stg_takeMVarzh ( P_ mvar /* :: MVar a */ ) // Write barrier before we make the new MVAR_TSO_QUEUE // visible to other cores. // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -1895,7 +1895,7 @@ stg_putMVarzh ( P_ mvar, /* :: MVar a */ SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -2104,7 +2104,7 @@ stg_readMVarzh ( P_ mvar, /* :: MVar a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgTSO__link(CurrentTSO) = q; StgTSO_block_info(CurrentTSO) = mvar; @@ -2237,7 +2237,7 @@ stg_readIOPortzh ( P_ ioport /* :: IOPort a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgMVar_head(ioport) = q; StgTSO__link(CurrentTSO) = q; @@ -2389,7 +2389,8 @@ stg_makeStableNamezh ( P_ obj ) /* Is there already a StableName for this heap object? * stable_name_table is a pointer to an array of snEntry structs. */ - if ( snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) == NULL ) { + sn_obj = %acquire snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + if (sn_obj == NULL) { // At this point we have a snEntry, but it doesn't look as used to the // GC yet because we don't have a StableName object for the sn_obj field // (remember that sn_obj == NULL means the entry is free). So if we call @@ -2406,10 +2407,7 @@ stg_makeStableNamezh ( P_ obj ) // This will make the StableName# object visible to other threads; // be sure that its completely visible to other cores. // See Note [Heap memory barriers] in SMP.h. - prim_write_barrier; - snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; - } else { - sn_obj = snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + %release snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; } return (sn_obj); ===================================== rts/Schedule.c ===================================== @@ -91,7 +91,7 @@ StgWord recent_activity = ACTIVITY_YES; /* if this flag is set as well, give up execution * LOCK: none (changes monotonically) */ -volatile StgWord sched_state = SCHED_RUNNING; +StgWord sched_state = SCHED_RUNNING; /* * This mutex protects most of the global scheduler data in @@ -166,7 +166,6 @@ static void deleteAllThreads (void); static void deleteThread_(StgTSO *tso); #endif - /* --------------------------------------------------------------------------- Main scheduling loop. @@ -254,7 +253,7 @@ schedule (Capability *initialCapability, Task *task) // * We might be left with threads blocked in foreign calls, // we should really attempt to kill these somehow (TODO). - switch (RELAXED_LOAD(&sched_state)) { + switch (getSchedState()) { case SCHED_RUNNING: break; case SCHED_INTERRUPTING: @@ -266,7 +265,7 @@ schedule (Capability *initialCapability, Task *task) // other Capability did the final GC, or we did it above, // either way we can fall through to the SCHED_SHUTTING_DOWN // case now. - ASSERT(RELAXED_LOAD(&sched_state) == SCHED_SHUTTING_DOWN); + ASSERT(getSchedState() == SCHED_SHUTTING_DOWN); // fall through case SCHED_SHUTTING_DOWN: @@ -321,7 +320,7 @@ schedule (Capability *initialCapability, Task *task) */ awaitEvent (cap, emptyRunQueue(cap)); #else - ASSERT(sched_state >= SCHED_INTERRUPTING); + ASSERT(getSchedState() >= SCHED_INTERRUPTING); #endif } #endif @@ -371,7 +370,7 @@ schedule (Capability *initialCapability, Task *task) // killed, kill it now. This sometimes happens when a finalizer // thread is created by the final GC, or a thread previously // in a foreign call returns. - if (RELAXED_LOAD(&sched_state) >= SCHED_INTERRUPTING && + if (getSchedState() >= SCHED_INTERRUPTING && !(t->what_next == ThreadComplete || t->what_next == ThreadKilled)) { deleteThread(t); } @@ -688,7 +687,7 @@ scheduleYield (Capability **pcap, Task *task) if (!shouldYieldCapability(cap,task,false) && (!emptyRunQueue(cap) || !emptyInbox(cap) || - RELAXED_LOAD(&sched_state) >= SCHED_INTERRUPTING)) { + getSchedState() >= SCHED_INTERRUPTING)) { return; } @@ -991,7 +990,7 @@ scheduleDetectDeadlock (Capability **pcap, Task *task) } // either we have threads to run, or we were interrupted: - ASSERT(!emptyRunQueue(cap) || sched_state >= SCHED_INTERRUPTING); + ASSERT(!emptyRunQueue(cap) || getSchedState() >= SCHED_INTERRUPTING); return; } @@ -1343,7 +1342,7 @@ scheduleHandleThreadFinished (Capability *cap, Task *task, StgTSO *t) if (task->incall->ret) { *(task->incall->ret) = NULL; } - if (RELAXED_LOAD(&sched_state) >= SCHED_INTERRUPTING) { + if (getSchedState() >= SCHED_INTERRUPTING) { if (heap_overflow) { task->incall->rstat = HeapExhausted; } else { @@ -1431,7 +1430,7 @@ void stopAllCapabilitiesWith (Capability **pCap, Task *task, SyncType sync_type) acquireAllCapabilities(pCap ? *pCap : NULL, task); - pending_sync = 0; + RELAXED_STORE(&pending_sync, 0); signalCondition(&sync_finished_cond); } #endif @@ -1603,7 +1602,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, // cycle. #endif - if (RELAXED_LOAD(&sched_state) == SCHED_SHUTTING_DOWN) { + if (getSchedState() == SCHED_SHUTTING_DOWN) { // The final GC has already been done, and the system is // shutting down. We'll probably deadlock if we try to GC // now. @@ -1622,7 +1621,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, major_gc = (collect_gen == RtsFlags.GcFlags.generations-1); #if defined(THREADED_RTS) - if (RELAXED_LOAD(&sched_state) < SCHED_INTERRUPTING + if (getSchedState() < SCHED_INTERRUPTING && RtsFlags.ParFlags.parGcEnabled && collect_gen >= RtsFlags.ParFlags.parGcGen && ! oldest_gen->mark) @@ -1715,7 +1714,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, } if (was_syncing && (prev_sync == SYNC_GC_SEQ || prev_sync == SYNC_GC_PAR) && - !(RELAXED_LOAD(&sched_state) == SCHED_INTERRUPTING && force_major)) { + !(getSchedState() == SCHED_INTERRUPTING && force_major)) { // someone else had a pending sync request for a GC, so // let's assume GC has been done and we don't need to GC // again. @@ -1723,7 +1722,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, // need to do the final GC. return; } - if (RELAXED_LOAD(&sched_state) == SCHED_SHUTTING_DOWN) { + if (getSchedState() == SCHED_SHUTTING_DOWN) { // The scheduler might now be shutting down. We tested // this above, but it might have become true since then as // we yielded the capability in requestSync(). @@ -1826,7 +1825,7 @@ delete_threads_and_gc: * threads in the system. * Checking for major_gc ensures that the last GC is major. */ - if (RELAXED_LOAD(&sched_state) == SCHED_INTERRUPTING && major_gc) { + if (getSchedState() == SCHED_INTERRUPTING && major_gc) { deleteAllThreads(); #if defined(THREADED_RTS) // Discard all the sparks from every Capability. Why? @@ -1840,7 +1839,7 @@ delete_threads_and_gc: discardSparksCap(getCapability(i)); } #endif - RELAXED_STORE(&sched_state, SCHED_SHUTTING_DOWN); + setSchedState(SCHED_SHUTTING_DOWN); } /* @@ -1877,7 +1876,7 @@ delete_threads_and_gc: #if defined(THREADED_RTS) // reset pending_sync *before* GC, so that when the GC threads // emerge they don't immediately re-enter the GC. - pending_sync = 0; + RELAXED_STORE(&pending_sync, 0); signalCondition(&sync_finished_cond); GarbageCollect(collect_gen, heap_census, is_overflow_gc, deadlock_detect, gc_type, cap, idle_cap); #else @@ -1885,7 +1884,7 @@ delete_threads_and_gc: #endif // If we're shutting down, don't leave any idle GC work to do. - if (RELAXED_LOAD(&sched_state) == SCHED_SHUTTING_DOWN) { + if (getSchedState() == SCHED_SHUTTING_DOWN) { doIdleGCWork(cap, true /* all of it */); } @@ -1962,7 +1961,7 @@ delete_threads_and_gc: releaseGCThreads(cap, idle_cap); } #endif - if (heap_overflow && RELAXED_LOAD(&sched_state) == SCHED_RUNNING) { + if (heap_overflow && getSchedState() == SCHED_RUNNING) { // GC set the heap_overflow flag. We should throw an exception if we // can, or shut down otherwise. @@ -1974,7 +1973,7 @@ delete_threads_and_gc: // shutdown now. Ultimately we want the main thread to return to // its caller with HeapExhausted, at which point the caller should // call hs_exit(). The first step is to delete all the threads. - RELAXED_STORE(&sched_state, SCHED_INTERRUPTING); + setSchedState(SCHED_INTERRUPTING); goto delete_threads_and_gc; } @@ -2720,7 +2719,7 @@ startWorkerTasks (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) void initScheduler(void) { - sched_state = SCHED_RUNNING; + setSchedState(SCHED_RUNNING); setRecentActivity(ACTIVITY_YES); @@ -2763,8 +2762,8 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) Task *task = newBoundTask(); // If we haven't killed all the threads yet, do it now. - if (RELAXED_LOAD(&sched_state) < SCHED_SHUTTING_DOWN) { - RELAXED_STORE(&sched_state, SCHED_INTERRUPTING); + if (getSchedState() < SCHED_SHUTTING_DOWN) { + setSchedState(SCHED_INTERRUPTING); nonmovingStop(); Capability *cap = task->cap; waitForCapability(&cap,task); @@ -2772,7 +2771,7 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) ASSERT(task->incall->tso == NULL); releaseCapability(cap); } - ASSERT(sched_state == SCHED_SHUTTING_DOWN); + ASSERT(getSchedState() == SCHED_SHUTTING_DOWN); shutdownCapabilities(task, wait_foreign); @@ -2851,8 +2850,8 @@ performMajorGC(void) void interruptStgRts(void) { - ASSERT(sched_state != SCHED_SHUTTING_DOWN); - sched_state = SCHED_INTERRUPTING; + ASSERT(getSchedState() != SCHED_SHUTTING_DOWN); + setSchedState(SCHED_INTERRUPTING); interruptAllCapabilities(); #if defined(THREADED_RTS) wakeUpRts(); ===================================== rts/Schedule.h ===================================== @@ -64,11 +64,23 @@ void releaseAllCapabilities(uint32_t n, Capability *keep_cap, Task *task); /* The state of the scheduler. This is used to control the sequence * of events during shutdown. See Note [shutdown] in Schedule.c. */ -#define SCHED_RUNNING 0 /* running as normal */ -#define SCHED_INTERRUPTING 1 /* before threads are deleted */ -#define SCHED_SHUTTING_DOWN 2 /* final shutdown */ +enum SchedState { + SCHED_RUNNING = 0, /* running as normal */ + SCHED_INTERRUPTING = 1, /* before threads are deleted */ + SCHED_SHUTTING_DOWN = 2, /* final shutdown */ +}; + +extern StgWord sched_state; -extern volatile StgWord sched_state; +INLINE_HEADER void setSchedState(enum SchedState ss) +{ + SEQ_CST_STORE_ALWAYS(&sched_state, (StgWord) ss); +} + +INLINE_HEADER enum SchedState getSchedState(void) +{ + return (enum SchedState) SEQ_CST_LOAD_ALWAYS(&sched_state); +} /* * flag that tracks whether we have done any execution in this time ===================================== rts/StgMiscClosures.cmm ===================================== @@ -540,7 +540,8 @@ retry: return (p); } - info = GET_INFO(p); + // May race with OVERWRITE_INFO in wakeBlockingQueue() + info = %relaxed GET_INFO(p); if (info == stg_IND_info) { // This could happen, if e.g. we got a BLOCKING_QUEUE that has // just been replaced with an IND by another thread in ===================================== rts/eventlog/EventLog.c ===================================== @@ -478,7 +478,7 @@ endEventLogging(void) // // N.B. Don't flush if shutting down: this was done in // finishCapEventLogging and the capabilities have already been freed. - if (sched_state != SCHED_SHUTTING_DOWN) { + if (getSchedState() != SCHED_SHUTTING_DOWN) { flushEventLog(NULL); } ===================================== rts/include/Cmm.h ===================================== @@ -278,8 +278,7 @@ // "used". #define LOAD_INFO_ACQUIRE(ret,x) \ - info = %INFO_PTR(UNTAG(x)); \ - prim_read_barrier; + info = %acquire StgHeader_info(UNTAG(x)); #define UNTAG_IF_PROF(x) UNTAG(x) @@ -289,8 +288,7 @@ if (GETTAG(x) != 0) { \ ret(x); \ } \ - info = %INFO_PTR(x); \ - prim_read_barrier; + info = %acquire StgHeader_info(x); #define UNTAG_IF_PROF(x) (x) /* already untagged */ ===================================== rts/include/rts/Config.h ===================================== @@ -76,3 +76,9 @@ code. #if defined(DEBUG) #define PROF_SPIN #endif + +#if defined(THREADED_RTS) +#define MAX_N_CAPABILITIES 256 +#else +#define MAX_N_CAPABILITIES 1 +#endif ===================================== rts/include/rts/storage/ClosureMacros.h ===================================== @@ -97,6 +97,12 @@ EXTERN_INLINE const StgInfoTable *get_itbl(const StgClosure *c) return INFO_PTR_TO_STRUCT(RELAXED_LOAD(&c->header.info)); } +EXTERN_INLINE const StgInfoTable *get_itbl_acquire(const StgClosure *c); +EXTERN_INLINE const StgInfoTable *get_itbl_acquire(const StgClosure *c) +{ + return INFO_PTR_TO_STRUCT(ACQUIRE_LOAD(&c->header.info)); +} + EXTERN_INLINE const StgRetInfoTable *get_ret_itbl(const StgClosure *c); EXTERN_INLINE const StgRetInfoTable *get_ret_itbl(const StgClosure *c) { ===================================== rts/include/stg/SMP.h ===================================== @@ -574,6 +574,7 @@ load_load_barrier(void) { // These are typically necessary only in very specific cases (e.g. WSDeque) // where the ordered operations aren't expressive enough to capture the desired // ordering. +#define ACQUIRE_FENCE() __atomic_thread_fence(__ATOMIC_ACQUIRE) #define RELEASE_FENCE() __atomic_thread_fence(__ATOMIC_RELEASE) #define SEQ_CST_FENCE() __atomic_thread_fence(__ATOMIC_SEQ_CST) @@ -608,6 +609,7 @@ EXTERN_INLINE void load_load_barrier () {} /* nothing */ #define SEQ_CST_RELAXED_CAS(p,o,n) cas(p,o,n) // Fences +#define ACQUIRE_FENCE() #define RELEASE_FENCE() #define SEQ_CST_FENCE() ===================================== rts/posix/Select.c ===================================== @@ -362,7 +362,7 @@ awaitEvent(Capability *cap, bool wait) /* we were interrupted, return to the scheduler immediately. */ - if (sched_state >= SCHED_INTERRUPTING) { + if (getSchedState() >= SCHED_INTERRUPTING) { return; /* still hold the lock */ } @@ -459,7 +459,7 @@ awaitEvent(Capability *cap, bool wait) } } - } while (wait && sched_state == SCHED_RUNNING + } while (wait && getSchedState() == SCHED_RUNNING && emptyRunQueue(cap)); } ===================================== rts/posix/Signals.c ===================================== @@ -350,7 +350,7 @@ anyUserHandlers(void) void awaitUserSignals(void) { - while (!signals_pending() && sched_state == SCHED_RUNNING) { + while (!signals_pending() && getSchedState() == SCHED_RUNNING) { pause(); } } @@ -521,7 +521,7 @@ shutdown_handler(int sig STG_UNUSED) // If we're already trying to interrupt the RTS, terminate with // extreme prejudice. So the first ^C tries to exit the program // cleanly, and the second one just kills it. - if (sched_state >= SCHED_INTERRUPTING) { + if (getSchedState() >= SCHED_INTERRUPTING) { stg_exit(EXIT_INTERRUPTED); } else { interruptStgRts(); ===================================== rts/sm/GC.c ===================================== @@ -355,7 +355,7 @@ GarbageCollect (uint32_t collect_gen, deadlock_detect_gc = deadlock_detect; #if defined(THREADED_RTS) - if (major_gc && RtsFlags.GcFlags.useNonmoving && concurrent_coll_running) { + if (major_gc && RtsFlags.GcFlags.useNonmoving && RELAXED_LOAD(&concurrent_coll_running)) { /* If there is already a concurrent major collection running then * there is no benefit to starting another. * TODO: Catch heap-size runaway. @@ -833,23 +833,18 @@ GarbageCollect (uint32_t collect_gen, live_blocks += genLiveBlocks(gen); // add in the partial blocks in the gen_workspaces - { - uint32_t i; - for (i = 0; i < getNumCapabilities(); i++) { - live_words += gcThreadLiveWords(i, gen->no); - live_blocks += gcThreadLiveBlocks(i, gen->no); - } + for (uint32_t i = 0; i < getNumCapabilities(); i++) { + live_words += gcThreadLiveWords(i, gen->no); + live_blocks += gcThreadLiveBlocks(i, gen->no); } } // for all generations // Flush the update remembered sets. See Note [Eager update remembered set // flushing] in NonMovingMark.c if (RtsFlags.GcFlags.useNonmoving) { - RELEASE_SM_LOCK; for (n = 0; n < getNumCapabilities(); n++) { - nonmovingAddUpdRemSetBlocks(&getCapability(n)->upd_rem_set.queue); + nonmovingAddUpdRemSetBlocks(&getCapability(n)->upd_rem_set); } - ACQUIRE_SM_LOCK; } // Mark and sweep the oldest generation. @@ -870,8 +865,6 @@ GarbageCollect (uint32_t collect_gen, // old_weak_ptr_list should be empty. ASSERT(oldest_gen->old_weak_ptr_list == NULL); - // we may need to take the lock to allocate mark queue blocks - RELEASE_SM_LOCK; // dead_weak_ptr_list contains weak pointers with dead keys. Those need to // be kept alive because we'll use them in finalizeSchedulers(). Similarly // resurrected_threads are also going to be used in resurrectedThreads() @@ -881,10 +874,9 @@ GarbageCollect (uint32_t collect_gen, #if !defined(THREADED_RTS) // In the non-threaded runtime this is the only time we push to the // upd_rem_set - nonmovingAddUpdRemSetBlocks(&gct->cap->upd_rem_set.queue); + nonmovingAddUpdRemSetBlocks(&gct->cap->upd_rem_set); #endif nonmovingCollect(&dead_weak_ptr_list, &resurrected_threads); - ACQUIRE_SM_LOCK; } // Update the max size of older generations after a major GC: ===================================== rts/sm/NonMoving.c ===================================== @@ -85,6 +85,10 @@ Mutex concurrent_coll_finished_lock; * - A set of *filled* segments, which contain no unallocated blocks and will * be collected during the next major GC cycle * + * These sets are maintained as atomic singly-linked lists. This is not + * susceptible to the ABA problem since we are guaranteed to push a given + * segment to a list only once per garbage collection cycle. + * * Storage for segments is allocated using the block allocator using an aligned * group of NONMOVING_SEGMENT_BLOCKS blocks. This makes the task of locating * the segment header for a clone a simple matter of bit-masking (as @@ -518,7 +522,7 @@ static void nonmovingInitSegment(struct NonmovingSegment *seg, uint8_t log_block void nonmovingPushFreeSegment(struct NonmovingSegment *seg) { // See Note [Live data accounting in nonmoving collector]. - if (nonmovingHeap.n_free > NONMOVING_MAX_FREE) { + if (RELAXED_LOAD(&nonmovingHeap.n_free) > NONMOVING_MAX_FREE) { bdescr *bd = Bdescr((StgPtr) seg); ACQUIRE_SM_LOCK; ASSERT(oldest_gen->n_blocks >= bd->blocks); @@ -543,7 +547,7 @@ void nonmovingPushFreeSegment(struct NonmovingSegment *seg) static struct NonmovingSegment *nonmovingPopFreeSegment(void) { while (true) { - struct NonmovingSegment *seg = nonmovingHeap.free; + struct NonmovingSegment *seg = ACQUIRE_LOAD(&nonmovingHeap.free); if (seg == NULL) { return NULL; } @@ -641,13 +645,15 @@ static bool advance_next_free(struct NonmovingSegment *seg, const unsigned int b static struct NonmovingSegment *pop_active_segment(struct NonmovingAllocator *alloca) { while (true) { - struct NonmovingSegment *seg = alloca->active; + // Synchronizes with CAS in nonmovingPushActiveSegment + struct NonmovingSegment *seg = ACQUIRE_LOAD(&alloca->active); if (seg == NULL) { return NULL; } + struct NonmovingSegment *next = RELAXED_LOAD(&seg->link); if (cas((StgVolatilePtr) &alloca->active, (StgWord) seg, - (StgWord) seg->link) == (StgWord) seg) { + (StgWord) next) == (StgWord) seg) { return seg; } } @@ -742,11 +748,12 @@ void nonmovingStop(void) { if (! RtsFlags.GcFlags.useNonmoving) return; #if defined(THREADED_RTS) - if (mark_thread) { + if (RELAXED_LOAD(&mark_thread)) { debugTrace(DEBUG_nonmoving_gc, "waiting for nonmoving collector thread to terminate"); ACQUIRE_LOCK(&concurrent_coll_finished_lock); waitCondition(&concurrent_coll_finished, &concurrent_coll_finished_lock); + RELEASE_LOCK(&concurrent_coll_finished_lock); } #endif } @@ -759,6 +766,9 @@ void nonmovingExit(void) nonmovingStop(); #if defined(THREADED_RTS) + ACQUIRE_LOCK(&nonmoving_collection_mutex); + RELEASE_LOCK(&nonmoving_collection_mutex); + closeMutex(&concurrent_coll_finished_lock); closeCondition(&concurrent_coll_finished); closeMutex(&nonmoving_collection_mutex); @@ -892,7 +902,7 @@ static void nonmovingPrepareMark(void) static void nonmovingMarkWeakPtrList(MarkQueue *mark_queue, StgWeak *dead_weak_ptr_list) { for (StgWeak *w = oldest_gen->weak_ptr_list; w; w = w->link) { - markQueuePushClosure_(mark_queue, (StgClosure*)w); + markQueuePushClosureGC(mark_queue, (StgClosure*)w); // Do not mark finalizers and values here, those fields will be marked // in `nonmovingMarkDeadWeaks` (for dead weaks) or // `nonmovingTidyWeaks` (for live weaks) @@ -911,8 +921,14 @@ static void nonmovingMarkWeakPtrList(MarkQueue *mark_queue, StgWeak *dead_weak_p // - So, to be able to traverse `dead_weak_ptr_list` and run finalizers we // need to mark it. for (StgWeak *w = dead_weak_ptr_list; w; w = w->link) { - markQueuePushClosure_(mark_queue, (StgClosure*)w); - nonmovingMarkDeadWeak(mark_queue, w); + markQueuePushClosureGC(mark_queue, (StgClosure*)w); + + // Mark the value and finalizer since they will be needed regardless of + // whether we find the weak is live. + if (w->cfinalizers != &stg_NO_FINALIZER_closure) { + markQueuePushClosureGC(mark_queue, w->value); + } + markQueuePushClosureGC(mark_queue, w->finalizer); } } @@ -921,7 +937,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) #if defined(THREADED_RTS) // We can't start a new collection until the old one has finished // We also don't run in final GC - if (concurrent_coll_running || sched_state > SCHED_RUNNING) { + if (RELAXED_LOAD(&concurrent_coll_running) || getSchedState() > SCHED_RUNNING) { return; } #endif @@ -953,7 +969,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) // Mark threads resurrected during moving heap scavenging for (StgTSO *tso = *resurrected_threads; tso != END_TSO_QUEUE; tso = tso->global_link) { - markQueuePushClosure_(mark_queue, (StgClosure*)tso); + markQueuePushClosureGC(mark_queue, (StgClosure*)tso); } trace(TRACE_nonmoving_gc, "Finished marking roots for nonmoving GC"); @@ -994,14 +1010,16 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) // again for the sync if we let it go, because it'll immediately start doing // a major GC, because that's what we do when exiting scheduler (see // exitScheduler()). - if (sched_state == SCHED_RUNNING) { - concurrent_coll_running = true; + if (getSchedState() == SCHED_RUNNING) { + RELAXED_STORE(&concurrent_coll_running, true); nonmoving_write_barrier_enabled = true; debugTrace(DEBUG_nonmoving_gc, "Starting concurrent mark thread"); - if (createOSThread(&mark_thread, "non-moving mark thread", + OSThreadId thread; + if (createOSThread(&thread, "non-moving mark thread", nonmovingConcurrentMark, mark_queue) != 0) { barf("nonmovingCollect: failed to spawn mark thread: %s", strerror(errno)); } + RELAXED_STORE(&mark_thread, thread); } else { nonmovingConcurrentMark(mark_queue); } @@ -1086,7 +1104,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * Task *task = newBoundTask(); // If at this point if we've decided to exit then just return - if (sched_state > SCHED_RUNNING) { + if (getSchedState() > SCHED_RUNNING) { // Note that we break our invariants here and leave segments in // nonmovingHeap.sweep_list, don't free nonmoving_large_objects etc. // However because we won't be running mark-sweep in the final GC this @@ -1240,12 +1258,12 @@ finish: exitMyTask(); // We are done... - mark_thread = 0; + RELAXED_STORE(&mark_thread, 0); stat_endNonmovingGc(); // Signal that the concurrent collection is finished, allowing the next // non-moving collection to proceed - concurrent_coll_running = false; + RELAXED_STORE(&concurrent_coll_running, false); signalCondition(&concurrent_coll_finished); RELEASE_LOCK(&nonmoving_collection_mutex); #endif ===================================== rts/sm/NonMoving.h ===================================== @@ -44,7 +44,7 @@ enum NonmovingSegmentState { FREE, CURRENT, ACTIVE, FILLED, FILLED_SWEEPING }; -#define SET_SEGMENT_STATE(seg, st) (seg)->state = (st) +#define SET_SEGMENT_STATE(seg, st) RELAXED_STORE(&(seg)->state, (st)) #else #define SET_SEGMENT_STATE(_seg,_st) #endif @@ -169,7 +169,7 @@ INLINE_HEADER void nonmovingPushActiveSegment(struct NonmovingSegment *seg) nonmovingHeap.allocators[nonmovingSegmentLogBlockSize(seg) - NONMOVING_ALLOCA0]; SET_SEGMENT_STATE(seg, ACTIVE); while (true) { - struct NonmovingSegment *current_active = (struct NonmovingSegment*)VOLATILE_LOAD(&alloc->active); + struct NonmovingSegment *current_active = RELAXED_LOAD(&alloc->active); seg->link = current_active; if (cas((StgVolatilePtr) &alloc->active, (StgWord) current_active, (StgWord) seg) == (StgWord) current_active) { break; @@ -184,8 +184,8 @@ INLINE_HEADER void nonmovingPushFilledSegment(struct NonmovingSegment *seg) nonmovingHeap.allocators[nonmovingSegmentLogBlockSize(seg) - NONMOVING_ALLOCA0]; SET_SEGMENT_STATE(seg, FILLED); while (true) { - struct NonmovingSegment *current_filled = (struct NonmovingSegment*)VOLATILE_LOAD(&alloc->filled); - seg->link = current_filled; + struct NonmovingSegment *current_filled = (struct NonmovingSegment*) RELAXED_LOAD(&alloc->filled); + RELAXED_STORE(&seg->link, current_filled); if (cas((StgVolatilePtr) &alloc->filled, (StgWord) current_filled, (StgWord) seg) == (StgWord) current_filled) { break; } @@ -276,12 +276,12 @@ extern uint8_t nonmovingMarkEpoch; INLINE_HEADER void nonmovingSetMark(struct NonmovingSegment *seg, nonmoving_block_idx i) { - seg->bitmap[i] = nonmovingMarkEpoch; + RELAXED_STORE(&seg->bitmap[i], nonmovingMarkEpoch); } INLINE_HEADER uint8_t nonmovingGetMark(struct NonmovingSegment *seg, nonmoving_block_idx i) { - return seg->bitmap[i]; + return RELAXED_LOAD(&seg->bitmap[i]); } INLINE_HEADER void nonmovingSetClosureMark(StgPtr p) ===================================== rts/sm/NonMovingMark.c ===================================== @@ -27,6 +27,8 @@ #include "sm/Storage.h" #include "CNF.h" +static void nonmovingResetUpdRemSetQueue (MarkQueue *rset); +static void nonmovingResetUpdRemSet (UpdRemSet *rset); static bool check_in_nonmoving_heap(StgClosure *p); static void mark_closure (MarkQueue *queue, const StgClosure *p, StgClosure **origin); static void trace_tso (MarkQueue *queue, StgTSO *tso); @@ -261,17 +263,9 @@ static uint32_t markQueueLength(MarkQueue *q); #endif static void init_mark_queue_(MarkQueue *queue); -/* Transfers the given capability's update-remembered set to the global - * remembered set. - * - * Really the argument type should be UpdRemSet* but this would be rather - * inconvenient without polymorphism. - */ -void nonmovingAddUpdRemSetBlocks(MarkQueue *rset) +static void nonmovingAddUpdRemSetBlocks_(MarkQueue *rset) { - if (markQueueIsEmpty(rset)) return; - - // find the tail of the queue + // find the tail of the remembered set mark queue bdescr *start = rset->blocks; bdescr *end = start; while (end->link != NULL) @@ -282,14 +276,45 @@ void nonmovingAddUpdRemSetBlocks(MarkQueue *rset) end->link = upd_rem_set_block_list; upd_rem_set_block_list = start; RELEASE_LOCK(&upd_rem_set_lock); +} + +/* + * Transfers the given capability's update-remembered set to the global + * remembered set. + * + * Really the argument type should be UpdRemSet* but this would be rather + * inconvenient without polymorphism. + */ +static void nonmovingAddUpdRemSetBlocks_lock(MarkQueue *rset) +{ + if (markQueueIsEmpty(rset)) return; - // Reset remembered set + nonmovingAddUpdRemSetBlocks_(rset); + // Reset the state of the remembered set. ACQUIRE_SM_LOCK; init_mark_queue_(rset); rset->is_upd_rem_set = true; RELEASE_SM_LOCK; } +/* + * Transfers the given capability's update-remembered set to the global + * remembered set. + * + * Really the argument type should be UpdRemSet* but this would be rather + * inconvenient without polymorphism. + * + * Caller must hold SM_LOCK. + */ +void nonmovingAddUpdRemSetBlocks(UpdRemSet *rset) +{ + if (markQueueIsEmpty(&rset->queue)) return; + + nonmovingAddUpdRemSetBlocks_(&rset->queue); + init_mark_queue_(&rset->queue); + rset->queue.is_upd_rem_set = true; +} + #if defined(THREADED_RTS) /* Called by capabilities to flush their update remembered sets when * synchronising with the non-moving collector as it transitions from mark to @@ -301,7 +326,7 @@ void nonmovingFlushCapUpdRemSetBlocks(Capability *cap) "Capability %d flushing update remembered set: %d", cap->no, markQueueLength(&cap->upd_rem_set.queue)); traceConcUpdRemSetFlush(cap); - nonmovingAddUpdRemSetBlocks(&cap->upd_rem_set.queue); + nonmovingAddUpdRemSetBlocks_lock(&cap->upd_rem_set.queue); atomic_inc(&upd_rem_set_flush_count, 1); signalCondition(&upd_rem_set_flushed_cond); // After this mutation will remain suspended until nonmovingFinishFlush @@ -399,7 +424,7 @@ void nonmovingFinishFlush(Task *task) { // See Note [Unintentional marking in resurrectThreads] for (uint32_t i = 0; i < getNumCapabilities(); i++) { - reset_upd_rem_set(&getCapability(i)->upd_rem_set); + nonmovingResetUpdRemSet(&getCapability(i)->upd_rem_set); } // Also reset upd_rem_set_block_list in case some of the UpdRemSets were // filled and we flushed them. @@ -424,7 +449,8 @@ push (MarkQueue *q, const MarkQueueEnt *ent) if (q->top->head == MARK_QUEUE_BLOCK_ENTRIES) { // Yes, this block is full. if (q->is_upd_rem_set) { - nonmovingAddUpdRemSetBlocks(q); + // Flush the block to the global update remembered set + nonmovingAddUpdRemSetBlocks_lock(q); } else { // allocate a fresh block. ACQUIRE_SM_LOCK; @@ -780,7 +806,7 @@ void markQueuePushClosure (MarkQueue *q, /* TODO: Do we really never want to specify the origin here? */ void markQueueAddRoot (MarkQueue* q, StgClosure** root) { - markQueuePushClosure(q, *root, NULL); + markQueuePushClosureGC(q, *root); } /* Push a closure to the mark queue without origin information */ @@ -908,18 +934,24 @@ void initMarkQueue (MarkQueue *queue) } /* Must hold sm_mutex. */ -void init_upd_rem_set (UpdRemSet *rset) +void nonmovingInitUpdRemSet (UpdRemSet *rset) { init_mark_queue_(&rset->queue); rset->queue.is_upd_rem_set = true; } -void reset_upd_rem_set (UpdRemSet *rset) +static void nonmovingResetUpdRemSetQueue (MarkQueue *rset) { // UpdRemSets always have one block for the mark queue. This assertion is to // update this code if we change that. - ASSERT(rset->queue.blocks->link == NULL); - rset->queue.top->head = 0; + ASSERT(rset->is_upd_rem_set); + ASSERT(rset->blocks->link == NULL); + rset->top->head = 0; +} + +void nonmovingResetUpdRemSet (UpdRemSet *rset) +{ + nonmovingResetUpdRemSetQueue(&rset->queue); } void freeMarkQueue (MarkQueue *queue) @@ -1187,15 +1219,17 @@ trace_stack (MarkQueue *queue, StgStack *stack) static bool bump_static_flag(StgClosure **link_field, StgClosure *q STG_UNUSED) { - while (1) { - StgWord link = (StgWord) *link_field; - StgWord new = (link & ~STATIC_BITS) | static_flag; - if ((link & STATIC_BITS) == static_flag) - return false; - else if (cas((StgVolatilePtr) link_field, link, new) == link) { - return true; - } + ACQUIRE_SM_LOCK; + bool needs_marking; + StgWord link = (StgWord) *link_field; + if ((link & STATIC_BITS) == static_flag) { + needs_marking = false; + } else { + *link_field = (StgClosure *) ((link & ~STATIC_BITS) | static_flag); + needs_marking = true; } + RELEASE_SM_LOCK; + return needs_marking; } /* N.B. p0 may be tagged */ @@ -1211,10 +1245,16 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) StgWord tag = GET_CLOSURE_TAG(p); p = UNTAG_CLOSURE(p); + // Push an immutable field to the mark queue. # define PUSH_FIELD(obj, field) \ markQueuePushClosure(queue, \ (StgClosure *) (obj)->field, \ (StgClosure **) &(obj)->field) + // Push a mutable field to the mark queue. +# define PUSH_FIELD_MUT(obj, field) \ + markQueuePushClosure(queue, \ + (StgClosure *) ACQUIRE_LOAD(&(obj)->field), \ + (StgClosure **) &(obj)->field) if (!HEAP_ALLOCED_GC(p)) { const StgInfoTable *info = get_itbl(p); @@ -1281,7 +1321,10 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) bd = Bdescr((StgPtr) p); - if (bd->gen != oldest_gen) { + // This must be a relaxed load since the object may be a large object, + // in which case evacuation by the moving collector will result in + // mutation. + if (RELAXED_LOAD(&bd->gen) != oldest_gen) { // Here we have an object living outside of the non-moving heap. While // we likely evacuated nearly everything to the nonmoving heap during // preparation there are nevertheless a few ways in which we might trace @@ -1386,16 +1429,16 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) case MVAR_CLEAN: case MVAR_DIRTY: { StgMVar *mvar = (StgMVar *) p; - PUSH_FIELD(mvar, head); - PUSH_FIELD(mvar, tail); - PUSH_FIELD(mvar, value); + PUSH_FIELD_MUT(mvar, head); + PUSH_FIELD_MUT(mvar, tail); + PUSH_FIELD_MUT(mvar, value); break; } case TVAR: { StgTVar *tvar = ((StgTVar *)p); - PUSH_FIELD(tvar, current_value); - PUSH_FIELD(tvar, first_watch_queue_entry); + PUSH_FIELD_MUT(tvar, current_value); + PUSH_FIELD_MUT(tvar, first_watch_queue_entry); break; } @@ -1510,8 +1553,12 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) } case BLACKHOLE: { - PUSH_FIELD((StgInd *) p, indirectee); - StgClosure *indirectee = ((StgInd*)p)->indirectee; + // Synchronizes with the release-store in updateWithIndirection. + // See Note [Heap memory barriers] in SMP.h. + StgInd *ind = (StgInd *) p; + ACQUIRE_FENCE(); + StgClosure *indirectee = RELAXED_LOAD(&ind->indirectee); + markQueuePushClosure(queue, indirectee, &ind->indirectee); if (GET_CLOSURE_TAG(indirectee) == 0 || origin == NULL) { // do nothing } else { @@ -1522,7 +1569,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) case MUT_VAR_CLEAN: case MUT_VAR_DIRTY: - PUSH_FIELD((StgMutVar *)p, var); + PUSH_FIELD_MUT((StgMutVar *)p, var); break; case BLOCKING_QUEUE: { @@ -1577,7 +1624,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) StgSmallMutArrPtrs *arr = (StgSmallMutArrPtrs *) p; for (StgWord i = 0; i < arr->ptrs; i++) { StgClosure **field = &arr->payload[i]; - markQueuePushClosure(queue, *field, field); + markQueuePushClosure(queue, ACQUIRE_LOAD(field), field); } break; } @@ -1639,6 +1686,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) } # undef PUSH_FIELD +# undef PUSH_FIELD_MUT /* Set the mark bit: it's important that we do this only after we actually push * the object's pointers since in the case of marking stacks there may be a @@ -1719,13 +1767,16 @@ nonmovingMark (MarkQueue *queue) end = arr->ptrs; } for (StgWord i = start; i < end; i++) { - markQueuePushClosure_(queue, arr->payload[i]); + StgClosure *c = ACQUIRE_LOAD(&arr->payload[i]); + markQueuePushClosure_(queue, c); } break; } case NULL_ENTRY: // Perhaps the update remembered set has more to mark... - if (upd_rem_set_block_list) { + // N.B. This must be atomic since we have not yet taken + // upd_rem_set_lock. + if (RELAXED_LOAD(&upd_rem_set_block_list) != NULL) { ACQUIRE_LOCK(&upd_rem_set_lock); bdescr *old = queue->blocks; queue->blocks = upd_rem_set_block_list; ===================================== rts/sm/NonMovingMark.h ===================================== @@ -137,8 +137,7 @@ extern bdescr *upd_rem_set_block_list; void nonmovingMarkInitUpdRemSet(void); -void init_upd_rem_set(UpdRemSet *rset); -void reset_upd_rem_set(UpdRemSet *rset); +void nonmovingInitUpdRemSet(UpdRemSet *rset); void updateRemembSetPushClosure(Capability *cap, StgClosure *p); void updateRemembSetPushThunk(Capability *cap, StgThunk *p); void updateRemembSetPushTSO(Capability *cap, StgTSO *tso); @@ -165,7 +164,7 @@ void nonmovingResurrectThreads(struct MarkQueue_ *queue, StgTSO **resurrected_th bool nonmovingIsAlive(StgClosure *p); void nonmovingMarkDeadWeak(struct MarkQueue_ *queue, StgWeak *w); void nonmovingMarkLiveWeak(struct MarkQueue_ *queue, StgWeak *w); -void nonmovingAddUpdRemSetBlocks(struct MarkQueue_ *rset); +void nonmovingAddUpdRemSetBlocks(UpdRemSet *rset); void markQueuePush(MarkQueue *q, const MarkQueueEnt *ent); void markQueuePushClosureGC(MarkQueue *q, StgClosure *p); ===================================== rts/sm/NonMovingShortcut.c ===================================== @@ -153,7 +153,8 @@ selectee_changed: // Selectee is a non-moving object, mark it. markQueuePushClosure(queue, selectee, NULL); - const StgInfoTable *selectee_info_tbl = get_itbl(selectee); + // This may synchronize with the release in updateWithIndirection. + const StgInfoTable *selectee_info_tbl = get_itbl_acquire(selectee); switch (selectee_info_tbl->type) { case WHITEHOLE: { // Probably a loop. Abort. ===================================== rts/sm/Storage.c ===================================== @@ -325,7 +325,7 @@ void storageAddCapabilities (uint32_t from, uint32_t to) if (RtsFlags.GcFlags.useNonmoving) { nonmovingAddCapabilities(to); for (i = 0; i < to; ++i) { - init_upd_rem_set(&getCapability(i)->upd_rem_set); + nonmovingInitUpdRemSet(&getCapability(i)->upd_rem_set); } } ===================================== rts/win32/AsyncMIO.c ===================================== @@ -247,7 +247,7 @@ start: if (completed_hw == 0) { // empty table, drop lock and wait OS_RELEASE_LOCK(&queue_lock); - if ( wait && sched_state == SCHED_RUNNING ) { + if ( wait && getSchedState() == SCHED_RUNNING ) { DWORD dwRes = WaitForMultipleObjects(2, wait_handles, FALSE, INFINITE); switch (dwRes) { ===================================== rts/win32/AwaitEvent.c ===================================== @@ -56,7 +56,7 @@ awaitEvent(Capability *cap, bool wait) // - the run-queue is now non- empty } while (wait - && sched_state == SCHED_RUNNING + && getSchedState() == SCHED_RUNNING && emptyRunQueue(cap) ); } ===================================== rts/win32/ConsoleHandler.c ===================================== @@ -91,7 +91,7 @@ static BOOL WINAPI shutdown_handler(DWORD dwCtrlType) // If we're already trying to interrupt the RTS, terminate with // extreme prejudice. So the first ^C tries to exit the program // cleanly, and the second one just kills it. - if (sched_state >= SCHED_INTERRUPTING) { + if (getSchedState() >= SCHED_INTERRUPTING) { stg_exit(EXIT_INTERRUPTED); } else { interruptStgRts(); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/801f97e827c3a661116b212c89c0f04d725e0776...e090f10543753358d5be370c721a9db9b2d43246 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/801f97e827c3a661116b212c89c0f04d725e0776...e090f10543753358d5be370c721a9db9b2d43246 You're receiving 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 Dec 6 12:57:06 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 06 Dec 2022 07:57:06 -0500 Subject: [Git][ghc/ghc][wip/T22264] 52 commits: rts: Encapsulate sched_state Message-ID: <638f3c22d90af_17512e13299fec13507a1@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC Commits: 16a95a38 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Encapsulate sched_state - - - - - 6a4fd558 by Ben Gamari at 2022-12-06T07:56:28-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 149a91be by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Style fix - - - - - c5b78290 by Ben Gamari at 2022-12-06T07:56:28-05:00 compiler: Use release store in eager blackholing - - - - - ab656ae7 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Fix ordering of makeStableName - - - - - 93265cc3 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a6ca5913 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 60ffe15f by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 5e565a67 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Note race with wakeBlockingQueue - - - - - 1e04cf59 by Ben Gamari at 2022-12-06T07:56:28-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 2f938591 by Ben Gamari at 2022-12-06T07:56:28-05:00 nonmoving: Fix segment list races - - - - - 2726d722 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - d3cd49cf by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Eliminate race in bump_static_flag To ensure that we don't race with a mutator entering a new CAF we take the SM mutex before touching static_flag. The other option here would be to instead modify newCAF to use a CAS but the present approach is a bit safer. - - - - - 6f52b643 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 947feeab by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Fix races in collector status tracking Mark a number of accesses to do with tracking of the status of the concurrent collection thread as atomic. No interesting races here, merely necessary to satisfy TSAN. - - - - - 5b09ee54 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Make segment state updates atomic - - - - - 651f6f3f by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex by not dropping the SM_MUTEX in nonmovingCollect. This requires quite a bit of rejiggering but it does seem like a better strategy. - - - - - b2b2008f by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - c868eee0 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Make bitmap accesses atomic This is a benign race on any sensible hard since these are byte accesses. Nevertheless, atomic accesses are necessary to satisfy TSAN. - - - - - 87e3d20d by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Fix benign race in update remembered set check Relaxed load is fine here since we will take the lock before looking at the list. - - - - - a5b1d1d2 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Fix race in shortcutting We must use an acquire load to read the info table pointer since if we find an indirection we must be certain that we see the indirectee. - - - - - e090f105 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - a98caae0 by Ben Gamari at 2022-12-06T07:57:00-05:00 nonmoving: Fix style - - - - - 00be5445 by Ben Gamari at 2022-12-06T07:57:00-05:00 nonmoving: Deduplicate assertion - - - - - f2f4fa99 by Ben Gamari at 2022-12-06T07:57:00-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - 87c435f8 by Ben Gamari at 2022-12-06T07:57:00-05:00 rts/BlockAlloc: Allow disabling of internal assertions These can be quite expensive and it is sometimes useful to compile a DEBUG RTS without them. - - - - - c46b2526 by Ben Gamari at 2022-12-06T07:57:00-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - c15aa019 by Ben Gamari at 2022-12-06T07:57:00-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - fcb8cd27 by Ben Gamari at 2022-12-06T07:57:01-05:00 Evac: Squash data race in eval_selector_chain - - - - - b9ec577d by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - 4993b652 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Clarify comment - - - - - 671418f9 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - 2d1798bc by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Don't push empty arrays to update remembered set Previously the write barrier of resizeSmallArray# incorrectly handled resizing of zero-sized arrays, pushing an invalid pointer to the update remembered set. Likely fixes the cause of #22264. - - - - - 90849796 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. - - - - - aa8f7211 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - 4f251f3c by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Sanity check mutable list Assert that entries in the nonmoving generation's generational remembered set (a.k.a. mutable list) live in nonmoving generation. - - - - - 37c51b8a by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 6fded74b by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Fix tracking of FILLED_SWEEPING segments Previously we only updated the state of the segment at the head of each allocator's filled list. - - - - - 4c526846 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Assert state of swept segments - - - - - fa93fda5 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive - - - - - 72224150 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. - - - - - 25a7ecdc by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. - - - - - 7337c60c by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Post-sweep sanity checking - - - - - 7fee5d4d by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Avoid n_caps race - - - - - 8adc1750 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 2459eb8c by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Paranoia - - - - - 1a1778e6 by Ben Gamari at 2022-12-06T07:57:01-05:00 rts: Drop racy assertion 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object. - - - - - ebca3b8b by Ben Gamari at 2022-12-06T07:57:01-05:00 rts: Drop SM spinlock - - - - - 81a24c88 by Ben Gamari at 2022-12-06T07:57:01-05:00 rts: C++ typing issues Make the RTS compilable with a C++ compiler by inserting necessary casts. - - - - - 52beb656 by Ben Gamari at 2022-12-06T07:57:01-05:00 setNumCapabilities - - - - - f29140a9 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Disable shortcutting - - - - - 4a91acb1 by Ben Gamari at 2022-12-06T07:57:01-05:00 CheckGC - - - - - 30 changed files: - compiler/GHC/StgToCmm/Bind.hs - libraries/base/GHC/Conc/Sync.hs - rts/Capability.c - rts/Capability.h - rts/CheckUnload.c - rts/PrimOps.cmm - rts/RtsStartup.c - rts/Schedule.c - rts/Schedule.h - rts/Sparks.h - rts/Stats.c - rts/StgMiscClosures.cmm - rts/Trace.h - rts/eventlog/EventLog.c - rts/include/Cmm.h - rts/include/rts/Config.h - rts/include/rts/Threads.h - rts/include/rts/storage/ClosureMacros.h - rts/include/rts/storage/MBlock.h - rts/include/stg/SMP.h - rts/posix/Select.c - rts/posix/Signals.c - rts/rts.cabal.in - rts/sm/BlockAlloc.c - + rts/sm/CheckGc.cpp - rts/sm/Evac.c - rts/sm/GC.c - rts/sm/GC.h - rts/sm/GCUtils.c - rts/sm/GCUtils.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22cd7bb71e1565a48c43d38fe044c517d0aa1d30...4a91acb13ad757f710c3cbcd35d29c06176cdef0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22cd7bb71e1565a48c43d38fe044c517d0aa1d30...4a91acb13ad757f710c3cbcd35d29c06176cdef0 You're receiving 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 Dec 6 13:01:45 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 06 Dec 2022 08:01:45 -0500 Subject: [Git][ghc/ghc][wip/no-sm-spinlock] 232 commits: gen-dll: Drop it Message-ID: <638f3d392b0c2_17512e2fdaf3701351160@gitlab.mail> Ben Gamari pushed to branch wip/no-sm-spinlock at Glasgow Haskell Compiler / GHC Commits: 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - 0927dde4 by Ben Gamari at 2022-12-05T18:42:59-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - ade88423 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce blockConcat - - - - - 4dd2d83f by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm: Introduce MemoryOrderings - - - - - e812bb93 by Ben Gamari at 2022-12-05T18:42:59-05:00 llvm: Respect memory specified orderings - - - - - cf0915f6 by Ben Gamari at 2022-12-05T18:42:59-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 4e2ae5d2 by Ben Gamari at 2022-12-05T18:42:59-05:00 cmm/Parser: Reduce some repetition - - - - - 251f8c99 by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 699bf77a by Ben Gamari at 2022-12-05T18:43:00-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 65dd69f6 by Ben Gamari at 2022-12-05T18:43:25-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 938d6176 by Ben Gamari at 2022-12-05T18:43:26-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 1ee07a55 by Ben Gamari at 2022-12-05T18:43:26-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 4f85f747 by Ben Gamari at 2022-12-05T18:43:26-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 1dba2919 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/Messages: Refactor This doesn't change behavior but makes the code a bit easier to follow. - - - - - 875907eb by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/ThreadPaused: Ordering fixes - - - - - 3c86d5ff by Ben Gamari at 2022-12-05T18:43:41-05:00 eventlog: Silence spurious data race - - - - - d8798a71 by Ben Gamari at 2022-12-05T18:43:41-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - c547e241 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Use fences instead of explicit barriers - - - - - c6d790ae by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - ea0a9590 by Ben Gamari at 2022-12-05T18:43:41-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - ab49e79c by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Introduce getNumCapabilities And ensure accesses to n_capabilities are atomic (although with relaxed ordering). This is necessary as RTS API callers may concurrently call into the RTS without holding a capability. - - - - - 2c5e2a4c by Ben Gamari at 2022-12-05T18:43:41-05:00 ghc: Fix data race in dump file handling Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer. - - - - - 3c6188b5 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - e07bf7e2 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts/Timer: Always use atomic operations As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded. - - - - - 8fe4d790 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Encapsulate recent_activity access This makes it easier to ensure that it is accessed using the necessary atomic operations. - - - - - 5f2c7b91 by Ben Gamari at 2022-12-05T18:43:41-05:00 rts: Encapsulate access to capabilities array - - - - - 16a95a38 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Encapsulate sched_state - - - - - 6a4fd558 by Ben Gamari at 2022-12-06T07:56:28-05:00 PrimOps: Fix benign MutVar race Relaxed ordering is fine here since the later CAS implies a release. - - - - - 149a91be by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Style fix - - - - - c5b78290 by Ben Gamari at 2022-12-06T07:56:28-05:00 compiler: Use release store in eager blackholing - - - - - ab656ae7 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Fix ordering of makeStableName - - - - - 93265cc3 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - a6ca5913 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 60ffe15f by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Ensure that all accesses to pending_sync are atomic - - - - - 5e565a67 by Ben Gamari at 2022-12-06T07:56:28-05:00 rts: Note race with wakeBlockingQueue - - - - - 1e04cf59 by Ben Gamari at 2022-12-06T07:56:28-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - 2f938591 by Ben Gamari at 2022-12-06T07:56:28-05:00 nonmoving: Fix segment list races - - - - - 2726d722 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Use atomic when looking at bd->gen Since it may have been mutated by a moving GC. - - - - - d3cd49cf by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Eliminate race in bump_static_flag To ensure that we don't race with a mutator entering a new CAF we take the SM mutex before touching static_flag. The other option here would be to instead modify newCAF to use a CAS but the present approach is a bit safer. - - - - - 6f52b643 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 947feeab by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Fix races in collector status tracking Mark a number of accesses to do with tracking of the status of the concurrent collection thread as atomic. No interesting races here, merely necessary to satisfy TSAN. - - - - - 5b09ee54 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Make segment state updates atomic - - - - - 651f6f3f by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex by not dropping the SM_MUTEX in nonmovingCollect. This requires quite a bit of rejiggering but it does seem like a better strategy. - - - - - b2b2008f by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Ensure that we aren't holding locks when closing them TSAN complains about this sort of thing. - - - - - c868eee0 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Make bitmap accesses atomic This is a benign race on any sensible hard since these are byte accesses. Nevertheless, atomic accesses are necessary to satisfy TSAN. - - - - - 87e3d20d by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Fix benign race in update remembered set check Relaxed load is fine here since we will take the lock before looking at the list. - - - - - a5b1d1d2 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Fix race in shortcutting We must use an acquire load to read the info table pointer since if we find an indirection we must be certain that we see the indirectee. - - - - - e090f105 by Ben Gamari at 2022-12-06T07:56:29-05:00 nonmoving: Make free list counter accesses atomic Since these may race with the allocator(s). - - - - - a98caae0 by Ben Gamari at 2022-12-06T07:57:00-05:00 nonmoving: Fix style - - - - - 00be5445 by Ben Gamari at 2022-12-06T07:57:00-05:00 nonmoving: Deduplicate assertion - - - - - f2f4fa99 by Ben Gamari at 2022-12-06T07:57:00-05:00 rts: Fix type issues in Sparks.h Adds explicit casts to satisfy a C++ compiler. - - - - - 87c435f8 by Ben Gamari at 2022-12-06T07:57:00-05:00 rts/BlockAlloc: Allow disabling of internal assertions These can be quite expensive and it is sometimes useful to compile a DEBUG RTS without them. - - - - - c46b2526 by Ben Gamari at 2022-12-06T07:57:00-05:00 rts/Sanity: Mark pinned_object_blocks - - - - - c15aa019 by Ben Gamari at 2022-12-06T07:57:00-05:00 rts/Sanity: Look at nonmoving saved_filled lists - - - - - fcb8cd27 by Ben Gamari at 2022-12-06T07:57:01-05:00 Evac: Squash data race in eval_selector_chain - - - - - b9ec577d by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Clarify implementation This makes the intent of this implementation a bit clearer. - - - - - 4993b652 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Clarify comment - - - - - 671418f9 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Add missing no-op in busy-wait loop - - - - - 2d1798bc by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Don't push empty arrays to update remembered set Previously the write barrier of resizeSmallArray# incorrectly handled resizing of zero-sized arrays, pushing an invalid pointer to the update remembered set. Likely fixes the cause of #22264. - - - - - 90849796 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. - - - - - aa8f7211 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Sanity check nonmoving large objects and compacts - - - - - 4f251f3c by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Sanity check mutable list Assert that entries in the nonmoving generation's generational remembered set (a.k.a. mutable list) live in nonmoving generation. - - - - - 37c51b8a by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Don't show occupancy if we didn't collect live words - - - - - 6fded74b by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Fix tracking of FILLED_SWEEPING segments Previously we only updated the state of the segment at the head of each allocator's filled list. - - - - - 4c526846 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Assert state of swept segments - - - - - fa93fda5 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive - - - - - 72224150 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. - - - - - 25a7ecdc by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. - - - - - 7337c60c by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Post-sweep sanity checking - - - - - 7fee5d4d by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Avoid n_caps race - - - - - 8adc1750 by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Don't push if nonmoving collector isn't enabled - - - - - 2459eb8c by Ben Gamari at 2022-12-06T07:57:01-05:00 nonmoving: Paranoia - - - - - 1a1778e6 by Ben Gamari at 2022-12-06T07:57:01-05:00 rts: Drop racy assertion 0e274c39bf836d5bb846f5fa08649c75f85326ac added an assertion in `dirty_MUT_VAR` checking that the MUT_VAR being dirtied was clean. However, this isn't necessarily the case since another thread may have raced us to dirty the object. - - - - - ebca3b8b by Ben Gamari at 2022-12-06T07:57:01-05:00 rts: Drop SM spinlock - - - - - 16 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d620ca0f8abb21a46aca6e28a680cf1c3674e7a5...ebca3b8bc1b2bb1ab23eafd28c85608f89661d1d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d620ca0f8abb21a46aca6e28a680cf1c3674e7a5...ebca3b8bc1b2bb1ab23eafd28c85608f89661d1d You're receiving 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 Dec 6 13:59:40 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Tue, 06 Dec 2022 08:59:40 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/int-index/tok-at-app-kind Message-ID: <638f4acc888de_1769bb526981264dd@gitlab.mail> Vladislav Zavialov pushed new branch wip/int-index/tok-at-app-kind at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/int-index/tok-at-app-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 Tue Dec 6 14:12:11 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Tue, 06 Dec 2022 09:12:11 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/remove-make-stray Message-ID: <638f4dbb8d4ca_1769bb526341373d9@gitlab.mail> John Ericson pushed new branch wip/remove-make-stray at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/remove-make-stray You're receiving 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 Dec 6 14:26:13 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Tue, 06 Dec 2022 09:26:13 -0500 Subject: [Git][ghc/ghc][wip/remove-make-stray] Delete `rts/package.conf.in` Message-ID: <638f5105d3ded_1769bb110ca60146247@gitlab.mail> John Ericson pushed to branch wip/remove-make-stray at Glasgow Haskell Compiler / GHC Commits: d11ace39 by John Ericson at 2022-12-06T09:25:58-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - 1 changed file: - − rts/package.conf.in Changes: ===================================== rts/package.conf.in deleted ===================================== @@ -1,331 +0,0 @@ -/* The RTS is just another package! */ - -#include "ghcconfig.h" -#include "rts/Config.h" -#include "MachDeps.h" - -name: rts -version: 1.0.2 -id: rts -key: rts -license: BSD-3-Clause -maintainer: glasgow-haskell-users at haskell.org -exposed: True - -exposed-modules: -hidden-modules: - -import-dirs: - -#if defined(INSTALLING) -library-dirs: LIB_DIR FFI_LIB_DIR LIBDW_LIB_DIR -#else /* !INSTALLING */ -library-dirs: TOP"/rts/dist-install/build" FFI_LIB_DIR LIBDW_LIB_DIR -#endif - -hs-libraries: "HSrts" FFI_LIB - -extra-libraries: -#if defined(HAVE_LIBM) - "m" /* for ldexp() */ -#endif -#if defined(HAVE_LIBRT) - , "rt" -#endif -#if defined(HAVE_LIBDL) - , "dl" -#endif -#if defined(HAVE_SYSTEM_LIBFFI) - , "ffi" -#endif -#if HAVE_LIBNUMA - , "numa" -#endif -#if defined(mingw32_HOST_OS) - ,"wsock32" /* for the linker */ - ,"gdi32" /* for the linker */ - ,"winmm" /* for the linker */ - ,"dbghelp" /* for crash dump */ - ,"psapi" /* for process information. */ -#endif -#if NEED_PTHREAD_LIB - , "pthread" /* for pthread_getthreadid_np, pthread_create, etc. */ -#endif -#if defined(DEBUG) && defined(HAVE_LIBBFD) - ,"bfd", "iberty" /* for debugging */ -#endif -#if defined(HAVE_LIBMINGWEX) -# if !defined(INSTALLING) /* Bundled Mingw is behind */ - ,"mingwex" -# endif -#endif -#if USE_LIBDW - , "elf" - , "dw" /* for backtraces */ -#endif -#if NEED_ATOMIC_LIB - , "atomic" -#endif - -#if defined(INSTALLING) -include-dirs: INCLUDE_DIR FFI_INCLUDE_DIR -#else /* !INSTALLING */ -include-dirs: TOP"/rts/include" - TOP"/rts/dist-install/build/include" - FFI_INCLUDE_DIR - LIBDW_INCLUDE_DIR -#endif - -includes: Rts.h -cc-options: - -ld-options: -#if defined(LEADING_UNDERSCORE) - - "-Wl,-u,_base_GHCziTopHandler_runIO_closure" - , "-Wl,-u,_base_GHCziTopHandler_runNonIO_closure" - - , "-Wl,-u,_ghczmprim_GHCziTupleziPrim_Z0T_closure" - , "-Wl,-u,_ghczmprim_GHCziTypes_True_closure" - , "-Wl,-u,_ghczmprim_GHCziTypes_False_closure" - , "-Wl,-u,_base_GHCziPack_unpackCString_closure" - , "-Wl,-u,_base_GHCziWeakziFinalizze_runFinalizzerBatch_closure" - , "-Wl,-u,_base_GHCziIOziException_stackOverflow_closure" - , "-Wl,-u,_base_GHCziIOziException_heapOverflow_closure" - , "-Wl,-u,_base_GHCziIOziException_allocationLimitExceeded_closure" - , "-Wl,-u,_base_GHCziIOziException_blockedIndefinitelyOnMVar_closure" - , "-Wl,-u,_base_GHCziIOziException_blockedIndefinitelyOnSTM_closure" - , "-Wl,-u,_base_GHCziIOziException_cannotCompactFunction_closure" - , "-Wl,-u,_base_GHCziIOziException_cannotCompactPinned_closure" - , "-Wl,-u,_base_GHCziIOziException_cannotCompactMutable_closure" - , "-Wl,-u,_base_GHCziIOPort_doubleReadException_closure" - , "-Wl,-u,_base_ControlziExceptionziBase_nonTermination_closure" - , "-Wl,-u,_base_ControlziExceptionziBase_nestedAtomically_closure" - , "-Wl,-u,_base_GHCziEventziThread_blockedOnBadFD_closure" - , "-Wl,-u,_base_GHCziExceptionziType_divZZeroException_closure" - , "-Wl,-u,_base_GHCziExceptionziType_underflowException_closure" - , "-Wl,-u,_base_GHCziExceptionziType_overflowException_closure" - , "-Wl,-u,_base_GHCziConcziSync_runSparks_closure" - , "-Wl,-u,_base_GHCziConcziIO_ensureIOManagerIsRunning_closure" - , "-Wl,-u,_base_GHCziConcziIO_interruptIOManager_closure" - , "-Wl,-u,_base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure" - , "-Wl,-u,_base_GHCziConcziSignal_runHandlersPtr_closure" -#if defined(mingw32_HOST_OS) - , "-Wl,-u,_base_GHCziEventziWindows_processRemoteCompletion_closure" -#endif - , "-Wl,-u,_base_GHCziTopHandler_flushStdHandles_closure" - , "-Wl,-u,_base_GHCziTopHandler_runMainIO_closure" - , "-Wl,-u,_ghczmprim_GHCziTypes_Czh_con_info" - , "-Wl,-u,_ghczmprim_GHCziTypes_Izh_con_info" - , "-Wl,-u,_ghczmprim_GHCziTypes_Fzh_con_info" - , "-Wl,-u,_ghczmprim_GHCziTypes_Dzh_con_info" - , "-Wl,-u,_ghczmprim_GHCziTypes_Wzh_con_info" - , "-Wl,-u,_base_GHCziPtr_Ptr_con_info" - , "-Wl,-u,_base_GHCziPtr_FunPtr_con_info" - , "-Wl,-u,_base_GHCziInt_I8zh_con_info" - , "-Wl,-u,_base_GHCziInt_I16zh_con_info" - , "-Wl,-u,_base_GHCziInt_I32zh_con_info" - , "-Wl,-u,_base_GHCziInt_I64zh_con_info" - , "-Wl,-u,_base_GHCziWord_W8zh_con_info" - , "-Wl,-u,_base_GHCziWord_W16zh_con_info" - , "-Wl,-u,_base_GHCziWord_W32zh_con_info" - , "-Wl,-u,_base_GHCziWord_W64zh_con_info" - , "-Wl,-u,_base_GHCziStable_StablePtr_con_info" - - , "-Wl,-u,_hs_atomic_add8" - , "-Wl,-u,_hs_atomic_add16" - , "-Wl,-u,_hs_atomic_add32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_add64" -#endif - , "-Wl,-u,_hs_atomic_sub8" - , "-Wl,-u,_hs_atomic_sub16" - , "-Wl,-u,_hs_atomic_sub32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_sub64" -#endif - , "-Wl,-u,_hs_atomic_and8" - , "-Wl,-u,_hs_atomic_and16" - , "-Wl,-u,_hs_atomic_and32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_and64" -#endif - , "-Wl,-u,_hs_atomic_nand8" - , "-Wl,-u,_hs_atomic_nand16" - , "-Wl,-u,_hs_atomic_nand32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_nand64" -#endif - , "-Wl,-u,_hs_atomic_or8" - , "-Wl,-u,_hs_atomic_or16" - , "-Wl,-u,_hs_atomic_or32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_or64" -#endif - , "-Wl,-u,_hs_atomic_xor8" - , "-Wl,-u,_hs_atomic_xor16" - , "-Wl,-u,_hs_atomic_xor32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_xor64" -#endif - , "-Wl,-u,_hs_cmpxchg8" - , "-Wl,-u,_hs_cmpxchg16" - , "-Wl,-u,_hs_cmpxchg32" - , "-Wl,-u,_hs_cmpxchg64" - , "-Wl,-u,_hs_xchg8" - , "-Wl,-u,_hs_xchg16" - , "-Wl,-u,_hs_xchg32" - , "-Wl,-u,_hs_xchg64" - , "-Wl,-u,_hs_atomicread8" - , "-Wl,-u,_hs_atomicread16" - , "-Wl,-u,_hs_atomicread32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomicread64" -#endif - , "-Wl,-u,_hs_atomicwrite8" - , "-Wl,-u,_hs_atomicwrite16" - , "-Wl,-u,_hs_atomicwrite32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomicwrite64" -#endif -#if defined(DEBUG) - /* This symbol is useful in gdb, but not referred to anywhere, - * 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" - - , "-Wl,-u,ghczmprim_GHCziTupleziPrim_Z0T_closure" - , "-Wl,-u,ghczmprim_GHCziTypes_True_closure" - , "-Wl,-u,ghczmprim_GHCziTypes_False_closure" - , "-Wl,-u,base_GHCziPack_unpackCString_closure" - , "-Wl,-u,base_GHCziWeakziFinalizze_runFinalizzerBatch_closure" - , "-Wl,-u,base_GHCziIOziException_stackOverflow_closure" - , "-Wl,-u,base_GHCziIOziException_heapOverflow_closure" - , "-Wl,-u,base_GHCziIOziException_allocationLimitExceeded_closure" - , "-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnMVar_closure" - , "-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnSTM_closure" - , "-Wl,-u,base_GHCziIOziException_cannotCompactFunction_closure" - , "-Wl,-u,base_GHCziIOziException_cannotCompactPinned_closure" - , "-Wl,-u,base_GHCziIOziException_cannotCompactMutable_closure" - , "-Wl,-u,base_GHCziIOPort_doubleReadException_closure" - , "-Wl,-u,base_ControlziExceptionziBase_nonTermination_closure" - , "-Wl,-u,base_ControlziExceptionziBase_nestedAtomically_closure" - , "-Wl,-u,base_GHCziEventziThread_blockedOnBadFD_closure" - , "-Wl,-u,base_GHCziExceptionziType_divZZeroException_closure" - , "-Wl,-u,base_GHCziExceptionziType_underflowException_closure" - , "-Wl,-u,base_GHCziExceptionziType_overflowException_closure" - , "-Wl,-u,base_GHCziConcziSync_runSparks_closure" - , "-Wl,-u,base_GHCziConcziIO_ensureIOManagerIsRunning_closure" - , "-Wl,-u,base_GHCziConcziIO_interruptIOManager_closure" - , "-Wl,-u,base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure" - , "-Wl,-u,base_GHCziConcziSignal_runHandlersPtr_closure" -#if defined(mingw32_HOST_OS) - , "-Wl,-u,base_GHCziEventziWindows_processRemoteCompletion_closure" -#endif - , "-Wl,-u,base_GHCziTopHandler_flushStdHandles_closure" - , "-Wl,-u,base_GHCziTopHandler_runMainIO_closure" - , "-Wl,-u,ghczmprim_GHCziTypes_Czh_con_info" - , "-Wl,-u,ghczmprim_GHCziTypes_Izh_con_info" - , "-Wl,-u,ghczmprim_GHCziTypes_Fzh_con_info" - , "-Wl,-u,ghczmprim_GHCziTypes_Dzh_con_info" - , "-Wl,-u,ghczmprim_GHCziTypes_Wzh_con_info" - , "-Wl,-u,base_GHCziPtr_Ptr_con_info" - , "-Wl,-u,base_GHCziPtr_FunPtr_con_info" - , "-Wl,-u,base_GHCziInt_I8zh_con_info" - , "-Wl,-u,base_GHCziInt_I16zh_con_info" - , "-Wl,-u,base_GHCziInt_I32zh_con_info" - , "-Wl,-u,base_GHCziInt_I64zh_con_info" - , "-Wl,-u,base_GHCziWord_W8zh_con_info" - , "-Wl,-u,base_GHCziWord_W16zh_con_info" - , "-Wl,-u,base_GHCziWord_W32zh_con_info" - , "-Wl,-u,base_GHCziWord_W64zh_con_info" - , "-Wl,-u,base_GHCziStable_StablePtr_con_info" - - , "-Wl,-u,hs_atomic_add8" - , "-Wl,-u,hs_atomic_add16" - , "-Wl,-u,hs_atomic_add32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_add64" -#endif - , "-Wl,-u,hs_atomic_sub8" - , "-Wl,-u,hs_atomic_sub16" - , "-Wl,-u,hs_atomic_sub32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_sub64" -#endif - , "-Wl,-u,hs_atomic_and8" - , "-Wl,-u,hs_atomic_and16" - , "-Wl,-u,hs_atomic_and32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_and64" -#endif - , "-Wl,-u,hs_atomic_nand8" - , "-Wl,-u,hs_atomic_nand16" - , "-Wl,-u,hs_atomic_nand32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_nand64" -#endif - , "-Wl,-u,hs_atomic_or8" - , "-Wl,-u,hs_atomic_or16" - , "-Wl,-u,hs_atomic_or32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_or64" -#endif - , "-Wl,-u,hs_atomic_xor8" - , "-Wl,-u,hs_atomic_xor16" - , "-Wl,-u,hs_atomic_xor32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_xor64" -#endif - , "-Wl,-u,hs_cmpxchg8" - , "-Wl,-u,hs_cmpxchg16" - , "-Wl,-u,hs_cmpxchg32" - , "-Wl,-u,hs_cmpxchg64" - , "-Wl,-u,hs_xchg8" - , "-Wl,-u,hs_xchg16" - , "-Wl,-u,hs_xchg32" - , "-Wl,-u,hs_xchg64" - , "-Wl,-u,hs_atomicread8" - , "-Wl,-u,hs_atomicread16" - , "-Wl,-u,hs_atomicread32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomicread64" -#endif - , "-Wl,-u,hs_atomicwrite8" - , "-Wl,-u,hs_atomicwrite16" - , "-Wl,-u,hs_atomicwrite32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomicwrite64" -#endif -#if defined(DEBUG) - /* This symbol is useful in gdb, but not referred to anywhere, - * 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 - * path. This is important to use the static gmp in preference on Mac OS. - * The used option is specific to the Darwin linker. - */ -/* - * See Note [fd_set_overflow] -*/ -#if defined(darwin_HOST_OS) - , "-Wl,-search_paths_first" - , "-Wl,-U,___darwin_check_fd_set_overflow" -#endif - -#if defined(darwin_HOST_OS) && !defined(x86_64_HOST_ARCH) && !defined(aarch64_HOST_ARCH) - , "-read_only_relocs", "warning" -#endif - -framework-dirs: - -haddock-interfaces: -haddock-html: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d11ace398fa86da39a27c992cbedd70d31068505 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d11ace398fa86da39a27c992cbedd70d31068505 You're receiving 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 Dec 6 14:27:49 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 06 Dec 2022 09:27:49 -0500 Subject: [Git][ghc/ghc][wip/fix-multi-repl] ci: Add job to test hadrian-multi command Message-ID: <638f516593701_1769bb526201505d@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: aa5bb698 by Matthew Pickering at 2022-12-06T14:27:43+00:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - 3 changed files: - .gitlab-ci.yml - configure.ac - hadrian/ghci-multi-cabal.in Changes: ===================================== .gitlab-ci.yml ===================================== @@ -376,6 +376,57 @@ hadrian-ghc-in-ghci: paths: - cabal-cache +############################################################ +# Hadrian Multi-Repl +############################################################ + +hadrian-multi: + stage: testing + needs: + - job: x86_64-linux-fedora33-release + optional: true + - job: nightly-x86_64-linux-fedora33-release + optional: true + - job: release-x86_64-linux-fedora33-release + optional: true + dependencies: null + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + variables: + GHC_FLAGS: -Werror + CONFIGURE_ARGS: --enable-bootstrap-with-devel-snapshot + tags: + - x86_64-linux + script: + - export BOOT_HC=$GHC + - root=$(pwd)/ghc + - ls + - | + mkdir tmp + tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export HC=$root/bin/ghc + # This GHC means, use this GHC to configure with + - export GHC=$root/bin/ghc + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + # Now GHC means, use this GHC for hadrian + - export GHC=$BOOT_HC + # Load hadrian-multi then immediately exit and check the modules loaded + - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok," + after_script: + - .gitlab/ci.sh save_cache + cache: + key: hadrian-ghci-$CACHE_REV + paths: + - cabal-cache + ############################################################ # stack-hadrian-build ############################################################ ===================================== configure.ac ===================================== @@ -1201,6 +1201,7 @@ AC_CONFIG_FILES( [ mk/project.mk hadrian/cfg/system.config hadrian/ghci-cabal + hadrian/ghci-cabal-multi hadrian/ghci-stack docs/users_guide/ghc_config.py distrib/configure.ac ===================================== hadrian/ghci-multi-cabal.in ===================================== @@ -1,7 +1,7 @@ #!/usr/bin/env sh -GHC=@WithGhc@ -if [[ $(printf "9.4.0\n%s\n" $($GHC --numeric-version) | sort -uV | head -n 1) != "9.4.0" ]]; then echo "Multi-repl needs at least GHC-9.4.1"; exit 1; fi +RUN_GHC=@WithGhc@ +if [[ $(printf "9.4.0\n%s\n" $($RUN_GHC --numeric-version) | sort -uV | head -n 1) != "9.4.0" ]]; then echo "Multi-repl needs at least GHC-9.4.1"; exit 1; fi # This file is generated by configure from ghci-multi.in @@ -10,4 +10,4 @@ export TOOL_OUTPUT=.hadrian_ghci_multi/ghci_args # Replace newlines with spaces, as these otherwise break the ghci invocation on windows. CABFLAGS=-v0 "hadrian/build-cabal" multi:ghc --build-root=.hadrian_ghci_multi --flavour=ghc-in-ghci $HADRIAN_ARGS GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')" -$GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m +$RUN_GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa5bb698b0c331444b02536b7451f6ba15ceced9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa5bb698b0c331444b02536b7451f6ba15ceced9 You're receiving 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 Dec 6 15:24:00 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 06 Dec 2022 10:24:00 -0500 Subject: [Git][ghc/ghc][wip/T18964] Make `drop` and `dropWhile` fuse (#18964) Message-ID: <638f5e9037115_224fca605f4277f@gitlab.mail> Sebastian Graf pushed to branch wip/T18964 at Glasgow Haskell Compiler / GHC Commits: 4bb308ef by Sebastian Graf at 2022-12-06T16:23:53+01:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 4 changed files: - libraries/base/GHC/List.hs - + testsuite/tests/perf/should_run/T18964.hs - + testsuite/tests/perf/should_run/T18964.stdout - testsuite/tests/perf/should_run/all.T Changes: ===================================== libraries/base/GHC/List.hs ===================================== @@ -517,9 +517,9 @@ scanl' = scanlGo' -- See Note [scanl rewrite rules] {-# RULES "scanl'" [~1] forall f a bs . scanl' f a bs = - build (\c n -> a `c` foldr (scanlFB' f c) (flipSeqScanl' n) bs a) + build (\c n -> a `c` foldr (scanlFB' f c) (flipSeq n) bs a) "scanlList'" [1] forall f a bs . - foldr (scanlFB' f (:)) (flipSeqScanl' []) bs a = tail (scanl' f a bs) + foldr (scanlFB' f (:)) (flipSeq []) bs a = tail (scanl' f a bs) #-} {-# INLINE [0] scanlFB' #-} -- See Note [Inline FB functions] @@ -527,10 +527,6 @@ scanlFB' :: (b -> a -> b) -> (b -> c -> c) -> a -> (b -> c) -> b -> c scanlFB' f c = \b g -> oneShot (\x -> let !b' = f x b in b' `c` g b') -- See Note [Left folds via right fold] -{-# INLINE [0] flipSeqScanl' #-} -flipSeqScanl' :: a -> b -> a -flipSeqScanl' a !_b = a - {- Note [scanl rewrite rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -890,12 +886,23 @@ takeWhileFB p c n = \x r -> if p x then x `c` r else n -- [] -- >>> dropWhile (< 0) [1,2,3] -- [1,2,3] +{-# NOINLINE [1] dropWhile #-} dropWhile :: (a -> Bool) -> [a] -> [a] dropWhile _ [] = [] dropWhile p xs@(x:xs') | p x = dropWhile p xs' | otherwise = xs +{-# INLINE [0] dropWhileFB #-} -- See Note [Inline FB functions] +dropWhileFB :: (a -> Bool) -> (a -> b -> b) -> b -> a -> (Bool -> b) -> Bool -> b +dropWhileFB p c _n x xs = \drp -> if drp && p x then xs True else x `c` xs False + +{-# RULES +"dropWhile" [~1] forall p xs. dropWhile p xs = + build (\c n -> foldr (dropWhileFB p c n) (flipSeq n) xs True) +"dropWhileList" [1] forall p xs. foldr (dropWhileFB p (:) []) (flipSeq []) xs True = dropWhile p xs + #-} + -- | 'take' @n@, applied to a list @xs@, returns the prefix of @xs@ -- of length @n@, or @xs@ itself if @n >= 'length' xs at . -- @@ -932,7 +939,7 @@ take n xs | 0 < n = unsafeTake n xs -- A version of take that takes the whole list if it's given an argument less -- than 1. -{-# NOINLINE [1] unsafeTake #-} +{-# NOINLINE [0] unsafeTake #-} -- See Note [Inline FB functions] unsafeTake :: Int -> [a] -> [a] unsafeTake !_ [] = [] unsafeTake 1 (x: _) = [x] @@ -941,20 +948,18 @@ unsafeTake m (x:xs) = x : unsafeTake (m - 1) xs {-# RULES "take" [~1] forall n xs . take n xs = build (\c nil -> if 0 < n - then foldr (takeFB c nil) (flipSeqTake nil) xs n + then foldr (takeFB c nil) (flipSeq nil) xs n else nil) -"unsafeTakeList" [1] forall n xs . foldr (takeFB (:) []) (flipSeqTake []) xs n +"unsafeTakeList" [1] forall n xs . foldr (takeFB (:) []) (flipSeq []) xs n = unsafeTake n xs #-} -{-# INLINE [0] flipSeqTake #-} --- Just flip seq, specialized to Int, but not inlined too early. --- It's important to force the numeric argument here, even though --- it's not used. Otherwise, take n [] doesn't force n. This is --- bad for strictness analysis and unboxing, and leads to increased --- allocation in T7257. -flipSeqTake :: a -> Int -> a -flipSeqTake x !_n = x +{-# INLINE [0] flipSeq #-} +-- Just flip seq, but not inlined too early. +-- It's important to force the argument here, even though it's not used. +-- Otherwise, take n [] can't unbox n, leading to increased allocation in T7257. +flipSeq :: a -> b -> a +flipSeq x !_n = x {-# INLINE [0] takeFB #-} -- See Note [Inline FB functions] takeFB :: (a -> b -> b) -> b -> a -> (Int -> b) -> Int -> b @@ -993,17 +998,31 @@ drop n xs | n <= 0 = xs drop _ [] = [] drop n (_:xs) = drop (n-1) xs #else /* hack away */ -{-# INLINE drop #-} +{-# INLINE[1] drop #-} -- Why [1]? See justification on take! => RULES drop n ls | n <= 0 = ls | otherwise = unsafeDrop n ls - where - -- A version of drop that drops the whole list if given an argument - -- less than 1 - unsafeDrop :: Int -> [a] -> [a] - unsafeDrop !_ [] = [] - unsafeDrop 1 (_:xs) = xs - unsafeDrop m (_:xs) = unsafeDrop (m - 1) xs + +-- A version of drop that drops the whole list if given an argument +-- less than 1 +{-# NOINLINE [0] unsafeDrop #-} -- See Note [Inline FB functions] +unsafeDrop :: Int -> [a] -> [a] +unsafeDrop !_ [] = [] +unsafeDrop 1 (_:xs) = xs +unsafeDrop m (_:xs) = unsafeDrop (m - 1) xs + +{-# RULES +"drop" [~1] forall n xs . drop n xs = + build (\c nil -> if n <= 0 + then foldr c nil xs + else foldr (dropFB c nil) (flipSeq nil) xs n) +"unsafeDropList" [1] forall n xs . foldr (dropFB (:) []) (flipSeq []) xs n + = unsafeDrop n xs + #-} + +{-# INLINE [0] dropFB #-} -- See Note [Inline FB functions] +dropFB :: (a -> b -> b) -> b -> a -> (Int -> b) -> Int -> b +dropFB c _n x xs = \ m -> if m <= 0 then x `c` xs m else xs (m-1) #endif -- | 'splitAt' @n xs@ returns a tuple where first element is @xs@ prefix of ===================================== testsuite/tests/perf/should_run/T18964.hs ===================================== @@ -0,0 +1,15 @@ +import GHC.Exts +import Data.Int + +main :: IO () +main = do + -- drop should fuse away and the program should consume O(1) space + -- If fusion fails, this allocates about 640MB. + print $ sum $ drop 10 [0..10000000::Int64] + -- Here, drop can't fuse. This asserts that we don't regress in allocations in that case either + -- If we don't do a good job here, we'll see more than 6.4MB of allocs. + print $ lazy $ sum $ lazy $ drop 10 $ lazy [0..100000::Int64] + + -- and once more with dropWhile + print $ sum $ dropWhile (< 10) [0..10000000::Int64] + print $ lazy $ sum $ lazy $ dropWhile (< 10) $ lazy [0..100000::Int64] ===================================== testsuite/tests/perf/should_run/T18964.stdout ===================================== @@ -0,0 +1,4 @@ +50000004999955 +5000049955 +50000004999955 +5000049955 ===================================== testsuite/tests/perf/should_run/all.T ===================================== @@ -408,3 +408,5 @@ test('T21839r', only_ways(['normal'])], compile_and_run, ['-O']) + +test('T18964', [collect_stats('bytes allocated', 1), only_ways(['normal'])], compile_and_run, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bb308efc01bf290269d776c74deb4ede7b24902 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bb308efc01bf290269d776c74deb4ede7b24902 You're receiving 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 Dec 6 15:54:07 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 06 Dec 2022 10:54:07 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-9.4-mercury-leaks Message-ID: <638f659f4eaf_224fca5271046778@gitlab.mail> Zubin pushed new branch wip/ghc-9.4-mercury-leaks at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-9.4-mercury-leaks You're receiving 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 Dec 6 15:59:30 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 06 Dec 2022 10:59:30 -0500 Subject: [Git][ghc/ghc][wip/T22264-9.2] 5 commits: nonmoving: Fix handling of weak pointers Message-ID: <638f66e2b7968_224fca605f446929@gitlab.mail> Ben Gamari pushed to branch wip/T22264-9.2 at Glasgow Haskell Compiler / GHC Commits: 079ac21f by Ben Gamari at 2022-12-06T10:59:21-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. (cherry picked from commit cab678fc11d0a3f28fbf2210c4c0bb04eb52997d) - - - - - 9fc7df1d by Ben Gamari at 2022-12-06T10:59:21-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive (cherry picked from commit 36ca160d0f199a688cf5fbc91d4bb92d2d4ea14e) - - - - - b9c641ba by Ben Gamari at 2022-12-06T10:59:21-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. (cherry picked from commit 8b64aff0fa978c762dfae8df235dd2b2a340656a) - - - - - 16f79f44 by Ben Gamari at 2022-12-06T10:59:22-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. (cherry picked from commit dde67d6e32ecff0e400f98213d42ae790babac09) - - - - - 7bf7a61c by Ben Gamari at 2022-12-06T10:59:22-05:00 nonmoving: Don't push if nonmoving collector isn't enabled (cherry picked from commit 8adc1750c02e596b4014d2837b4eb3d76bd130f2) - - - - - 8 changed files: - rts/RtsStartup.c - rts/sm/Evac.c - rts/sm/MarkWeak.c - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/NonMovingMark.h - rts/sm/Storage.c Changes: ===================================== rts/RtsStartup.c ===================================== @@ -472,6 +472,7 @@ hs_exit_(bool wait_foreign) for (g = 0; g < RtsFlags.GcFlags.generations; g++) { runAllCFinalizers(generations[g].weak_ptr_list); } + runAllCFinalizers(nonmoving_weak_ptr_list); #if defined(RTS_USER_SIGNALS) if (RtsFlags.MiscFlags.install_signal_handlers) { ===================================== rts/sm/Evac.c ===================================== @@ -1246,13 +1246,18 @@ selector_chain: bd = Bdescr((StgPtr)p); if (HEAP_ALLOCED_GC(p)) { + uint16_t flags = RELAXED_LOAD(&bd->flags); // If the THUNK_SELECTOR is in to-space or in a generation that we // are not collecting, then bale out early. We won't be able to // 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 (RELAXED_LOAD(&bd->flags) & (BF_EVACUATED | BF_NONMOVING)) { + if (flags & (BF_EVACUATED | BF_NONMOVING)) { unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p); + if (flags & BF_NONMOVING) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) p); + } *q = (StgClosure *)p; // shortcut, behave as for: if (evac) evacuate(q); if (evac && bd->gen_no < gct->evac_gen_no) { @@ -1267,7 +1272,7 @@ selector_chain: // (scavenge_mark_stack doesn't deal with IND). BEWARE! This // bit is very tricky to get right. If you make changes // around here, test by compiling stage 3 with +RTS -c -RTS. - if (bd->flags & BF_MARKED) { + if (flags & BF_MARKED) { // must call evacuate() to mark this closure if evac==true *q = (StgClosure *)p; if (evac) evacuate(q); @@ -1307,6 +1312,12 @@ selector_chain: // - undo the chain we've built to point to p. SET_INFO((StgClosure *)p, (const StgInfoTable *)info_ptr); RELEASE_STORE(q, (StgClosure *) p); + if (Bdescr((StgPtr)p)->flags & BF_NONMOVING) { + // See Note [Non-moving GC: Marking evacuated objects]. + // TODO: This really shouldn't be necessary since whoever won + // the race should have pushed + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) p); + } if (evac) evacuate(q); unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p); return; @@ -1397,6 +1408,11 @@ selector_loop: case THUNK_SELECTOR: // Use payload to make a list of thunk selectors, to be // used in unchain_thunk_selectors + // + // FIXME: This seems racy; should we lock this selector to + // ensure that another thread doesn't clobber this node + // of the chain. This would result in some previous + // selectors not being updated when we unchain. RELAXED_STORE(&((StgClosure*)p)->payload[0], (StgClosure *)prev_thunk_selector); prev_thunk_selector = p; p = (StgSelector*)val; @@ -1421,6 +1437,12 @@ selector_loop: // eval_thunk_selector(), because we know val is not // a THUNK_SELECTOR. if (evac) evacuate(q); + + if (isNonmovingClosure(*q)) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) *q); + } + return; } @@ -1465,6 +1487,10 @@ selector_loop: // recurse indefinitely, so we impose a depth bound. // See Note [Selector optimisation depth limit]. if (gct->thunk_selector_depth >= MAX_THUNK_SELECTOR_DEPTH) { + if (isNonmovingClosure((StgClosure *) p)) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) p); + } goto bale_out; } @@ -1511,5 +1537,9 @@ bale_out: if (evac) { copy(q,(const StgInfoTable *)info_ptr,(StgClosure *)p,THUNK_SELECTOR_sizeW(),bd->dest_no); } + if (isNonmovingClosure(*q)) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, *q); + } unchain_thunk_selectors(prev_thunk_selector, *q); } ===================================== rts/sm/MarkWeak.c ===================================== @@ -50,7 +50,7 @@ - weak_stage == WeakPtrs - We process all the weak pointers whos keys are alive (evacuate + We process all the weak pointers whose keys are alive (evacuate their values and finalizers), and repeat until we can find no new live keys. If no live keys are found in this pass, then we evacuate the finalizers of all the dead weak pointers in order to @@ -82,12 +82,46 @@ static bool tidyWeakList (generation *gen); static bool resurrectUnreachableThreads (generation *gen, StgTSO **resurrected_threads); static void tidyThreadList (generation *gen); +/* + * Note [Weak pointer processing and the non-moving GC] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * When using the non-moving GC we defer weak pointer processing + * until the concurrent marking phase as weaks in the non-moving heap may be + * keyed on objects living in the non-moving generation. To accomplish this + * initWeakForGC keeps all weak pointers on oldest_gen->weak_ptr_list, where + * nonmovingCollect will find them. From there they will be moved to + * nonmoving_old_weak_ptr_list. During the mark loop we will move weaks with + * reachable keys to nonmoving_weak_ptr_list. At the end of concurrent marking + * we tidy the weak list (in nonmovingTidyWeakList) and perform another set of + * marking as necessary, just as is done in tidyWeakList. + * + * Note that this treatment takes advantage of the fact that we usually need + * not worry about Weak#s living in the non-moving heap but being keyed on an + * object in the moving heap since the Weak# must be strictly older than the + * key. Such objects would otherwise pose a problem since the non-moving + * collector would be unable to safely determine the liveness of the key. + * In the rare case that we *do* see such a key (e.g. in the case of a + * pinned ByteArray# living in a partially-filled accumulator block) + * the nonmoving collector assumes that it is live. + * + */ + +/* + * Prepare the weak object lists for GC. Specifically, reset weak_stage + * and move all generations' `weak_ptr_list`s to `old_weak_ptr_list`. + * Weaks with live keys will later be moved back to `weak_ptr_list` by + * `tidyWeakList`. + */ void initWeakForGC(void) { - uint32_t g; + uint32_t oldest = N; + if (RtsFlags.GcFlags.useNonmoving && N == oldest_gen->no) { + // See Note [Weak pointer processing and the non-moving GC]. + oldest = oldest_gen->no - 1; + } - for (g = 0; g <= N; g++) { + for (uint32_t g = 0; g <= oldest; g++) { generation *gen = &generations[g]; gen->old_weak_ptr_list = gen->weak_ptr_list; gen->weak_ptr_list = NULL; @@ -96,6 +130,14 @@ initWeakForGC(void) weak_stage = WeakThreads; } +/* + * Walk the weak pointer lists after having finished a round of scavenging, + * tidying the weak (and possibly thread) lists (depending upon the current + * weak_stage). + * + * Returns true if new live weak pointers were found, implying that another + * round of scavenging is necessary. + */ bool traverseWeakPtrList(StgWeak **dead_weak_ptr_list, StgTSO **resurrected_threads) { @@ -182,6 +224,11 @@ traverseWeakPtrList(StgWeak **dead_weak_ptr_list, StgTSO **resurrected_threads) } } +/* + * Deal with weak pointers with unreachable keys after GC has concluded. + * This means marking the finalizer (and possibly value) in preparation for + * later finalization. + */ static void collectDeadWeakPtrs (generation *gen, StgWeak **dead_weak_ptr_list) { StgWeak *w, *next_w; @@ -198,6 +245,10 @@ static void collectDeadWeakPtrs (generation *gen, StgWeak **dead_weak_ptr_list) } } +/* + * Deal with threads left on the old_threads list after GC has concluded, + * moving them onto the resurrected_threads list where appropriate. + */ static bool resurrectUnreachableThreads (generation *gen, StgTSO **resurrected_threads) { StgTSO *t, *tmp, *next; @@ -233,8 +284,21 @@ static bool resurrectUnreachableThreads (generation *gen, StgTSO **resurrected_t return flag; } +/* + * Walk over the `old_weak_ptr_list` of the given generation and: + * + * - remove any DEAD_WEAKs + * - move any weaks with reachable keys to the `weak_ptr_list` of the + * appropriate to-space and mark the weak's value and finalizer. + */ static bool tidyWeakList(generation *gen) { + if (RtsFlags.GcFlags.useNonmoving && gen == oldest_gen) { + // See Note [Weak pointer processing and the non-moving GC]. + ASSERT(gen->old_weak_ptr_list == NULL); + return false; + } + StgWeak *w, **last_w, *next_w; const StgInfoTable *info; StgClosure *new; @@ -322,6 +386,10 @@ static bool tidyWeakList(generation *gen) return flag; } +/* + * Walk over the `old_threads` list of the given generation and move any + * reachable threads onto the `threads` list. + */ static void tidyThreadList (generation *gen) { StgTSO *t, *tmp, *next, **prev; @@ -381,6 +449,10 @@ static void checkWeakPtrSanity(StgWeak *hd, StgWeak *tl) } #endif +/* + * Traverse the capabilities' local new-weak-pointer lists at the beginning of + * GC and move them to the nursery's weak_ptr_list. + */ void collectFreshWeakPtrs() { uint32_t i; ===================================== rts/sm/NonMoving.c ===================================== @@ -26,7 +26,7 @@ #include "NonMovingCensus.h" #include "StablePtr.h" // markStablePtrTable #include "Schedule.h" // markScheduler -#include "Weak.h" // dead_weak_ptr_list +#include "Weak.h" // scheduleFinalizers struct NonmovingHeap nonmovingHeap; @@ -244,6 +244,9 @@ Mutex concurrent_coll_finished_lock; * how we use the DIRTY flags associated with MUT_VARs and TVARs to improve * barrier efficiency. * + * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) describes + * how weak pointers are handled when the non-moving GC is in use. + * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage * collector for functional programs on multicore processors. SIGPLAN Not. 51, @@ -282,8 +285,8 @@ Mutex concurrent_coll_finished_lock; * was (unsurprisingly) also found to result in significant amounts of * unnecessary copying. * - * Consequently, we now allow aging. Aging allows the preparatory GC leading up - * to a major collection to evacuate some objects into the young generation. + * Consequently, we now allow "aging", allows the preparatory GC leading up + * to a major collection to evacuate objects into the young generation. * However, this introduces the following tricky case that might arise after * we have finished the preparatory GC: * @@ -886,37 +889,6 @@ static void nonmovingPrepareMark(void) #endif } -// Mark weak pointers in the non-moving heap. They'll either end up in -// dead_weak_ptr_list or stay in weak_ptr_list. Either way they need to be kept -// during sweep. See `MarkWeak.c:markWeakPtrList` for the moving heap variant -// of this. -static void nonmovingMarkWeakPtrList(MarkQueue *mark_queue, StgWeak *dead_weak_ptr_list) -{ - for (StgWeak *w = oldest_gen->weak_ptr_list; w; w = w->link) { - markQueuePushClosure_(mark_queue, (StgClosure*)w); - // Do not mark finalizers and values here, those fields will be marked - // in `nonmovingMarkDeadWeaks` (for dead weaks) or - // `nonmovingTidyWeaks` (for live weaks) - } - - // We need to mark dead_weak_ptr_list too. This is subtle: - // - // - By the beginning of this GC we evacuated all weaks to the non-moving - // heap (in `markWeakPtrList`) - // - // - During the scavenging of the moving heap we discovered that some of - // those weaks are dead and moved them to `dead_weak_ptr_list`. Note that - // because of the fact above _all weaks_ are in the non-moving heap at - // this point. - // - // - So, to be able to traverse `dead_weak_ptr_list` and run finalizers we - // need to mark it. - for (StgWeak *w = dead_weak_ptr_list; w; w = w->link) { - markQueuePushClosure_(mark_queue, (StgClosure*)w); - nonmovingMarkDeadWeak(mark_queue, w); - } -} - void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) { #if defined(THREADED_RTS) @@ -950,9 +922,17 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) capabilities[n], true/*don't mark sparks*/); } markScheduler((evac_fn)markQueueAddRoot, mark_queue); - nonmovingMarkWeakPtrList(mark_queue, *dead_weaks); + nonmovingMarkWeakPtrList(mark_queue); markStablePtrTable((evac_fn)markQueueAddRoot, mark_queue); + // The dead weak pointer list shouldn't contain any weaks in the + // nonmoving heap +#if defined(DEBUG) + for (StgWeak *w = *dead_weaks; w; w = w->link) { + ASSERT(Bdescr((StgPtr) w)->gen != oldest_gen); + } +#endif + // Mark threads resurrected during moving heap scavenging for (StgTSO *tso = *resurrected_threads; tso != END_TSO_QUEUE; tso = tso->global_link) { markQueuePushClosure_(mark_queue, (StgClosure*)tso); @@ -978,8 +958,23 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) // alive). ASSERT(oldest_gen->old_weak_ptr_list == NULL); ASSERT(nonmoving_old_weak_ptr_list == NULL); - nonmoving_old_weak_ptr_list = oldest_gen->weak_ptr_list; - oldest_gen->weak_ptr_list = NULL; + { + // Move both oldest_gen->weak_ptr_list and nonmoving_weak_ptr_list to + // nonmoving_old_weak_ptr_list + StgWeak **weaks = &oldest_gen->weak_ptr_list; + uint32_t n = 0; + while (*weaks) { + weaks = &(*weaks)->link; + n++; + } + debugTrace(DEBUG_nonmoving_gc, "%d new nonmoving weaks", n); + *weaks = nonmoving_weak_ptr_list; + nonmoving_old_weak_ptr_list = oldest_gen->weak_ptr_list; + nonmoving_weak_ptr_list = NULL; + oldest_gen->weak_ptr_list = NULL; + // At this point all weaks in the nonmoving generation are on + // nonmoving_old_weak_ptr_list + } trace(TRACE_nonmoving_gc, "Finished nonmoving GC preparation"); // We are now safe to start concurrent marking @@ -1041,7 +1036,6 @@ static void* nonmovingConcurrentMark(void *data) return NULL; } -// TODO: Not sure where to put this function. // Append w2 to the end of w1. static void appendWeakList( StgWeak **w1, StgWeak *w2 ) { @@ -1081,6 +1075,9 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * } } + // Mark Weak#s + nonmovingMarkWeakPtrList(mark_queue); + // Do concurrent marking; most of the heap will get marked here. nonmovingMarkThreadsWeaks(mark_queue); @@ -1091,21 +1088,13 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * if (sched_state > SCHED_RUNNING) { // Note that we break our invariants here and leave segments in // nonmovingHeap.sweep_list, don't free nonmoving_large_objects etc. - // However because we won't be running mark-sweep in the final GC this + // However because we won't be running sweep in the final GC this // is OK. - - // This is a RTS shutdown so we need to move our copy (snapshot) of - // weaks (nonmoving_old_weak_ptr_list and nonmoving_weak_ptr_list) to - // oldest_gen->threads to be able to run C finalizers in hs_exit_. Note - // that there may be more weaks added to oldest_gen->threads since we - // started mark, so we need to append our list to the tail of - // oldest_gen->threads. - appendWeakList(&nonmoving_old_weak_ptr_list, nonmoving_weak_ptr_list); - appendWeakList(&oldest_gen->weak_ptr_list, nonmoving_old_weak_ptr_list); - // These lists won't be used again so this is not necessary, but still - nonmoving_old_weak_ptr_list = NULL; - nonmoving_weak_ptr_list = NULL; - + // + // However, we must move any weak pointers remaining on + // nonmoving_old_weak_ptr_list back to nonmoving_weak_ptr_list + // such that their C finalizers can be run by hs_exit_. + appendWeakList(&nonmoving_weak_ptr_list, nonmoving_old_weak_ptr_list); goto finish; } @@ -1177,15 +1166,9 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * nonmoving_old_threads = END_TSO_QUEUE; } - { - StgWeak **weaks = &oldest_gen->weak_ptr_list; - while (*weaks) { - weaks = &(*weaks)->link; - } - *weaks = nonmoving_weak_ptr_list; - nonmoving_weak_ptr_list = NULL; - nonmoving_old_weak_ptr_list = NULL; - } + // At this point point any weak that remains on nonmoving_old_weak_ptr_list + // has a dead key. + nonmoving_old_weak_ptr_list = NULL; // Prune spark lists // See Note [Spark management under the nonmoving collector]. ===================================== rts/sm/NonMoving.h ===================================== @@ -289,20 +289,17 @@ INLINE_HEADER void nonmovingSetClosureMark(StgPtr p) nonmovingSetMark(nonmovingGetSegment(p), nonmovingGetBlockIdx(p)); } -// TODO: Audit the uses of these -/* Was the given closure marked this major GC cycle? */ -INLINE_HEADER bool nonmovingClosureMarkedThisCycle(StgPtr p) +INLINE_HEADER uint8_t nonmovingGetClosureMark(StgPtr p) { struct NonmovingSegment *seg = nonmovingGetSegment(p); nonmoving_block_idx blk_idx = nonmovingGetBlockIdx(p); - return nonmovingGetMark(seg, blk_idx) == nonmovingMarkEpoch; + return nonmovingGetMark(seg, blk_idx); } -INLINE_HEADER bool nonmovingClosureMarked(StgPtr p) +/* Was the given closure marked this major GC cycle? */ +INLINE_HEADER bool nonmovingClosureMarkedThisCycle(StgPtr p) { - struct NonmovingSegment *seg = nonmovingGetSegment(p); - nonmoving_block_idx blk_idx = nonmovingGetBlockIdx(p); - return nonmovingGetMark(seg, blk_idx) != 0; + return nonmovingGetClosureMark(p) == nonmovingMarkEpoch; } // Can be called during a major collection to determine whether a particular @@ -338,7 +335,7 @@ INLINE_HEADER bool nonmovingClosureBeingSwept(StgClosure *p) INLINE_HEADER bool isNonmovingClosure(StgClosure *p) { - return !HEAP_ALLOCED_GC(p) || Bdescr((P_)p)->flags & BF_NONMOVING; + return RtsFlags.GcFlags.useNonmoving && (!HEAP_ALLOCED_GC(p) || Bdescr((P_)p)->flags & BF_NONMOVING); } #if defined(DEBUG) ===================================== rts/sm/NonMovingMark.c ===================================== @@ -35,6 +35,9 @@ static void trace_PAP_payload (MarkQueue *queue, StgClosure *fun, StgClosure **payload, StgWord size); +#if defined(DEBUG) +static bool is_nonmoving_weak(StgWeak *weak); +#endif // How many Array# entries to add to the mark queue at once? #define MARK_ARRAY_CHUNK_LENGTH 128 @@ -623,6 +626,16 @@ void updateRemembSetPushThunkEager(Capability *cap, } break; } + case THUNK_SELECTOR: + { + StgSelector *sel = (StgSelector *) thunk; + if (check_in_nonmoving_heap(sel->selectee)) { + // Don't bother to push origin; it makes the barrier needlessly + // expensive with little benefit. + push_closure(queue, sel->selectee, NULL); + } + break; + } case AP: { StgAP *ap = (StgAP *) thunk; @@ -632,9 +645,11 @@ void updateRemembSetPushThunkEager(Capability *cap, trace_PAP_payload(queue, ap->fun, ap->payload, ap->n_args); break; } - case THUNK_SELECTOR: + // We may end up here if a thunk update races with another update. + // In this case there is nothing to do as the other thread will have + // already pushed the updated thunk's free variables to the update + // remembered set. case BLACKHOLE: - // TODO: This is right, right? break; // The selector optimization performed by the nonmoving mark may have // overwritten a thunk which we are updating with an indirection. @@ -1466,10 +1481,12 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) break; } + case WEAK: + ASSERT(is_nonmoving_weak((StgWeak*) p)); + // fallthrough gen_obj: case CONSTR: case CONSTR_NOCAF: - case WEAK: case PRIM: { for (StgWord i = 0; i < info->layout.payload.ptrs; i++) { @@ -1522,8 +1539,15 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) } case THUNK_SELECTOR: - nonmoving_eval_thunk_selector(queue, (StgSelector*)p, origin); + { + StgSelector *sel = (StgSelector *) p; + // We may be able to evaluate this selector which may render the + // selectee unreachable. However, we must mark the selectee regardless + // to satisfy the snapshot invariant. + PUSH_FIELD(sel, selectee); + nonmoving_eval_thunk_selector(queue, sel, origin); break; + } case AP_STACK: { StgAP_STACK *ap = (StgAP_STACK *)p; @@ -1820,9 +1844,45 @@ static bool nonmovingIsNowAlive (StgClosure *p) || (bd->flags & BF_MARKED) != 0; // The object was marked } else { - return nonmovingClosureMarkedThisCycle((P_)p); + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) p); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (p >= snapshot_loc && nonmovingGetClosureMark((StgPtr) p) == 0) { + /* + * In this case we are looking at a block that wasn't allocated + * at the time that the snapshot was taken. As we do not mark such + * blocks, we must assume that it is reachable. + */ + return true; + } else { + return nonmovingClosureMarkedThisCycle((P_)p); + } + } +} + +// Mark all Weak#s on nonmoving_old_weak_ptr_list. +void nonmovingMarkWeakPtrList (struct MarkQueue_ *queue) +{ + ASSERT(nonmoving_weak_ptr_list == NULL); + for (StgWeak *w = nonmoving_old_weak_ptr_list; w != NULL; w = w->link) { + mark_closure(queue, (StgClosure *) w, NULL); + } +} + +#if defined(DEBUG) +// Determine whether a weak pointer object is on one of the nonmoving +// collector's weak pointer lists. Used for sanity checking. +static bool is_nonmoving_weak(StgWeak *weak) +{ + for (StgWeak *w = nonmoving_old_weak_ptr_list; w != NULL; w = w->link) { + if (w == weak) return true; } + for (StgWeak *w = nonmoving_weak_ptr_list; w != NULL; w = w->link) { + if (w == weak) return true; + } + return false; } +#endif // Non-moving heap variant of `tidyWeakList` bool nonmovingTidyWeaks (struct MarkQueue_ *queue) @@ -1832,6 +1892,9 @@ bool nonmovingTidyWeaks (struct MarkQueue_ *queue) StgWeak **last_w = &nonmoving_old_weak_ptr_list; StgWeak *next_w; for (StgWeak *w = nonmoving_old_weak_ptr_list; w != NULL; w = next_w) { + // This should have been marked by nonmovingMarkWeaks + ASSERT(nonmovingIsNowAlive((StgClosure *) w)); + if (w->header.info == &stg_DEAD_WEAK_info) { // finalizeWeak# was called on the weak next_w = w->link; @@ -1842,7 +1905,10 @@ bool nonmovingTidyWeaks (struct MarkQueue_ *queue) // Otherwise it's a live weak ASSERT(w->header.info == &stg_WEAK_info); - if (nonmovingIsNowAlive(w->key)) { + // See Note [Weak pointer processing and the non-moving GC] in + // MarkWeak.c + bool key_in_nonmoving = Bdescr((StgPtr) w->key)->flags & BF_NONMOVING; + if (!key_in_nonmoving || nonmovingIsNowAlive(w->key)) { nonmovingMarkLiveWeak(queue, w); did_work = true; @@ -1850,7 +1916,7 @@ bool nonmovingTidyWeaks (struct MarkQueue_ *queue) *last_w = w->link; next_w = w->link; - // and put it on the weak ptr list + // and put it on nonmoving_weak_ptr_list w->link = nonmoving_weak_ptr_list; nonmoving_weak_ptr_list = w; } else { @@ -1872,7 +1938,8 @@ void nonmovingMarkDeadWeak (struct MarkQueue_ *queue, StgWeak *w) void nonmovingMarkLiveWeak (struct MarkQueue_ *queue, StgWeak *w) { - ASSERT(nonmovingClosureMarkedThisCycle((P_)w)); + ASSERT(nonmovingIsNowAlive((StgClosure *) w)); + ASSERT(nonmovingIsNowAlive((StgClosure *) w->key)); markQueuePushClosure_(queue, w->value); markQueuePushClosure_(queue, w->finalizer); markQueuePushClosure_(queue, w->cfinalizers); @@ -1886,9 +1953,9 @@ void nonmovingMarkDeadWeaks (struct MarkQueue_ *queue, StgWeak **dead_weaks) { StgWeak *next_w; for (StgWeak *w = nonmoving_old_weak_ptr_list; w; w = next_w) { - ASSERT(!nonmovingClosureMarkedThisCycle((P_)(w->key))); + ASSERT(!nonmovingIsNowAlive(w->key)); nonmovingMarkDeadWeak(queue, w); - next_w = w ->link; + next_w = w->link; w->link = *dead_weaks; *dead_weaks = w; } ===================================== rts/sm/NonMovingMark.h ===================================== @@ -157,6 +157,7 @@ void initMarkQueue(MarkQueue *queue); void freeMarkQueue(MarkQueue *queue); void nonmovingMark(struct MarkQueue_ *restrict queue); +void nonmovingMarkWeakPtrList(struct MarkQueue_ *queue); bool nonmovingTidyWeaks(struct MarkQueue_ *queue); void nonmovingTidyThreads(void); void nonmovingMarkDeadWeaks(struct MarkQueue_ *queue, StgWeak **dead_weak_ptr_list); ===================================== rts/sm/Storage.c ===================================== @@ -323,7 +323,7 @@ void storageAddCapabilities (uint32_t from, uint32_t to) // Initialize NonmovingAllocators and UpdRemSets if (RtsFlags.GcFlags.useNonmoving) { nonmovingAddCapabilities(to); - for (i = 0; i < to; ++i) { + for (i = from; i < to; ++i) { init_upd_rem_set(&capabilities[i]->upd_rem_set); } } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c6f17f1218301dc7aed2a3d29f071353ee16fb89...7bf7a61cce31be34953c0a4c023caca74179bf18 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c6f17f1218301dc7aed2a3d29f071353ee16fb89...7bf7a61cce31be34953c0a4c023caca74179bf18 You're receiving 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 Dec 6 17:29:55 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Tue, 06 Dec 2022 12:29:55 -0500 Subject: [Git][ghc/ghc][wip/unsafe-reflection] 31 commits: Move hs_mulIntMayOflo cbits to ghc-prim Message-ID: <638f7c13f3212_224fca605f450536@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/unsafe-reflection at Glasgow Haskell Compiler / GHC Commits: 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - a90bb4fc by Krzysztof Gogolewski at 2022-12-06T18:29:16+01:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 29 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/Wasm/Types.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + compiler/GHC/Core/TyCo/FVs.hs-boot - 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/cab8a355242f959d80dfec849cc7ca181a80f996...a90bb4fcb3a36c7409f6f584b0ea43be60d2c690 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cab8a355242f959d80dfec849cc7ca181a80f996...a90bb4fcb3a36c7409f6f584b0ea43be60d2c690 You're receiving 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 Dec 6 17:52:15 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Tue, 06 Dec 2022 12:52:15 -0500 Subject: [Git][ghc/ghc][wip/int-index/decl-invis-binders] WIP: Invisible binders in type declarations Message-ID: <638f814fccc5e_224fca526d4525c2@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/decl-invis-binders at Glasgow Haskell Compiler / GHC Commits: 4e16b559 by Vladislav Zavialov at 2022-12-06T20:45:07+03:00 WIP: Invisible binders in type declarations - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Error/Codes.hs - compiler/Language/Haskell/Syntax/Type.hs - libraries/ghci/GHCi/TH/Binary.hs - libraries/template-haskell/Language/Haskell/TH.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/indexed-types/should_fail/T9160.hs - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e16b559644efb6a7771d9ef56ac3cf898b20d07 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e16b559644efb6a7771d9ef56ac3cf898b20d07 You're receiving 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 Dec 6 18:04:55 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Tue, 06 Dec 2022 13:04:55 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-2] 181 commits: Drop a kludge for binutils<2.17, which is now over 10 years old. Message-ID: <638f84473820e_224fca6063054250@gitlab.mail> John Ericson pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - d11ace39 by John Ericson at 2022-12-06T09:25:58-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - f94000bc by Ben Gamari at 2022-12-06T12:57:19-05:00 rts configure script - - - - - 17 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - CODEOWNERS - boot - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/717bf8474efbb1b1cf4b26675adaf5c42a20470a...f94000bc2978df298bdff2f5bbf95447196a55dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/717bf8474efbb1b1cf4b26675adaf5c42a20470a...f94000bc2978df298bdff2f5bbf95447196a55dd You're receiving 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 Dec 6 19:40:37 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Tue, 06 Dec 2022 14:40:37 -0500 Subject: [Git][ghc/ghc][wip/int-index/tok-where] 4 commits: Handle type data declarations in Template Haskell quotations and splices (fixes #22500) Message-ID: <638f9ab5da07b_224fca19137b86023b@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/tok-where at Glasgow Haskell Compiler / GHC Commits: 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - db9ac6ba by Vladislav Zavialov at 2022-12-06T21:11:57+03:00 WIP: Use LHsToken for class, where Updates the haddock submodule. - - - - - 4ee46958 by Vladislav Zavialov at 2022-12-06T22:40:24+03:00 WIP: HsModuleHeaderTokens - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Data/Strict.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/SrcLoc.hs - compiler/Language/Haskell/Syntax.hs - compiler/Language/Haskell/Syntax/Decls.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs - libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs - libraries/template-haskell/Language/Haskell/TH/Syntax.hs - libraries/template-haskell/changelog.md - 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/DumpSemis.stderr - testsuite/tests/parser/should_compile/T20452.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7515ec98a5a04603ac366c8802ac8af813a74304...4ee46958679ce4bc275d7f4e7ff71c822028c326 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7515ec98a5a04603ac366c8802ac8af813a74304...4ee46958679ce4bc275d7f4e7ff71c822028c326 You're receiving 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 Dec 6 20:46:16 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 06 Dec 2022 15:46:16 -0500 Subject: [Git][ghc/ghc][master] Hadrian: fix ghcDebugAssertions off-by-one error Message-ID: <638faa1858ec4_224fca605f4728f1@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 5 changed files: - hadrian/doc/user-settings.md - hadrian/src/Flavour/Type.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Flavours/Development.hs - hadrian/src/Settings/Packages.hs Changes: ===================================== hadrian/doc/user-settings.md ===================================== @@ -25,7 +25,7 @@ data Flavour = Flavour { packages :: Stage -> Action [Package], -- | Bignum backend: 'native', 'gmp', 'ffi', etc. bignumBackend :: String, - -- | Check bignum backend against native + -- | Check selected bignum backend against native backend bignumCheck :: Bool, -- | Build libraries these ways. libraryWays :: Ways, @@ -34,15 +34,20 @@ data Flavour = Flavour { -- | Build dynamic GHC programs. dynamicGhcPrograms :: Action Bool, -- | Enable GHCi debugger. - ghciWithDebugger :: Bool, + ghciWithDebugger :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build profiled GHC. - ghcProfiled :: Bool, + ghcProfiled :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build GHC with the debug RTS. - ghcDebugged :: Bool, + ghcDebugged :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build GHC with debug assertions (-DDEBUG). - ghcDebugAssertions :: Bool, + ghcDebugAssertions :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build the GHC executable against the threaded runtime system. - ghcThreaded :: Bool, + ghcThreaded :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Whether to build docs and which ones -- (haddocks, user manual, haddock manual) ghcDocs :: Action DocTargets } ===================================== hadrian/src/Flavour/Type.hs ===================================== @@ -18,9 +18,9 @@ data Flavour = Flavour { args :: Args, -- | Build these packages. packages :: Stage -> Action [Package], - -- | 'native', 'gmp', 'ffi'. + -- | Bignum backend: 'native', 'gmp', 'ffi', etc. bignumBackend :: String, - -- | Check selected backend against native backend + -- | Check selected bignum backend against native backend bignumCheck :: Bool, -- | Build libraries these ways. libraryWays :: Ways, @@ -29,15 +29,20 @@ data Flavour = Flavour { -- | Build dynamic GHC programs. dynamicGhcPrograms :: Action Bool, -- | Enable GHCi debugger. - ghciWithDebugger :: Stage -> Bool, + ghciWithDebugger :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build profiled GHC. - ghcProfiled :: Stage -> Bool, + ghcProfiled :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build GHC with the debug RTS. - ghcDebugged :: Stage -> Bool, - -- | Build GHC with debug assertions. - ghcDebugAssertions :: Stage -> Bool, + ghcDebugged :: Stage -- ^ stage of the /built/ compiler + -> Bool, + -- | Build GHC with debug assertions (-DDEBUG). + ghcDebugAssertions :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build the GHC executable against the threaded runtime system. - ghcThreaded :: Stage -> Bool, + ghcThreaded :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Whether to build docs and which ones -- (haddocks, user manual, haddock manual) ghcDocs :: Action DocTargets } ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -101,7 +101,7 @@ inTreeCompilerArgs stg = do unregisterised <- flag GhcUnregisterised tables_next_to_code <- flag TablesNextToCode withSMP <- targetSupportsSMP - debugAssertions <- ($ stg) . ghcDebugAssertions <$> flavour + debugAssertions <- ($ succStage stg) . ghcDebugAssertions <$> flavour profiled <- ghcProfiled <$> flavour <*> pure stg os <- setting HostOs ===================================== hadrian/src/Settings/Flavours/Development.hs ===================================== @@ -16,12 +16,12 @@ developmentFlavour ghcStage = defaultFlavour , libraryWays = pure $ Set.fromList [vanilla] , rtsWays = Set.fromList <$> mconcat [pure [vanilla, debug], targetSupportsThreadedRts ? pure [threaded, threadedDebug]] , dynamicGhcPrograms = return False - , ghcDebugAssertions = (>= Stage2) } + , ghcDebugAssertions = (== ghcStage) } where stageString Stage2 = "2" stageString Stage1 = "1" stageString Stage3 = "3" - stageString s = error ("developmentFlavour not support for " ++ show s) + stageString s = error ("developmentFlavour not supported for " ++ show s) developmentArgs :: Stage -> Args developmentArgs ghcStage = do ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -13,7 +13,6 @@ packageArgs :: Args packageArgs = do stage <- getStage path <- getBuildPath - root <- getBuildRoot compilerPath <- expr $ buildPath (vanillaContext stage compiler) let -- Do not bind the result to a Boolean: this forces the configure rule @@ -29,7 +28,10 @@ packageArgs = do cursesLibraryDir <- getSetting CursesLibDir ffiIncludeDir <- getSetting FfiIncludeDir ffiLibraryDir <- getSetting FfiLibDir - debugAssertions <- ghcDebugAssertions <$> expr flavour + debugAssertions <- ( `ghcDebugAssertions` (succStage stage) ) <$> expr flavour + -- NB: in this function, "stage" is the stage of the compiler we are + -- using to build, but ghcDebugAssertions wants the stage of the compiler + -- we are building, which we get using succStage. mconcat --------------------------------- base --------------------------------- @@ -52,7 +54,7 @@ packageArgs = do [ builder Alex ? arg "--latin1" , builder (Ghc CompileHs) ? mconcat - [ debugAssertions stage ? arg "-DDEBUG" + [ debugAssertions ? arg "-DDEBUG" , inputs ["**/GHC.hs", "**/GHC/Driver/Make.hs"] ? arg "-fprof-auto" , input "**/Parser.hs" ? @@ -83,7 +85,7 @@ packageArgs = do , package ghc ? mconcat [ builder Ghc ? mconcat [ arg ("-I" ++ compilerPath) - , debugAssertions stage ? arg "-DDEBUG" ] + , debugAssertions ? arg "-DDEBUG" ] , builder (Cabal Flags) ? mconcat [ andM [expr ghcWithInterpreter, notStage0] `cabalFlag` "internal-interpreter" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cd31acad391582dd16b00a823271b364ab063ca9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cd31acad391582dd16b00a823271b364ab063ca9 You're receiving 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 Dec 6 20:46:58 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 06 Dec 2022 15:46:58 -0500 Subject: [Git][ghc/ghc][master] 4 commits: Push DynFlags out of runInstallNameTool Message-ID: <638faa4218fe8_224fca6066c76664@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - 8 changed files: - + compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Session.hs - + compiler/GHC/Linker/Config.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/SysTools/Tasks.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Driver/Config/Linker.hs ===================================== @@ -0,0 +1,13 @@ +module GHC.Driver.Config.Linker + ( initFrameworkOpts + ) where + +import GHC.Linker.Config + +import GHC.Driver.Session + +initFrameworkOpts :: DynFlags -> FrameworkOpts +initFrameworkOpts dflags = FrameworkOpts + { foFrameworkPaths = frameworkPaths dflags + , foCmdlineFrameworks = cmdlineFrameworks dflags + } ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -130,7 +130,7 @@ module GHC.Driver.Session ( versionedAppDir, versionedFilePath, extraGccViaCFlags, globalPackageDatabasePath, pgm_L, pgm_P, pgm_F, pgm_c, pgm_cxx, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, - pgm_windres, pgm_ar, pgm_otool, pgm_install_name_tool, + pgm_windres, pgm_ar, 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, @@ -833,10 +833,6 @@ 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]) ===================================== compiler/GHC/Linker/Config.hs ===================================== @@ -0,0 +1,13 @@ +-- | Linker configuration + +module GHC.Linker.Config + ( FrameworkOpts(..) + ) where + +import GHC.Prelude + +-- used on darwin only +data FrameworkOpts = FrameworkOpts + { foFrameworkPaths :: [String] + , foCmdlineFrameworks :: [String] + } ===================================== compiler/GHC/Linker/Dynamic.hs ===================================== @@ -12,6 +12,7 @@ import GHC.Prelude import GHC.Platform import GHC.Platform.Ways +import GHC.Driver.Config.Linker import GHC.Driver.Session import GHC.Unit.Env @@ -23,6 +24,7 @@ import GHC.SysTools.Tasks import GHC.Utils.Logger import GHC.Utils.TmpFs +import Control.Monad (when) import System.FilePath linkDynLib :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [String] -> [UnitId] -> IO () @@ -94,7 +96,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- frameworks pkg_framework_opts <- getUnitFrameworkOpts unit_env (map unitId pkgs) - let framework_opts = getFrameworkOpts dflags platform + let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform case os of OSMinGW32 -> do @@ -193,7 +195,9 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- See Note [Dynamic linking on macOS] ++ [ Option "-Wl,-dead_strip_dylibs", Option "-Wl,-headerpad,8000" ] ) - runInjectRPaths logger dflags pkg_lib_paths output_fn + -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004 + when (gopt Opt_RPath dflags) $ + runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn _ -> do ------------------------------------------------------------------- -- Making a DSO ===================================== compiler/GHC/Linker/MacOS.hs ===================================== @@ -9,12 +9,15 @@ where import GHC.Prelude import GHC.Platform +import GHC.Linker.Config + import GHC.Driver.Session import GHC.Unit.Types import GHC.Unit.State import GHC.Unit.Env +import GHC.Settings import GHC.SysTools.Tasks import GHC.Runtime.Interpreter @@ -46,15 +49,13 @@ import Text.ParserCombinators.ReadP as Parser -- dynamic library through @-add_rpath at . -- -- See Note [Dynamic linking on macOS] -runInjectRPaths :: Logger -> DynFlags -> [FilePath] -> FilePath -> IO () --- Make sure to honour -fno-use-rpaths if set on darwin as well see #20004 -runInjectRPaths _ dflags _ _ | not (gopt Opt_RPath dflags) = return () -runInjectRPaths logger dflags lib_paths dylib = do - info <- lines <$> askOtool logger dflags Nothing [Option "-L", Option dylib] +runInjectRPaths :: Logger -> ToolSettings -> [FilePath] -> FilePath -> IO () +runInjectRPaths logger toolSettings lib_paths dylib = do + info <- lines <$> askOtool logger toolSettings 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 <- lines <$> askOtool logger dflags Nothing [Option "-l", Option dylib] + info <- lines <$> askOtool logger toolSettings Nothing [Option "-l", Option dylib] let paths = mapMaybe get_rpath info lib_paths' = [ p | p <- lib_paths, not (p `elem` paths) ] -- only find those rpaths, that aren't already in the library. @@ -62,7 +63,7 @@ runInjectRPaths logger dflags lib_paths dylib = do -- inject the rpaths case rpaths of [] -> return () - _ -> runInstallNameTool logger dflags $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] + _ -> runInstallNameTool logger toolSettings $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] get_rpath :: String -> Maybe FilePath get_rpath l = case readP_to_S rpath_parser l of @@ -96,15 +97,15 @@ getUnitFrameworkOpts unit_env dep_packages | otherwise = return [] -getFrameworkOpts :: DynFlags -> Platform -> [String] -getFrameworkOpts dflags platform +getFrameworkOpts :: FrameworkOpts -> Platform -> [String] +getFrameworkOpts fwOpts platform | platformUsesFrameworks platform = framework_path_opts ++ framework_opts | otherwise = [] where - framework_paths = frameworkPaths dflags + framework_paths = foFrameworkPaths fwOpts framework_path_opts = map ("-F" ++) framework_paths - frameworks = cmdlineFrameworks dflags + frameworks = foCmdlineFrameworks fwOpts -- reverse because they're added in reverse order from the cmd line: framework_opts = concat [ ["-framework", fw] | fw <- reverse frameworks ] ===================================== compiler/GHC/Linker/Static.hs ===================================== @@ -29,6 +29,7 @@ import GHC.Linker.ExtraObj import GHC.Linker.Windows import GHC.Linker.Static.Utils +import GHC.Driver.Config.Linker import GHC.Driver.Session import System.FilePath @@ -171,7 +172,7 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do -- frameworks pkg_framework_opts <- getUnitFrameworkOpts unit_env dep_units - let framework_opts = getFrameworkOpts dflags platform + let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform -- probably _stub.o files let extra_ld_inputs = ldInputs dflags @@ -183,7 +184,9 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do let link dflags args | platformOS platform == OSDarwin = do GHC.SysTools.runLink logger tmpfs dflags args - GHC.Linker.MacOS.runInjectRPaths logger dflags pkg_lib_paths output_fn + -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004 + when (gopt Opt_RPath dflags) $ + GHC.Linker.MacOS.runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn | otherwise = GHC.SysTools.runLink logger tmpfs dflags args ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -16,6 +16,8 @@ import GHC.IO (catchException) import GHC.CmmToLlvm.Config (LlvmVersion, llvmVersionStr, supportedLlvmVersionUpperBound, parseLlvmVersion, supportedLlvmVersionLowerBound) +import GHC.Settings + import GHC.SysTools.Process import GHC.SysTools.Info @@ -362,15 +364,15 @@ runAr logger dflags cwd args = traceSystoolCommand logger "ar" $ do let ar = pgm_ar dflags runSomethingFiltered logger id "Ar" ar args cwd Nothing -askOtool :: Logger -> DynFlags -> Maybe FilePath -> [Option] -> IO String -askOtool logger dflags mb_cwd args = do - let otool = pgm_otool dflags +askOtool :: Logger -> ToolSettings -> Maybe FilePath -> [Option] -> IO String +askOtool logger toolSettings mb_cwd args = do + let otool = toolSettings_pgm_otool toolSettings runSomethingWith logger "otool" otool args $ \real_args -> readCreateProcessWithExitCode' (proc otool real_args){ cwd = mb_cwd } -runInstallNameTool :: Logger -> DynFlags -> [Option] -> IO () -runInstallNameTool logger dflags args = do - let tool = pgm_install_name_tool dflags +runInstallNameTool :: Logger -> ToolSettings -> [Option] -> IO () +runInstallNameTool logger toolSettings args = do + let tool = toolSettings_pgm_install_name_tool toolSettings runSomethingFiltered logger id "Install Name Tool" tool args Nothing Nothing runRanlib :: Logger -> DynFlags -> [Option] -> IO () ===================================== compiler/ghc.cabal.in ===================================== @@ -421,6 +421,7 @@ Library GHC.Driver.Config.HsToCore GHC.Driver.Config.HsToCore.Ticks GHC.Driver.Config.HsToCore.Usage + GHC.Driver.Config.Linker GHC.Driver.Config.Logger GHC.Driver.Config.Parser GHC.Driver.Config.Stg.Debug @@ -529,6 +530,7 @@ Library GHC.JS.Syntax GHC.JS.Transform GHC.Linker + GHC.Linker.Config GHC.Linker.Dynamic GHC.Linker.ExtraObj GHC.Linker.Loader View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd31acad391582dd16b00a823271b364ab063ca9...a74225803dc4ec14e3aef96cfe5e17bdc5f0d2a7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd31acad391582dd16b00a823271b364ab063ca9...a74225803dc4ec14e3aef96cfe5e17bdc5f0d2a7 You're receiving 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 Dec 6 21:17:40 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 06 Dec 2022 16:17:40 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Hadrian: fix ghcDebugAssertions off-by-one error Message-ID: <638fb17438881_224fca19137b8906c7@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - a0b98917 by Gergő Érdi at 2022-12-06T16:17:29-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. - - - - - e1cf7bc0 by Gergő Érdi at 2022-12-06T16:17:32-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - 8698931c by Gergő Érdi at 2022-12-06T16:17:32-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 2f562c46 by Cheng Shao at 2022-12-06T16:17:33-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 5025fe44 by Krzysztof Gogolewski at 2022-12-06T16:17:34-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/Graph/Directed.hs - + compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - + compiler/GHC/Linker/Config.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/SysTools/Tasks.hs - compiler/ghc.cabal.in - hadrian/doc/user-settings.md - hadrian/src/Flavour/Type.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Flavours/Development.hs - hadrian/src/Settings/Packages.hs - libraries/base/Data/Typeable/Internal.hs - testsuite/tests/deSugar/should_compile/T13208.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3610891d555379d2f79fdcbb3ada56d95032dbaa...5025fe44cfa7eac0f9f466bb723b3a7cb5e323e8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3610891d555379d2f79fdcbb3ada56d95032dbaa...5025fe44cfa7eac0f9f466bb723b3a7cb5e323e8 You're receiving 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 Dec 6 22:04:11 2022 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 06 Dec 2022 17:04:11 -0500 Subject: [Git][ghc/ghc][wip/az/epa-note] 207 commits: Class layout info (#19623) Message-ID: <638fbc5b44cd2_224fca6061c110237@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-note at Glasgow Haskell Compiler / GHC Commits: 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - 171ab320 by Alan Zimmerman at 2022-12-06T22:03:53+00:00 Starting on note re exact print annotations - - - - - 16 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/27bb49333ff59eaf315b6bf6b7fcb9a308f8c59a...171ab320ee673668c937aa62f49a85ac8a26f2f7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/27bb49333ff59eaf315b6bf6b7fcb9a308f8c59a...171ab320ee673668c937aa62f49a85ac8a26f2f7 You're receiving 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 Dec 7 07:18:43 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 07 Dec 2022 02:18:43 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/fix-literals Message-ID: <63903e53eaabd_224fca60630145361@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/fix-literals at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fix-literals You're receiving 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 Dec 7 11:30:44 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 07 Dec 2022 06:30:44 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/various-hadrian-fixes Message-ID: <63907964e3362_224fcabe792c0175623@gitlab.mail> Matthew Pickering pushed new branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/various-hadrian-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 Wed Dec 7 11:32:49 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 07 Dec 2022 06:32:49 -0500 Subject: [Git][ghc/ghc][wip/various-hadrian-fixes] packaging: Build perf builds with -split-sections Message-ID: <639079e172d71_224fcafbc676817589e@gitlab.mail> Matthew Pickering pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC Commits: 39498bde by Matthew Pickering at 2022-12-07T11:32:37+00:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 5 changed files: - .gitlab-ci.yml - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - hadrian/doc/flavours.md - hadrian/src/Settings/Flavours/Performance.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -423,7 +423,7 @@ doc-tarball: optional: true - job: nightly-x86_64-windows-validate optional: true - - job: release-x86_64-windows-release + - job: release-x86_64-windows-release+no_split_sections optional: true tags: @@ -447,7 +447,7 @@ doc-tarball: || mv "ghc-x86_64-linux-deb10-release.tar.xz" "$LINUX_BINDIST" \ || true mv "ghc-x86_64-windows-validate.tar.xz" "$WINDOWS_BINDIST" \ - || mv "ghc-x86_64-windows-release.tar.xz" "$WINDOWS_BINDIST" \ + || mv "ghc-x86_64-windows-release+no_split_sections.tar.xz" "$WINDOWS_BINDIST" \ || true if [ ! -f "$LINUX_BINDIST" ]; then echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" ===================================== .gitlab/gen_ci.hs ===================================== @@ -130,6 +130,7 @@ data BuildConfig , fullyStatic :: Bool , tablesNextToCode :: Bool , threadSanitiser :: Bool + , noSplitSections :: Bool } -- Extra arguments to pass to ./configure due to the BuildConfig @@ -146,13 +147,14 @@ mkJobFlavour BuildConfig{..} = Flavour buildFlavour opts opts = [Llvm | llvmBootstrap] ++ [Dwarf | withDwarf] ++ [FullyStatic | fullyStatic] ++ - [ThreadSanitiser | threadSanitiser] + [ThreadSanitiser | threadSanitiser] ++ + [NoSplitSections | noSplitSections, buildFlavour == Release ] data Flavour = Flavour BaseFlavour [FlavourTrans] -data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser +data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser | NoSplitSections -data BaseFlavour = Release | Validate | SlowValidate +data BaseFlavour = Release | Validate | SlowValidate deriving Eq ----------------------------------------------------------------------------- -- Build Configs @@ -174,8 +176,12 @@ vanilla = BuildConfig , fullyStatic = False , tablesNextToCode = True , threadSanitiser = False + , noSplitSections = False } +splitSectionsBroken :: BuildConfig -> BuildConfig +splitSectionsBroken bc = bc { noSplitSections = True } + nativeInt :: BuildConfig nativeInt = vanilla { bignumBackend = Native } @@ -290,6 +296,7 @@ flavourString (Flavour base trans) = baseString base ++ concatMap (("+" ++) . fl flavourString Dwarf = "debug_info" flavourString FullyStatic = "fully_static" flavourString ThreadSanitiser = "thread_sanitizer" + flavourString NoSplitSections = "no_split_sections" -- The path to the docker image (just for linux builders) dockerImage :: Arch -> Opsys -> Maybe String @@ -792,7 +799,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , disableValidate (standardBuilds Amd64 (Linux Debian11)) -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 -- not being at EOL until April 2023 and they still need tinfo5. - , disableValidate (standardBuilds Amd64 (Linux Debian9)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) (splitSectionsBroken vanilla)) , disableValidate (standardBuilds Amd64 (Linux Ubuntu2004)) , disableValidate (standardBuilds Amd64 (Linux Centos7)) -- Fedora33 job is always built with perf so there's one job in the normal @@ -801,13 +808,13 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ -- This job is only for generating head.hackage docs , hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig)) , disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf) - , fastCI (standardBuilds Amd64 Windows) - , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt) + , fastCI (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla)) + , disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt)) , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , standardBuilds I386 (Linux Debian9) + , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) static , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) ===================================== .gitlab/jobs.yaml ===================================== @@ -1869,7 +1869,7 @@ "XZ_OPT": "-9" } }, - "release-i386-linux-deb9-release": { + "release-i386-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1879,7 +1879,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-i386-linux-deb9-release.tar.xz", + "ghc-i386-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -1921,11 +1921,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-i386-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "i386-linux-deb9-release", + "TEST_ENV": "i386-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2424,7 +2424,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-linux-deb9-release": { + "release-x86_64-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2434,7 +2434,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-deb9-release.tar.xz", + "ghc-x86_64-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2476,11 +2476,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "x86_64-linux-deb9-release", + "TEST_ENV": "x86_64-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2731,7 +2731,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-windows-int_native-release": { + "release-x86_64-windows-int_native-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2740,7 +2740,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-int_native-release.tar.xz", + "ghc-x86_64-windows-int_native-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2778,8 +2778,8 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2787,11 +2787,11 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-int_native-release", + "TEST_ENV": "x86_64-windows-int_native-release+no_split_sections", "XZ_OPT": "-9" } }, - "release-x86_64-windows-release": { + "release-x86_64-windows-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2800,7 +2800,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-release.tar.xz", + "ghc-x86_64-windows-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2838,8 +2838,8 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-windows-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2847,7 +2847,7 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-release", + "TEST_ENV": "x86_64-windows-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== hadrian/doc/flavours.md ===================================== @@ -15,6 +15,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH + @@ -35,6 +36,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -46,6 +48,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -57,6 +60,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -68,6 +72,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -79,6 +84,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -90,6 +96,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -112,6 +119,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -123,6 +131,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -134,6 +143,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -145,6 +155,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -156,6 +167,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -167,6 +179,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH ===================================== hadrian/src/Settings/Flavours/Performance.hs ===================================== @@ -6,7 +6,7 @@ import {-# SOURCE #-} Settings.Default -- Please update doc/flavours.md when changing this file. performanceFlavour :: Flavour -performanceFlavour = defaultFlavour +performanceFlavour = splitSections $ defaultFlavour { name = "perf" , args = defaultBuilderArgs <> performanceArgs <> defaultPackageArgs } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39498bdeac910f12764eff594ec94a1b4ad24d7d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39498bdeac910f12764eff594ec94a1b4ad24d7d You're receiving 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 Dec 7 11:45:52 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 07 Dec 2022 06:45:52 -0500 Subject: [Git][ghc/ghc][wip/t22333] 194 commits: Testsuite: more precise test options Message-ID: <63907cf0d2f6c_224fca60680181773@gitlab.mail> Matthew Pickering pushed to branch wip/t22333 at Glasgow Haskell Compiler / GHC Commits: 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - 58a138d0 by Matthew Pickering at 2022-12-07T11:45:44+00:00 Package Imports: Get candidate packages also from re-exported modules Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333 - - - - - 16 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/939ac65fcff7af4ae7a87b492d8ec6da8321aa8a...58a138d0f62c057333e4fd15fe20df64492b1dac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/939ac65fcff7af4ae7a87b492d8ec6da8321aa8a...58a138d0f62c057333e4fd15fe20df64492b1dac You're receiving 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 Dec 7 11:48:06 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 07 Dec 2022 06:48:06 -0500 Subject: [Git][ghc/ghc][wip/hackage-bindist] 196 commits: Remove source location information from interface files Message-ID: <63907d765292a_224fca6063018557f@gitlab.mail> Matthew Pickering pushed to branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC Commits: 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - 5d5e08b3 by Matthew Pickering at 2022-12-07T11:46:53+00:00 Add test for #22162 - - - - - c21dc215 by Matthew Pickering at 2022-12-07T11:46:53+00:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 35734568 by Matthew Pickering at 2022-12-07T11:46:53+00:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - e8a9a199 by Matthew Pickering at 2022-12-07T11:47:44+00:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - 2f3277fd by Matthew Pickering at 2022-12-07T11:47:44+00:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - 16 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bd523e6da2ace750c3ad275a3bce254b96962b45...2f3277fda3715491eef8be80498ef7befc53480a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bd523e6da2ace750c3ad275a3bce254b96962b45...2f3277fda3715491eef8be80498ef7befc53480a You're receiving 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 Dec 7 12:17:45 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 07 Dec 2022 07:17:45 -0500 Subject: [Git][ghc/ghc][wip/fix-multi-repl] ci: Add job to test hadrian-multi command Message-ID: <63908469391f9_224fca606301959a6@gitlab.mail> Matthew Pickering pushed to branch wip/fix-multi-repl at Glasgow Haskell Compiler / GHC Commits: dcc72dbb by Matthew Pickering at 2022-12-07T12:17:38+00:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - 3 changed files: - .gitlab-ci.yml - configure.ac - hadrian/ghci-multi-cabal.in Changes: ===================================== .gitlab-ci.yml ===================================== @@ -376,6 +376,57 @@ hadrian-ghc-in-ghci: paths: - cabal-cache +############################################################ +# Hadrian Multi-Repl +############################################################ + +hadrian-multi: + stage: testing + needs: + - job: x86_64-linux-fedora33-release + optional: true + - job: nightly-x86_64-linux-fedora33-release + optional: true + - job: release-x86_64-linux-fedora33-release + optional: true + dependencies: null + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + variables: + GHC_FLAGS: -Werror + CONFIGURE_ARGS: --enable-bootstrap-with-devel-snapshot + tags: + - x86_64-linux + script: + - export BOOT_HC=$GHC + - root=$(pwd)/ghc + - ls + - | + mkdir tmp + tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export HC=$root/bin/ghc + # This GHC means, use this GHC to configure with + - export GHC=$root/bin/ghc + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + # Now GHC means, use this GHC for hadrian + - export GHC=$BOOT_HC + # Load hadrian-multi then immediately exit and check the modules loaded + - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok," + after_script: + - .gitlab/ci.sh save_cache + cache: + key: hadrian-ghci-$CACHE_REV + paths: + - cabal-cache + ############################################################ # stack-hadrian-build ############################################################ ===================================== configure.ac ===================================== @@ -1201,6 +1201,7 @@ AC_CONFIG_FILES( [ mk/project.mk hadrian/cfg/system.config hadrian/ghci-cabal + hadrian/ghci-multi-cabal hadrian/ghci-stack docs/users_guide/ghc_config.py distrib/configure.ac ===================================== hadrian/ghci-multi-cabal.in ===================================== @@ -1,7 +1,7 @@ #!/usr/bin/env sh -GHC=@WithGhc@ -if [[ $(printf "9.4.0\n%s\n" $($GHC --numeric-version) | sort -uV | head -n 1) != "9.4.0" ]]; then echo "Multi-repl needs at least GHC-9.4.1"; exit 1; fi +RUN_GHC=@WithGhc@ +if [[ $(printf "9.4.0\n%s\n" $($RUN_GHC --numeric-version) | sort -uV | head -n 1) != "9.4.0" ]]; then echo "Multi-repl needs at least GHC-9.4.1"; exit 1; fi # This file is generated by configure from ghci-multi.in @@ -10,4 +10,4 @@ export TOOL_OUTPUT=.hadrian_ghci_multi/ghci_args # Replace newlines with spaces, as these otherwise break the ghci invocation on windows. CABFLAGS=-v0 "hadrian/build-cabal" multi:ghc --build-root=.hadrian_ghci_multi --flavour=ghc-in-ghci $HADRIAN_ARGS GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')" -$GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m +$RUN_GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dcc72dbb2cf883b897786aae9273061166ea3695 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dcc72dbb2cf883b897786aae9273061166ea3695 You're receiving 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 Dec 7 12:52:28 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 07 Dec 2022 07:52:28 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/17733-fragile-conc024 Message-ID: <63908c8c6e859_224fca605f4199055@gitlab.mail> Bryan R pushed new branch wip/17733-fragile-conc024 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/17733-fragile-conc024 You're receiving 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 Dec 7 12:53:36 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 07 Dec 2022 07:53:36 -0500 Subject: [Git][ghc/ghc][wip/17733-fragile-conc024] 13 commits: Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` Message-ID: <63908cd058c0b_224fca6061c201195@gitlab.mail> Bryan R pushed to branch wip/17733-fragile-conc024 at Glasgow Haskell Compiler / GHC Commits: 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - 251c9edd by Bryan Richter at 2022-12-07T14:53:28+02:00 testsuite: Mark conc024 fragile on Windows - - - - - 30 changed files: - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Core/Lint.hs - + compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Dump.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/IfaceToCore.hs - + compiler/GHC/Linker/Config.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/SrcLoc.hs - compiler/ghc.cabal.in - hadrian/doc/user-settings.md - hadrian/src/Flavour/Type.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Flavours/Development.hs - hadrian/src/Settings/Packages.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/-/compare/4c2293f831a165b822155eba624795406c45bdc5...251c9eddc45cf5e2366300a0c42e2f06e5567f79 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c2293f831a165b822155eba624795406c45bdc5...251c9eddc45cf5e2366300a0c42e2f06e5567f79 You're receiving 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 Dec 7 13:54:29 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 07 Dec 2022 08:54:29 -0500 Subject: [Git][ghc/ghc][wip/various-hadrian-fixes] 8 commits: Add -no-split-sections flag to reverse -split-sections Message-ID: <63909b156a30e_224fca1429f9642037d0@gitlab.mail> Matthew Pickering pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC Commits: 5447e1d5 by Matthew Pickering at 2022-12-07T13:54:11+00:00 Add -no-split-sections flag to reverse -split-sections This is useful for our packaging because we enable -split-sections by default but want to disable it in certain configurations. - - - - - f7f4d77b by Matthew Pickering at 2022-12-07T13:54:11+00:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 26ae5c37 by Matthew Pickering at 2022-12-07T13:54:11+00:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - a6a042b4 by Matthew Pickering at 2022-12-07T13:54:11+00:00 hadrian: Add no_split_sections tranformer This transformer reverts the effect of `split_sections`, which we intend to use for platforms which don't support split sections. - - - - - 36d6b7bd by Matthew Pickering at 2022-12-07T13:54:11+00:00 check-exact: Fix build with -Werror - - - - - 5556b968 by Matthew Pickering at 2022-12-07T13:54:11+00:00 ci: Build all test dependencies with in-tree compiler This means that these executables will honour flavour transformers such as "werror". Fixes #22555 - - - - - f802134d by Matthew Pickering at 2022-12-07T13:54:11+00:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - 294e237d by Matthew Pickering at 2022-12-07T13:54:11+00:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 15 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Driver/Session.hs - docs/users_guide/phases.rst - hadrian/README.md - hadrian/doc/flavours.md - hadrian/doc/testsuite.md - hadrian/src/Flavour.hs - hadrian/src/Oracles/TestSettings.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Flavours/Performance.hs - utils/check-exact/ExactPrint.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -423,7 +423,7 @@ doc-tarball: optional: true - job: nightly-x86_64-windows-validate optional: true - - job: release-x86_64-windows-release + - job: release-x86_64-windows-release+no_split_sections optional: true tags: @@ -447,7 +447,7 @@ doc-tarball: || mv "ghc-x86_64-linux-deb10-release.tar.xz" "$LINUX_BINDIST" \ || true mv "ghc-x86_64-windows-validate.tar.xz" "$WINDOWS_BINDIST" \ - || mv "ghc-x86_64-windows-release.tar.xz" "$WINDOWS_BINDIST" \ + || mv "ghc-x86_64-windows-release+no_split_sections.tar.xz" "$WINDOWS_BINDIST" \ || true if [ ! -f "$LINUX_BINDIST" ]; then echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" ===================================== .gitlab/ci.sh ===================================== @@ -518,7 +518,7 @@ function build_hadrian() { if [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian build-cabal -V else - run_hadrian binary-dist -V + run_hadrian test:all_deps binary-dist -V mv _build/bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz" fi ===================================== .gitlab/gen_ci.hs ===================================== @@ -130,6 +130,7 @@ data BuildConfig , fullyStatic :: Bool , tablesNextToCode :: Bool , threadSanitiser :: Bool + , noSplitSections :: Bool } -- Extra arguments to pass to ./configure due to the BuildConfig @@ -146,13 +147,14 @@ mkJobFlavour BuildConfig{..} = Flavour buildFlavour opts opts = [Llvm | llvmBootstrap] ++ [Dwarf | withDwarf] ++ [FullyStatic | fullyStatic] ++ - [ThreadSanitiser | threadSanitiser] + [ThreadSanitiser | threadSanitiser] ++ + [NoSplitSections | noSplitSections, buildFlavour == Release ] data Flavour = Flavour BaseFlavour [FlavourTrans] -data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser +data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser | NoSplitSections -data BaseFlavour = Release | Validate | SlowValidate +data BaseFlavour = Release | Validate | SlowValidate deriving Eq ----------------------------------------------------------------------------- -- Build Configs @@ -174,8 +176,12 @@ vanilla = BuildConfig , fullyStatic = False , tablesNextToCode = True , threadSanitiser = False + , noSplitSections = False } +splitSectionsBroken :: BuildConfig -> BuildConfig +splitSectionsBroken bc = bc { noSplitSections = True } + nativeInt :: BuildConfig nativeInt = vanilla { bignumBackend = Native } @@ -290,6 +296,7 @@ flavourString (Flavour base trans) = baseString base ++ concatMap (("+" ++) . fl flavourString Dwarf = "debug_info" flavourString FullyStatic = "fully_static" flavourString ThreadSanitiser = "thread_sanitizer" + flavourString NoSplitSections = "no_split_sections" -- The path to the docker image (just for linux builders) dockerImage :: Arch -> Opsys -> Maybe String @@ -792,7 +799,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , disableValidate (standardBuilds Amd64 (Linux Debian11)) -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 -- not being at EOL until April 2023 and they still need tinfo5. - , disableValidate (standardBuilds Amd64 (Linux Debian9)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) (splitSectionsBroken vanilla)) , disableValidate (standardBuilds Amd64 (Linux Ubuntu2004)) , disableValidate (standardBuilds Amd64 (Linux Centos7)) -- Fedora33 job is always built with perf so there's one job in the normal @@ -801,13 +808,13 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ -- This job is only for generating head.hackage docs , hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig)) , disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf) - , fastCI (standardBuilds Amd64 Windows) - , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt) + , fastCI (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla)) + , disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt)) , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , standardBuilds I386 (Linux Debian9) + , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) static , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) ===================================== .gitlab/jobs.yaml ===================================== @@ -1869,7 +1869,7 @@ "XZ_OPT": "-9" } }, - "release-i386-linux-deb9-release": { + "release-i386-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1879,7 +1879,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-i386-linux-deb9-release.tar.xz", + "ghc-i386-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -1921,11 +1921,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-i386-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "i386-linux-deb9-release", + "TEST_ENV": "i386-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2424,7 +2424,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-linux-deb9-release": { + "release-x86_64-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2434,7 +2434,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-deb9-release.tar.xz", + "ghc-x86_64-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2476,11 +2476,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "x86_64-linux-deb9-release", + "TEST_ENV": "x86_64-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2731,7 +2731,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-windows-int_native-release": { + "release-x86_64-windows-int_native-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2740,7 +2740,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-int_native-release.tar.xz", + "ghc-x86_64-windows-int_native-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2778,8 +2778,8 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2787,11 +2787,11 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-int_native-release", + "TEST_ENV": "x86_64-windows-int_native-release+no_split_sections", "XZ_OPT": "-9" } }, - "release-x86_64-windows-release": { + "release-x86_64-windows-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2800,7 +2800,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-release.tar.xz", + "ghc-x86_64-windows-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2838,8 +2838,8 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-windows-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2847,7 +2847,7 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-release", + "TEST_ENV": "x86_64-windows-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2192,6 +2192,8 @@ dynamic_flags_deps = [ , make_ord_flag defGhcFlag "split-objs" (NoArg $ addWarn "ignoring -split-objs") + -- MP (2022): This flag should have been implemented in fFlags, do not copy this + -- implementation for a new flag. In fFlags you automatically get the no-* version as well. , make_ord_flag defGhcFlag "split-sections" (noArgM (\dflags -> do if platformHasSubsectionsViaSymbols (targetPlatform dflags) @@ -2201,6 +2203,9 @@ dynamic_flags_deps = [ return dflags else return (gopt_set dflags Opt_SplitSections))) + , make_ord_flag defGhcFlag "no-split-sections" + (noArgM (\dflags -> return (gopt_unset dflags Opt_SplitSections ))) + -------- ghc -M ----------------------------------------------------- , make_ord_flag defGhcFlag "dep-suffix" (hasArg addDepSuffix) , make_ord_flag defGhcFlag "dep-makefile" (hasArg setDepMakefile) ===================================== docs/users_guide/phases.rst ===================================== @@ -922,6 +922,14 @@ for example). When linking, the linker can automatically remove all unreferenced sections and thus produce smaller executables. +.. ghc-flag:: -no-split-sections + :shortdesc: Disable the -split-sections flag + :type: dynamic + :category: linking + + Disable the :ghc-flag:`-split-sections` flag. + + .. ghc-flag:: -static :shortdesc: Use static Haskell libraries :type: dynamic ===================================== hadrian/README.md ===================================== @@ -164,6 +164,18 @@ build stage2:lib:text build stage1:exe:haddock ``` +#### Choosing the compiler used to build Hadrian + +The `GHC` environment variable can be used to control which GHC is used to build hadrian. By +default the version of GHC on your path is used to build hadrian. +This can be a different version of GHC to the one you want to use as the boot compiler (which +is selected during ./configure). + +``` +GHC=$(which ghc-9.4.2) ./hadrian/build +-- hadrian is built using ghc-9.4.2 +``` + #### Fast feedback using ghci Running the `./hadrian/ghci` script will load the main compiler into ===================================== hadrian/doc/flavours.md ===================================== @@ -15,6 +15,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
FlavourSplit Sections Extra arguments
default
+
-O
-H32m
-O2
-H32m
quick + -O0
-H64m
-O0
-H64m
quick-validate + -O0
-H64m
-Werror
-O0
-H64m
-Werror
quick-debug + -O0
-H64m
-O0
-H64m
quickest + -O0
-H64m
-O0
-H64m
perf + Yes (on supported platforms) -O
-H64m
-O
-H64m
bench + -O
-H64m
-O
-H64m
devel1 + -O
-H64m
-O
-H64m
devel2 + -O
-H64m
-O
-H64m
validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
slow-validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
static + -O
-H64m
-fPIC -static
-O
-H64m
-fPIC -static
+ @@ -35,6 +36,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -46,6 +48,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -57,6 +60,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -68,6 +72,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -79,6 +84,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -90,6 +96,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -112,6 +119,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -123,6 +131,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -134,6 +143,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -145,6 +155,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -156,6 +167,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -167,6 +179,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -216,6 +229,10 @@ The supported transformers are listed below: + + + + ===================================== hadrian/doc/testsuite.md ===================================== @@ -22,6 +22,19 @@ tested in CI. If you use an untested flavour such as "Quick" then you run the risk that not all tests will pass. In particular you can rely on the `validate` and `perf` flavours being tested but no others. +## Building just the dependencies needed for the testsuite + +By default the testsuite is queried to work out what specific dependencies need to +be built for tests. For example, some linter tests don't require anything to be built. +If you wish to build all the targets for the testsuite before running any tests there is +a special meta-target which builds all the dependencies you might need when running the testsuite. + +``` +build test:all_deps +``` + + + ## Running only a subset of the testsuite ### Specific tests ===================================== hadrian/src/Flavour.hs ===================================== @@ -46,6 +46,7 @@ flavourTransformers = M.fromList , "debug_info" =: enableDebugInfo , "ticky_ghc" =: enableTickyGhc , "split_sections" =: splitSections + , "no_split_sections" =: noSplitSections , "thread_sanitizer" =: enableThreadSanitizer , "llvm" =: viaLlvmBackend , "profiled_ghc" =: enableProfiledGhc @@ -188,18 +189,22 @@ enableHaddock = -- building it. Note that this transformer doesn't do anything -- on darwin because on darwin platforms we always enable subsections -- via symbols. -splitSectionsIf :: (Package -> Bool) -> Flavour -> Flavour -splitSectionsIf pkgPredicate = addArgs $ do +splitSectionsIf :: String -> (Package -> Bool) -> Flavour -> Flavour +splitSectionsIf opt pkgPredicate = addArgs $ do pkg <- getPackage osx <- expr isOsxTarget not osx ? -- osx doesn't support split sections pkgPredicate pkg ? -- Only apply to these packages - builder (Ghc CompileHs) ? arg "-split-sections" + notStage0 ? builder (Ghc CompileHs) ? arg opt -- | Like 'splitSectionsIf', but with a fixed predicate: use -- split sections for all packages but the GHC library. splitSections :: Flavour -> Flavour -splitSections = splitSectionsIf (/=ghc) +splitSections = splitSectionsIf "-split-sections" (/= ghc) + +noSplitSections :: Flavour -> Flavour +noSplitSections = splitSectionsIf "-no-split-sections" (/= ghc) + -- Disable section splitting for the GHC library. It takes too long and -- there is little benefit. ===================================== hadrian/src/Oracles/TestSettings.hs ===================================== @@ -31,6 +31,7 @@ data TestSetting = TestHostOS | TestGhcWithInterpreter | TestGhcWithRtsLinker | TestGhcUnregisterised + | TestGhcTablesNextToCode | TestGhcWithSMP | TestGhcDynamic | TestGhcProfiled @@ -61,6 +62,7 @@ testSetting key = do TestGhcWithInterpreter -> "GhcWithInterpreter" TestGhcWithRtsLinker -> "GhcWithRtsLinker" TestGhcUnregisterised -> "GhcUnregisterised" + TestGhcTablesNextToCode -> "GhcTablesNextToCode" TestGhcWithSMP -> "GhcWithSMP" TestGhcDynamic -> "GhcDynamic" TestGhcProfiled -> "GhcProfiled" ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -82,6 +82,9 @@ inTreeOutTree inTree outTree = do testsuiteDeps :: Rules () testsuiteDeps = do root <- buildRootRules + "test:all_deps" ~> do + need ("test:ghc" : map cp_target checkPrograms) + "test:ghc" ~> inTreeOutTree (\stg -> do needTestsuitePackages stg ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -145,7 +145,7 @@ outOfTreeCompilerArgs = do withNativeCodeGen <- getBooleanSetting TestGhcWithNativeCodeGen withInterpreter <- getBooleanSetting TestGhcWithInterpreter unregisterised <- getBooleanSetting TestGhcUnregisterised - tables_next_to_code <- getBooleanSetting TestGhcUnregisterised + tables_next_to_code <- getBooleanSetting TestGhcTablesNextToCode withSMP <- getBooleanSetting TestGhcWithSMP debugAssertions <- getBooleanSetting TestGhcDebugged ===================================== hadrian/src/Settings/Flavours/Performance.hs ===================================== @@ -6,7 +6,7 @@ import {-# SOURCE #-} Settings.Default -- Please update doc/flavours.md when changing this file. performanceFlavour :: Flavour -performanceFlavour = defaultFlavour +performanceFlavour = splitSections $ defaultFlavour { name = "perf" , args = defaultBuilderArgs <> performanceArgs <> defaultPackageArgs } ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -15,6 +15,7 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE BlockArguments #-} {-# LANGUAGE UndecidableInstances #-} -- For the (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ExactPrint instance +{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} module ExactPrint ( @@ -2931,7 +2932,7 @@ instance ExactPrint (HsExpr GhcPs) where exact (HsUntypedBracket an (DecBrL a e)) = do an0 <- markEpAnnLMS an lidl AnnOpen (Just "[d|") - an1 <- markEpAnnL an lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC e' <- markAnnotated e an2 <- markEpAnnL an1 lidl AnnCloseC an3 <- markEpAnnL an2 lidl AnnCloseQ -- "|]" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39498bdeac910f12764eff594ec94a1b4ad24d7d...294e237d05d77656612e2d2a1d7278f37b464a4a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39498bdeac910f12764eff594ec94a1b4ad24d7d...294e237d05d77656612e2d2a1d7278f37b464a4a You're receiving 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 Dec 7 14:00:10 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 07 Dec 2022 09:00:10 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/force-docs Message-ID: <63909c6a444ca_224fca6061c2075d9@gitlab.mail> Zubin pushed new branch wip/force-docs at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/force-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 Wed Dec 7 14:47:21 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 07 Dec 2022 09:47:21 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/inlineable-threshold Message-ID: <6390a779b188d_224fca6065822352c@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/inlineable-threshold at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/inlineable-threshold You're receiving 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 Dec 7 15:30:06 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 07 Dec 2022 10:30:06 -0500 Subject: [Git][ghc/ghc][wip/T21761] Respect -XStrict in the pattern-match checker (#21761) Message-ID: <6390b17ec51d4_224fca6061c23127@gitlab.mail> Sebastian Graf pushed to branch wip/T21761 at Glasgow Haskell Compiler / GHC Commits: 0daecee7 by Sebastian Graf at 2022-12-07T16:30:01+01:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. Unfortunately the ones in `mk_eqn_info` happen *after* the pattern-match checker on the match has run and there is a conflicting data dependency for long-distance information. Fixes #21761. - - - - - 4 changed files: - compiler/GHC/HsToCore/Pmc/Desugar.hs - + testsuite/tests/pmcheck/should_compile/T21761.hs - + testsuite/tests/pmcheck/should_compile/T21761.stderr - testsuite/tests/pmcheck/should_compile/all.T Changes: ===================================== compiler/GHC/HsToCore/Pmc/Desugar.hs ===================================== @@ -38,7 +38,7 @@ import GHC.Core.Coercion import GHC.Tc.Types.Evidence (HsWrapper(..), isIdHsWrapper) import {-# SOURCE #-} GHC.HsToCore.Expr (dsExpr, dsLExpr, dsSyntaxExpr) import {-# SOURCE #-} GHC.HsToCore.Binds (dsHsWrapper) -import GHC.HsToCore.Utils (isTrueLHsExpr, selectMatchVar) +import GHC.HsToCore.Utils (isTrueLHsExpr, selectMatchVar, decideBangHood) import GHC.HsToCore.Match.Literal (dsLit, dsOverLit) import GHC.HsToCore.Monad import GHC.Core.TyCo.Rep @@ -334,7 +334,14 @@ desugarMatches vars matches = -- Desugar a single match desugarMatch :: [Id] -> LMatch GhcTc (LHsExpr GhcTc) -> DsM (PmMatch Pre) desugarMatch vars (L match_loc (Match { m_pats = pats, m_grhss = grhss })) = do - pats' <- concat <$> zipWithM desugarLPat vars pats + dflags <- getDynFlags + -- We take account of -XStrict here (#21761). Ideally, we'd share the call + -- to `decideBangHood` with `GHC.HsToCore.Match.mk_eqn_info` and do it + -- *before* Pmc runs, but there is a conflicting data dependency with + -- long-distance information prohibiting the rearrangement. + -- It's simplest to call `decideBangHood` here on our own. + let banged_pats = map (decideBangHood dflags) pats + pats' <- concat <$> zipWithM desugarLPat vars banged_pats grhss' <- desugarGRHSs (locA match_loc) (sep (map ppr pats)) grhss -- tracePm "desugarMatch" (vcat [ppr pats, ppr pats', ppr grhss']) return PmMatch { pm_pats = GrdVec pats', pm_grhss = grhss' } ===================================== testsuite/tests/pmcheck/should_compile/T21761.hs ===================================== @@ -0,0 +1,19 @@ +{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE Strict #-} + +module T21761 where + +data Void + +idV :: Void -> Void +idV v = v + +idV' :: Void -> Void +idV' v = case v of w -> w + +bangIdV :: Void -> Void +bangIdV !v = v + +bangIdV' :: Void -> Void +bangIdV' v = case v of !w -> w ===================================== testsuite/tests/pmcheck/should_compile/T21761.stderr ===================================== @@ -0,0 +1,24 @@ + +T21761.hs:10:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘idV’: idV v = ... + +T21761.hs:13:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘idV'’: idV' v = ... + +T21761.hs:13:20: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In a case alternative: w -> ... + +T21761.hs:16:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘bangIdV’: bangIdV !v = ... + +T21761.hs:19:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘bangIdV'’: bangIdV' v = ... + +T21761.hs:19:24: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In a case alternative: !w -> ... ===================================== testsuite/tests/pmcheck/should_compile/all.T ===================================== @@ -157,3 +157,4 @@ test('EmptyCase008', [], compile, [overlapping_incomplete]) test('EmptyCase009', [], compile, [overlapping_incomplete]) test('EmptyCase010', [], compile, [overlapping_incomplete]) test('T19271', [], compile, [overlapping_incomplete]) +test('T21761', [], compile, [overlapping_incomplete]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0daecee722326a8031337bb0e55411996b26546e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0daecee722326a8031337bb0e55411996b26546e You're receiving 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 Dec 7 15:36:25 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 07 Dec 2022 10:36:25 -0500 Subject: [Git][ghc/ghc][wip/T22324] Make (^) INLINE (#22324) Message-ID: <6390b2f941871_224fcabe792c0236129@gitlab.mail> Sebastian Graf pushed to branch wip/T22324 at Glasgow Haskell Compiler / GHC Commits: 95f832ee by Sebastian Graf at 2022-12-07T16:36:15+01:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 2 changed files: - libraries/base/GHC/Real.hs - testsuite/tests/simplCore/should_compile/T12603.stdout Changes: ===================================== libraries/base/GHC/Real.hs ===================================== @@ -671,27 +671,37 @@ odd = not . even ------------------------------------------------------- -- | raise a number to a non-negative integral power -{-# SPECIALISE [1] (^) :: - Integer -> Integer -> Integer, - Integer -> Int -> Integer, - Int -> Int -> Int #-} -{-# INLINABLE [1] (^) #-} -- See Note [Inlining (^)] +{-# INLINE [1] (^) #-} -- See Note [Inlining (^)] (^) :: (Num a, Integral b) => a -> b -> a x0 ^ y0 | y0 < 0 = errorWithoutStackTrace "Negative exponent" | y0 == 0 = 1 - | otherwise = f x0 y0 - where -- f : x0 ^ y0 = x ^ y - f x y | even y = f (x * x) (y `quot` 2) - | y == 1 = x - | otherwise = g (x * x) (y `quot` 2) x -- See Note [Half of y - 1] - -- g : x0 ^ y0 = (x ^ y) * z - g x y z | even y = g (x * x) (y `quot` 2) z - | y == 1 = x * z - | otherwise = g (x * x) (y `quot` 2) (x * z) -- See Note [Half of y - 1] + | otherwise = powImpl x0 y0 + +{-# SPECIALISE powImpl :: + Integer -> Integer -> Integer, + Integer -> Int -> Integer, + Int -> Int -> Int #-} +{-# INLINABLE powImpl #-} -- See Note [Inlining (^)] +powImpl :: (Num a, Integral b) => a -> b -> a +-- powImpl : x0 ^ y0 = (x ^ y) +powImpl x y | even y = powImpl (x * x) (y `quot` 2) + | y == 1 = x + | otherwise = powImplAcc (x * x) (y `quot` 2) x -- See Note [Half of y - 1] + +{-# SPECIALISE powImplAcc :: + Integer -> Integer -> Integer -> Integer, + Integer -> Int -> Integer -> Integer, + Int -> Int -> Int -> Int #-} +{-# INLINABLE powImplAcc #-} -- See Note [Inlining (^)] +powImplAcc :: (Num a, Integral b) => a -> b -> a -> a +-- powImplAcc : x0 ^ y0 = (x ^ y) * z +powImplAcc x y z | even y = powImplAcc (x * x) (y `quot` 2) z + | y == 1 = x * z + | otherwise = powImplAcc (x * x) (y `quot` 2) (x * z) -- See Note [Half of y - 1] -- | raise a number to an integral power (^^) :: (Fractional a, Integral b) => a -> b -> a -{-# INLINABLE [1] (^^) #-} -- See Note [Inlining (^) +{-# INLINE [1] (^^) #-} -- See Note [Inlining (^) x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) {- Note [Half of y - 1] @@ -699,17 +709,40 @@ x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) Since y is guaranteed to be odd and positive here, half of y - 1 can be computed as y `quot` 2, optimising subtraction away. -Note [Inlining (^) -~~~~~~~~~~~~~~~~~~ -The INLINABLE [1] pragma allows (^) to be specialised at its call sites. -If it is called repeatedly at the same type, that can make a huge -difference, because of those constants which can be repeatedly -calculated. +Note [Inlining (^)] +~~~~~~~~~~~~~~~~~~~ +We want to achieve the following: +* Noting that (^) is lazy in its first argument, we'd still like to avoid allocating a box for + the first argument. Example: nofib/imaginary/x2n1, which makes many calls to (^) with + different first arguments each time. + + Solution: split (^) into a small INLINE wrapper that tests the second arg, which then calls the + strict (and recursive) auxiliary function `powImpl`. + +* Don't inline (^) too early because we want rewrite rules to optimise calls to (^) with + small exponents. See Note [Powers with small exponent]. + + Solution: use INLINE[1] to delay inlining to phase 1, giving the rewrite rules time to fire. + +* (^) is overloaded on two different type parameters. We want to specialise. + + Solution: make `powImpl` (and its friend `powImplAcc`) INLINEABLE, so they can be specialised + at call sites. Also give them some common specialisations right here, to avoid duplicating + that specialisation in clients. + +Specialisation can make a huge difference for repeated calls, because of +constants which would otherwise be calculated repeatedly and unboxing of +arguments. -We don't inline until phase 1, to give a chance for the RULES -"^2/Int" etc to fire first. +Why not make (^) strict in `x0` with a bang and make it INLINABLE? Well, because +it is futile: Being strict in the `Complex Double` pair won't be enough to unbox +the `Double`s anyway. Even after deep specisalisation, we will only unbox the +`Double`s when we inline (^), because (^) remains lazy in the `Double` fields. +Given that (^) must always inline to yield good code, we can just as well mark +it as such. -Currently the fromInteger calls are not floated because we get +A small note on perf: Currently the fromInteger calls from the desugaring of +literals are not floated because we get \d1 d2 x y -> blah after the gentle round of simplification. ===================================== testsuite/tests/simplCore/should_compile/T12603.stdout ===================================== @@ -1 +1 @@ -lvl = case GHC.Real.$wf1 2# 8# of v { __DEFAULT -> GHC.Types.I# v } + = case GHC.Real.$w$spowImpl1 2# 8# of v { __DEFAULT -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/95f832ee9ed8969b415af8eecf387f63def7861d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/95f832ee9ed8969b415af8eecf387f63def7861d You're receiving 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 Dec 7 15:46:46 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 07 Dec 2022 10:46:46 -0500 Subject: [Git][ghc/ghc][wip/T22549] Do not strictify a DFun's parameter dictionaries (#22549) Message-ID: <6390b5662a4d0_224fca1429f9642452ab@gitlab.mail> Sebastian Graf pushed to branch wip/T22549 at Glasgow Haskell Compiler / GHC Commits: 934947e9 by Sebastian Graf at 2022-12-07T16:46:39+01:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/CoreToStg/Prep.hs - + testsuite/tests/stranal/should_run/T22549.hs - + testsuite/tests/stranal/should_run/T22549.stdout - testsuite/tests/stranal/should_run/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -290,8 +290,10 @@ dmdAnalBind dmdAnalBind top_lvl env dmd bind anal_body = case bind of NonRec id rhs | useLetUp top_lvl id - -> dmdAnalBindLetUp top_lvl env id rhs anal_body - _ -> dmdAnalBindLetDown top_lvl env dmd bind anal_body + -> dmdAnalBindLetUp top_lvl env_rhs id rhs anal_body + _ -> dmdAnalBindLetDown top_lvl env_rhs dmd bind anal_body + where + env_rhs = enterDFun bind env -- | Annotates uninteresting top level functions ('isInterestingTopLevelFn') -- with 'topDmd', the rest with the given demand. @@ -1759,6 +1761,10 @@ We never unbox class dictionaries in worker/wrapper. occur without INLINABLE, when we use -fexpose-all-unfoldings and -fspecialise-aggressively to do vigorous cross-module specialisation. +3. #18421 found that unboxing a dictionary can also make the worker less likely + to inline; the inlining heuristics seem to prefer to inline a function + applied to a dictionary over a function applied to a bunch of functions. + TL;DR we /never/ unbox class dictionaries. Unboxing the dictionary, and passing a raft of higher-order functions isn't a huge win anyway -- you really want to specialise the function. @@ -2242,14 +2248,6 @@ addLazyFVs dmd_ty lazy_fvs -- L demand doesn't get both'd with the Bot coming up from the inner -- call to f. So we just get an L demand for x for g. -{- -Note [Do not strictify the argument dictionaries of a dfun] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The typechecker can tie recursive knots involving dfuns, so we do the -conservative thing and refrain from strictifying a dfun's argument -dictionaries. --} - setBndrsDemandInfo :: HasCallStack => [Var] -> [Demand] -> [Var] setBndrsDemandInfo (b:bs) ds | isTyVar b = b : setBndrsDemandInfo bs ds @@ -2388,6 +2386,16 @@ emptyAnalEnv opts fam_envs , ae_rec_dc = memoiseUniqueFun (isRecDataCon fam_envs 3) } +-- | Unset the 'dmd_strict_dicts' flag if any of the given bindings is a DFun +-- binding. Part of the mechanism that detects +-- Note [Do not strictify a DFun's parameter dictionaries]. +enterDFun :: CoreBind -> AnalEnv -> AnalEnv +enterDFun bind env + | any isDFunId (bindersOf bind) + = env { ae_opts = (ae_opts env) { dmd_strict_dicts = False } } + | otherwise + = env + emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv @@ -2439,31 +2447,29 @@ findBndrDmd env dmd_ty id id_ty = idType id strictify dmd - -- See Note [Making dictionaries strict] + -- See Note [Making dictionary parameters strict] + -- and Note [Do not strictify a DFun's parameter dictionaries] | dmd_strict_dicts (ae_opts env) - -- We never want to strictify a recursive let. At the moment - -- findBndrDmd is never called for recursive lets; if that - -- changes, we need a RecFlag parameter and another guard here. = strictifyDictDmd id_ty dmd | otherwise = dmd fam_envs = ae_fam_envs env -{- Note [Making dictionaries strict] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Making dictionary parameters strict] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? * Generally CBV is more efficient. -* Dictionaries are always non-bottom; and never take much work to - compute. E.g. a dfun from an instance decl always returns a dictionary +* A datatype dictionary is always non-bottom and never takes much work to + compute. E.g. a DFun from an instance decl always returns a dictionary record immediately. See DFunUnfolding in CoreSyn. See also Note [Recursive superclasses] in TcInstDcls. -* The strictness analyser will then unbox dictionaries and pass the - methods individually, rather than in a bundle. If there are a lot of - methods that might be bad; but worker/wrapper already does throttling. +See #17758 for more background and perf numbers. + +Wrinkles: * A newtype dictionary is *not* always non-bottom. E.g. class C a where op :: a -> a @@ -2471,26 +2477,44 @@ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? Now a value of type (C Int) is just a newtype wrapper (a cast) around the error thunk. Don't strictify these! -See #17758 for more background and perf numbers. +* Strictifying DFuns risks destroying the invariant that DFuns never take much + work to compute, so we don't do it. + See Note [Do not strictify a DFun's parameter dictionaries] for details. + +* Although worker/wrapper *could* unbox strictly used dictionaries, we do not do + so; see Note [Do not unbox class dictionaries]. The implementation is extremely simple: just make the strictness analyser strictify the demand on a dictionary binder in -'findBndrDmd'. - -However there is one case where this can make performance worse. -For the principle consider some function at the core level: - myEq :: Eq a => a -> a -> Bool - myEq eqDict x y = ((==) eqDict) x y -If we make the dictionary strict then WW can fire turning this into: - $wmyEq :: (a -> a -> Bool) -> a -> a -> Bool - $wmyEq eq x y = eq x y -Which *usually* performs better. However if the dictionary is known we -are far more likely to inline a function applied to the dictionary than -to inline one applied to a function. Sometimes this makes just enough -of a difference to stop a function from inlining. This is documented in #18421. - -It's somewhat similar to Note [Do not unbox class dictionaries] although -here our problem is with the inliner, not the specializer. +'findBndrDmd' if the binder does not belong to a DFun. + +Note [Do not strictify a DFun's parameter dictionaries] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The typechecker can tie recursive knots involving (non-recursive) DFuns, so +we must not strictify a DFun's parameter dictionaries (#22549). +T22549 has an example involving undecidable instances that <>s when we +strictify the DFun of, e.g., `$fEqSeqT`: + + Main.$fEqSeqT + = \@m @a ($dEq :: Eq (m (ViewT m a))) ($dMonad :: Monad m) -> + GHC.Classes.C:Eq @(SeqT m a) ($c== @m @a $dEq $dMonad) + ($c/= @m @a $dEq $dMonad) + + Rec { + $dEq_a = Main.$fEqSeqT @Identity @Int $dEq_b Main.$fMonadIdentity + $dEq_b = ... $dEq_a ... + } + +If we make `$fEqSeqT` strict in `$dEq`, we'll collapse the Rec group into a +giant, <>ing thunk. + +To prevent that, we never strictify dictionary params when inside a DFun. +That is implemented by unsetting 'dmd_strict_dicts' when entering a DFun. + +See also Note [Speculative evaluation] in GHC.CoreToStg.Prep which has a rather +similar example in #20836. We may never speculate *arguments* of (recursive) +DFun calls, likewise we should not mark *formal parameters* of recursive DFuns +as strict. Note [Initialising strictness] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1708,6 +1708,10 @@ Fortunately, pce_rec_ids already has all the information we need in that case. The problem is very similar to Note [Eta reduction in recursive RHSs]. Here as well as there it is *unsound* to change the termination properties of the very function whose termination properties we are exploiting. + +It is also similar to Note [Do not strictify a DFun's parameter dictionaries], +where marking recursive DFuns (of undecidable *instances*) strict in dictionary +*parameters* leads to quite the same change in termination as above. -} data FloatingBind ===================================== testsuite/tests/stranal/should_run/T22549.hs ===================================== @@ -0,0 +1,37 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE DeriveFunctor #-} + +import Data.Function (on) + +newtype Identity a = Identity a deriving (Eq, Functor) +instance Applicative Identity where + pure = Identity + Identity f <*> Identity a = Identity $ f a +instance Monad Identity where + Identity a >>= f = f a + +data ViewT m a + = Empty + | a :< SeqT m a +newtype SeqT m a = SeqT [m (ViewT m a)] + +toViewT :: Monad m => SeqT m a -> m (ViewT m a) +toViewT (SeqT []) = pure Empty +toViewT (SeqT (h : t)) = h >>= \case + Empty -> toViewT (SeqT t) + hi :< SeqT ti -> pure (hi :< SeqT (ti ++ t)) + +instance (Eq (m (ViewT m a)), Monad m) => Eq (SeqT m a) where + (==) = (==) `on` toViewT + +deriving instance (Eq a, Eq (SeqT m a)) => Eq (ViewT m a) + +example :: SeqT Identity Int +example = SeqT [] + +main :: IO () +main = print (example == example) ===================================== testsuite/tests/stranal/should_run/T22549.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== testsuite/tests/stranal/should_run/all.T ===================================== @@ -30,3 +30,5 @@ test('T19053', normal, compile_and_run, ['']) test('T21717b', normal, compile_and_run, ['']) test('T22475', normal, compile_and_run, ['']) test('T22475b', normal, compile_and_run, ['']) +# T22549: Do not strictify DFuns, otherwise we will <> +test('T22549', normal, compile_and_run, ['-fdicts-strict -fno-specialise']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/934947e93113a7d6ce7391e4857e1e197864f3a0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/934947e93113a7d6ce7391e4857e1e197864f3a0 You're receiving 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 Dec 7 16:28:46 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 07 Dec 2022 11:28:46 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-9.6 Message-ID: <6390bf3e61e62_224fca605f4260399@gitlab.mail> Ben Gamari pushed new branch wip/ghc-9.6 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-9.6 You're receiving 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 Dec 7 16:28:51 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 07 Dec 2022 11:28:51 -0500 Subject: [Git][ghc/ghc] Deleted branch ghc-9.6 Message-ID: <6390bf43c8092_224fcabe792c026055c@gitlab.mail> Ben Gamari deleted branch ghc-9.6 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 Dec 7 16:37:18 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 07 Dec 2022 11:37:18 -0500 Subject: [Git][ghc/ghc][wip/t25510] Typeable: Fix module locations of some definitions in GHC.Types Message-ID: <6390c13e7a02_224fca6066c2694bb@gitlab.mail> Matthew Pickering pushed to branch wip/t25510 at Glasgow Haskell Compiler / GHC Commits: c989d063 by Matthew Pickering at 2022-12-07T16:37:01+00:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 4 changed files: - compiler/GHC/Tc/Instance/Typeable.hs - + testsuite/tests/typecheck/should_run/T22510.hs - + testsuite/tests/typecheck/should_run/T22510.stdout - testsuite/tests/typecheck/should_run/all.T Changes: ===================================== compiler/GHC/Tc/Instance/Typeable.hs ===================================== @@ -172,7 +172,7 @@ mkTypeableBinds } } } where needs_typeable_binds tc - | tc `elem` [runtimeRepTyCon, levityTyCon, vecCountTyCon, vecElemTyCon] + | tc `elem` ghcTypesTypeableTyCons = False | otherwise = isAlgTyCon tc @@ -335,7 +335,14 @@ mkPrimTypeableTodos ; todo2 <- todoForTyCons gHC_PRIM ghc_prim_module_id ghcPrimTypeableTyCons - ; return ( gbl_env' , [todo1, todo2]) + ; tcg_env <- getGblEnv + ; let mod_id = case tcg_tr_module tcg_env of -- Should be set by now + Just mod_id -> mod_id + Nothing -> pprPanic "tcMkTypeableBinds" empty + + ; todo3 <- todoForTyCons gHC_TYPES mod_id ghcTypesTypeableTyCons + + ; return ( gbl_env' , [todo1, todo2, todo3]) } else do gbl_env <- getGblEnv return (gbl_env, []) @@ -350,12 +357,18 @@ mkPrimTypeableTodos -- Note [Built-in syntax and the OrigNameCache] in "GHC.Iface.Env" for more. ghcPrimTypeableTyCons :: [TyCon] ghcPrimTypeableTyCons = concat - [ [ runtimeRepTyCon, levityTyCon, vecCountTyCon, vecElemTyCon ] - , map (tupleTyCon Unboxed) [0..mAX_TUPLE_SIZE] + [ map (tupleTyCon Unboxed) [0..mAX_TUPLE_SIZE] , map sumTyCon [2..mAX_SUM_SIZE] , primTyCons ] +-- | These are types which are defined in GHC.Types but are needed in order to +-- typecheck the other generated bindings, therefore to avoid ordering issues we +-- generate them up-front along with the bindings from GHC.Prim. +ghcTypesTypeableTyCons :: [TyCon] +ghcTypesTypeableTyCons = [ runtimeRepTyCon, levityTyCon + , vecCountTyCon, vecElemTyCon ] + data TypeableStuff = Stuff { platform :: Platform -- ^ Target platform , trTyConDataCon :: DataCon -- ^ of @TyCon@ ===================================== testsuite/tests/typecheck/should_run/T22510.hs ===================================== @@ -0,0 +1,36 @@ +{-# LANGUAGE MagicHash, UnboxedTuples, UnboxedSums, ScopedTypeVariables, TypeApplications, AllowAmbiguousTypes #-} +module Main where + +import Type.Reflection +import Data.Proxy +import GHC.Types +import GHC.Prim + +moduleOf :: forall a . Typeable a => String +moduleOf = case someTypeRep (Proxy @a) of + SomeTypeRep tr -> (show tr ++ ": " ++ (tyConModule $ typeRepTyCon tr)) + +main = do + -- These are in GHC.Types + putStrLn $ moduleOf @Levity + putStrLn $ moduleOf @'Lifted + putStrLn $ moduleOf @RuntimeRep + putStrLn $ moduleOf @'IntRep + putStrLn $ moduleOf @'BoxedRep + putStrLn $ moduleOf @'Lifted + putStrLn $ moduleOf @VecCount + putStrLn $ moduleOf @'Vec2 + putStrLn $ moduleOf @VecElem + putStrLn $ moduleOf @'Int8ElemRep + + -- This is from GHC.Tuple + putStrLn $ moduleOf @((),()) + + -- These are in GHC.Prim + putStrLn $ moduleOf @(# () , () #) +-- putStrLn $ moduleOf @(# () | () #) +-- + putStrLn $ moduleOf @(Int64#) + putStrLn $ moduleOf @(Word64#) + putStrLn $ moduleOf @TYPE + putStrLn $ moduleOf @CONSTRAINT ===================================== testsuite/tests/typecheck/should_run/T22510.stdout ===================================== @@ -0,0 +1,16 @@ +Levity: GHC.Types +'Lifted: GHC.Types +RuntimeRep: GHC.Types +'IntRep: GHC.Types +'BoxedRep: GHC.Types +'Lifted: GHC.Types +VecCount: GHC.Types +'Vec2: GHC.Types +VecElem: GHC.Types +'Int8ElemRep: GHC.Types +((),()): GHC.Tuple.Prim +(#,#) ('BoxedRep 'Lifted) ('BoxedRep 'Lifted) () (): GHC.Prim +Int64#: GHC.Prim +Word64#: GHC.Prim +TYPE: GHC.Prim +CONSTRAINT: GHC.Prim ===================================== testsuite/tests/typecheck/should_run/all.T ===================================== @@ -163,3 +163,4 @@ test('T19397M3', extra_files(['T19397S.hs']), compile_and_run, ['-main-is foo']) test('T19397M4', extra_files(['T19397S.hs']), compile_and_run, ['-main-is foo']) test('T19667', normal, compile_and_run, ['-fhpc']) test('T20768', normal, compile_and_run, ['']) +test('T22510', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c989d063cb3ceb3e79106db6f33c0518d40f9463 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c989d063cb3ceb3e79106db6f33c0518d40f9463 You're receiving 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 Dec 7 16:56:31 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 07 Dec 2022 11:56:31 -0500 Subject: [Git][ghc/ghc][wip/force-docs] Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <6390c5bf10b51_224fca60680281342@gitlab.mail> Matthew Pickering pushed to branch wip/force-docs at Glasgow Haskell Compiler / GHC Commits: 73139d39 by Zubin Duggal at 2022-12-07T16:56:06+00:00 Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Involves adding many new NFData instances. Without forcing Docs, references to the TcGblEnv for each module are retained by the Docs structure. Usually these are forced when the ModIface is serialised but not when we aren't writing the interface. - - - - - 10 changed files: - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/FieldLabel.hs - compiler/GHC/Types/Name.hs-boot - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Types/Unique/Map.hs - compiler/GHC/Unit/Module/ModIface.hs Changes: ===================================== compiler/GHC/Data/EnumSet.hs ===================================== @@ -15,11 +15,12 @@ module GHC.Data.EnumSet import GHC.Prelude import GHC.Utils.Binary +import Control.DeepSeq import qualified Data.IntSet as IntSet newtype EnumSet a = EnumSet IntSet.IntSet - deriving (Semigroup, Monoid) + deriving (Semigroup, Monoid, NFData) member :: Enum a => a -> EnumSet a -> Bool member x (EnumSet s) = IntSet.member (fromEnum x) s ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -26,6 +26,7 @@ import GHC.Utils.Outputable import GHC.Utils.Binary import GHC.Data.EnumSet as EnumSet +import Control.DeepSeq import Control.Monad (guard) import Data.List.NonEmpty (NonEmpty(..)) import Data.Maybe (fromMaybe,mapMaybe) @@ -40,6 +41,9 @@ instance Binary Language where put_ bh = put_ bh . fromEnum get bh = toEnum <$> get bh +instance NFData Language where + rnf x = x `seq` () + -- | Debugging flags data DumpFlag -- See Note [Updating flag description in the User's Guide] ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -38,6 +38,7 @@ import GHC.Types.Avail import GHC.Types.Name.Set import GHC.Driver.Flags +import Control.DeepSeq import Data.Data import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap @@ -74,6 +75,8 @@ data WithHsDocIdentifiers a pass = WithHsDocIdentifiers deriving instance (Data pass, Data (IdP pass), Data a) => Data (WithHsDocIdentifiers a pass) deriving instance (Eq (IdP pass), Eq a) => Eq (WithHsDocIdentifiers a pass) +instance (NFData (IdP pass), NFData a) => NFData (WithHsDocIdentifiers a pass) where + rnf (WithHsDocIdentifiers d i) = rnf d `seq` rnf i -- | For compatibility with the existing @-ddump-parsed' output, we only show -- the docstring. @@ -118,19 +121,19 @@ type LHsDoc pass = Located (HsDoc pass) -- | A simplified version of 'HsImpExp.IE'. data DocStructureItem - = DsiSectionHeading Int (HsDoc GhcRn) - | DsiDocChunk (HsDoc GhcRn) - | DsiNamedChunkRef String - | DsiExports Avails + = DsiSectionHeading !Int !(HsDoc GhcRn) + | DsiDocChunk !(HsDoc GhcRn) + | DsiNamedChunkRef !(String) + | DsiExports !Avails | DsiModExport - (NonEmpty ModuleName) -- ^ We might re-export avails from multiple + !(NonEmpty ModuleName) -- ^ We might re-export avails from multiple -- modules with a single export declaration. E.g. -- when we have -- -- > module M (module X) where -- > import R0 as X -- > import R1 as X - Avails + !Avails instance Binary DocStructureItem where put_ bh = \case @@ -179,6 +182,15 @@ instance Outputable DocStructureItem where DsiModExport mod_names avails -> text "re-exported module(s):" <+> ppr mod_names $$ nest 2 (ppr avails) +instance NFData DocStructureItem where + rnf = \case + DsiSectionHeading level doc -> rnf level `seq` rnf doc + DsiDocChunk doc -> rnf doc + DsiNamedChunkRef name -> rnf name + DsiExports avails -> rnf avails + DsiModExport mod_names avails -> rnf mod_names `seq` rnf avails + + type DocStructure = [DocStructureItem] data Docs = Docs @@ -203,6 +215,12 @@ data Docs = Docs -- ^ The full set of language extensions used in the module. } +instance NFData Docs where + rnf (Docs mod_hdr decls args structure named_chunks haddock_opts language extentions) + = rnf mod_hdr `seq` rnf decls `seq` rnf args `seq` rnf structure `seq` rnf named_chunks + `seq` rnf haddock_opts `seq` rnf language `seq` rnf extentions + `seq` () + instance Binary Docs where put_ bh docs = do put_ bh (docs_mod_hdr docs) ===================================== compiler/GHC/Hs/DocString.hs ===================================== @@ -1,5 +1,7 @@ -- | An exactprintable structure for docstrings {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} module GHC.Hs.DocString ( LHsDocString @@ -27,6 +29,7 @@ import GHC.Utils.Binary import GHC.Utils.Encoding import GHC.Utils.Outputable as Outputable hiding ((<>)) import GHC.Types.SrcLoc +import Control.DeepSeq import Data.ByteString (ByteString) import qualified Data.ByteString as BS @@ -59,6 +62,11 @@ data HsDocString instance Outputable HsDocString where ppr = text . renderHsDocString +instance NFData HsDocString where + rnf (MultiLineDocString a b) = rnf a `seq` rnf b + rnf (NestedDocString a b) = rnf a `seq` rnf b + rnf (GeneratedDocString a) = rnf a + -- | Annotate a pretty printed thing with its doc -- The docstring comes after if is 'HsDocStringPrevious' -- Otherwise it comes before. @@ -101,6 +109,12 @@ data HsDocStringDecorator instance Outputable HsDocStringDecorator where ppr = text . printDecorator +instance NFData HsDocStringDecorator where + rnf HsDocStringNext = () + rnf HsDocStringPrevious = () + rnf (HsDocStringNamed x) = rnf x + rnf (HsDocStringGroup x) = rnf x + printDecorator :: HsDocStringDecorator -> String printDecorator HsDocStringNext = "|" printDecorator HsDocStringPrevious = "^" @@ -126,7 +140,8 @@ type LHsDocStringChunk = Located HsDocStringChunk -- | A contiguous chunk of documentation newtype HsDocStringChunk = HsDocStringChunk ByteString - deriving (Eq,Ord,Data, Show) + deriving stock (Eq,Ord,Data, Show) + deriving newtype (NFData) instance Binary HsDocStringChunk where put_ bh (HsDocStringChunk bs) = put_ bh bs @@ -135,7 +150,6 @@ instance Binary HsDocStringChunk where instance Outputable HsDocStringChunk where ppr = text . unpackHDSC - mkHsDocStringChunk :: String -> HsDocStringChunk mkHsDocStringChunk s = HsDocStringChunk (utf8EncodeByteString s) ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -50,6 +50,7 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Constants (debugIsOn) +import Control.DeepSeq import Data.Data ( Data ) import Data.Either ( partitionEithers ) import Data.Functor.Classes ( liftCompare ) @@ -272,6 +273,10 @@ instance Outputable GreName where ppr (NormalGreName n) = ppr n ppr (FieldGreName fl) = ppr fl +instance NFData GreName where + rnf (NormalGreName n) = rnf n + rnf (FieldGreName f) = rnf f + instance HasOccName GreName where occName (NormalGreName n) = occName n occName (FieldGreName fl) = occName fl @@ -385,6 +390,10 @@ instance Binary AvailInfo where ac <- get bh return (AvailTC ab ac) +instance NFData AvailInfo where + rnf (Avail n) = rnf n + rnf (AvailTC a b) = rnf a `seq` rnf b + instance Binary GreName where put_ bh (NormalGreName aa) = do putByte bh 0 @@ -399,3 +408,4 @@ instance Binary GreName where return (NormalGreName aa) _ -> do ab <- get bh return (FieldGreName ab) + ===================================== compiler/GHC/Types/FieldLabel.hs ===================================== @@ -95,6 +95,7 @@ import GHC.Utils.Binary import Language.Haskell.Syntax.Basic (FieldLabelString(..)) +import Control.DeepSeq import Data.Bool import Data.Data @@ -129,6 +130,8 @@ instance Outputable FieldLabelString where instance Uniquable FieldLabelString where getUnique (FieldLabelString fs) = getUnique fs +instance NFData FieldLabel where + rnf (FieldLabel a b c d) = rnf a `seq` rnf b `seq` rnf c `seq` rnf d -- | Flag to indicate whether the DuplicateRecordFields extension is enabled. data DuplicateRecordFields @@ -144,6 +147,8 @@ instance Outputable DuplicateRecordFields where ppr DuplicateRecordFields = text "+dup" ppr NoDuplicateRecordFields = text "-dup" +instance NFData DuplicateRecordFields where + rnf x = x `seq` () -- | Flag to indicate whether the FieldSelectors extension is enabled. data FieldSelectors @@ -159,6 +164,8 @@ instance Outputable FieldSelectors where ppr FieldSelectors = text "+sel" ppr NoFieldSelectors = text "-sel" +instance NFData FieldSelectors where + rnf x = x `seq` () -- | We need the @Binary Name@ constraint here even though there is an instance -- defined in "GHC.Types.Name", because the we have a SOURCE import, so the ===================================== compiler/GHC/Types/Name.hs-boot ===================================== @@ -8,6 +8,7 @@ import {-# SOURCE #-} GHC.Types.Name.Occurrence import GHC.Types.Unique import GHC.Utils.Outputable import Data.Data (Data) +import Control.DeepSeq (NFData) data Name @@ -15,6 +16,7 @@ instance Eq Name instance Data Name instance Uniquable Name instance Outputable Name +instance NFData Name class NamedThing a where getOccName :: a -> OccName ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -735,6 +735,8 @@ pprUserRealSpan show_path (RealSrcSpan' src_path sline scol eline ecol) -- | We attach SrcSpans to lots of things, so let's have a datatype for it. data GenLocated l e = L l e deriving (Eq, Ord, Show, Data, Functor, Foldable, Traversable) +instance (NFData l, NFData e) => NFData (GenLocated l e) where + rnf (L l e) = rnf l `seq` rnf e type Located = GenLocated SrcSpan type RealLocated = GenLocated RealSrcSpan ===================================== compiler/GHC/Types/Unique/Map.hs ===================================== @@ -59,6 +59,7 @@ import Data.Semigroup as Semi ( Semigroup(..) ) import Data.Coerce import Data.Maybe import Data.Data +import Control.DeepSeq -- | Maps indexed by 'Uniquable' keys newtype UniqMap k a = UniqMap { getUniqMap :: UniqFM k (k, a) } @@ -78,6 +79,9 @@ instance (Outputable k, Outputable a) => Outputable (UniqMap k a) where [ ppr k <+> text "->" <+> ppr v | (k, v) <- nonDetEltsUFM m ] +instance (NFData k, NFData a) => NFData (UniqMap k a) where + rnf (UniqMap fm) = seqEltsUFM rnf fm + liftC :: (a -> a -> a) -> (k, a) -> (k, a) -> (k, a) liftC f (_, v) (k', v') = (k', f v v') ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -240,7 +240,7 @@ data ModIface_ (phase :: ModIfacePhase) -- See Note [Trust Own Package] in GHC.Rename.Names mi_complete_matches :: ![IfaceCompleteMatch], - mi_docs :: Maybe Docs, + mi_docs :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- @@ -554,7 +554,7 @@ instance (NFData (IfaceBackendExts (phase :: ModIfacePhase)), NFData (IfaceDeclE f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24) = rnf f1 `seq` rnf f2 `seq` f3 `seq` f4 `seq` f5 `seq` f6 `seq` rnf f7 `seq` f8 `seq` f9 `seq` rnf f10 `seq` rnf f11 `seq` rnf f12 `seq` f13 `seq` rnf f14 `seq` rnf f15 `seq` rnf f16 `seq` - rnf f17 `seq` f18 `seq` rnf f19 `seq` rnf f20 `seq` f21 `seq` f22 `seq` f23 `seq` rnf f24 + rnf f17 `seq` f18 `seq` rnf f19 `seq` rnf f20 `seq` rnf f21 `seq` f22 `seq` f23 `seq` rnf f24 `seq` () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/73139d390b1c7d8391747fd6094dd4d119c28234 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/73139d390b1c7d8391747fd6094dd4d119c28234 You're receiving 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 Dec 7 18:20:04 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 07 Dec 2022 13:20:04 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Fix bounds-checking buglet in Data.Array.Byte Message-ID: <6390d954567b2_224fca6066c299091@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 1d5b31af by Matthew Craven at 2022-12-07T13:19:45-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 2e3aea73 by Gergő Érdi at 2022-12-07T13:19:50-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - b73a9799 by Gergő Érdi at 2022-12-07T13:19:50-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - f75ff67b by Krzysztof Gogolewski at 2022-12-07T13:19:51-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 69d54941 by Ian-Woo Kim at 2022-12-07T13:19:53-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 3c48fad8 by Cheng Shao at 2022-12-07T13:19:55-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - a0a06026 by Krzysztof Gogolewski at 2022-12-07T13:19:55-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 9 changed files: - compiler/GHC/Data/Graph/Directed.hs - hadrian/src/Settings/Packages.hs - libraries/base/Data/Array/Byte.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/Type/Reflection/Unsafe.hs - libraries/base/changelog.md - rts/eventlog/EventLog.c - testsuite/tests/typecheck/should_run/TestTypeableBinary.hs - testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout Changes: ===================================== compiler/GHC/Data/Graph/Directed.hs ===================================== @@ -9,11 +9,11 @@ module GHC.Data.Graph.Directed ( Graph, graphFromEdgedVerticesOrd, graphFromEdgedVerticesUniq, graphFromVerticesAndAdjacency, - SCC(..), Node(..), flattenSCC, flattenSCCs, + SCC(..), Node(..), G.flattenSCC, G.flattenSCCs, stronglyConnCompG, topologicalSortG, verticesG, edgesG, hasVertexG, - reachableG, reachablesG, transposeG, allReachable, outgoingG, + reachableG, reachablesG, transposeG, allReachable, allReachableCyclic, outgoingG, emptyG, findCycle, @@ -58,7 +58,7 @@ import qualified Data.Map as Map import qualified Data.Set as Set import qualified Data.Graph as G -import Data.Graph hiding (Graph, Edge, transposeG, reachable) +import Data.Graph ( Vertex, Bounds, SCC(..) ) -- Used in the underlying representation import Data.Tree import GHC.Types.Unique import GHC.Types.Unique.FM @@ -291,19 +291,11 @@ We use the order of nodes to normalize the order of edges. -} stronglyConnCompG :: Graph node -> [SCC node] -stronglyConnCompG graph = decodeSccs graph forest - where forest = {-# SCC "Digraph.scc" #-} scc (gr_int_graph graph) - -decodeSccs :: Graph node -> Forest Vertex -> [SCC node] -decodeSccs Graph { gr_int_graph = graph, gr_vertex_to_node = vertex_fn } forest - = map decode forest - where - decode (Node v []) | mentions_itself v = CyclicSCC [vertex_fn v] - | otherwise = AcyclicSCC (vertex_fn v) - decode other = CyclicSCC (dec other []) - where dec (Node v ts) vs = vertex_fn v : foldr dec vs ts - mentions_itself v = v `elem` (graph ! v) +stronglyConnCompG graph = decodeSccs graph $ scc (gr_int_graph graph) +decodeSccs :: Graph node -> [SCC Vertex] -> [SCC node] +decodeSccs Graph { gr_vertex_to_node = vertex_fn } + = map (fmap vertex_fn) -- The following two versions are provided for backwards compatibility: -- See Note [Deterministic SCC] @@ -334,7 +326,7 @@ stronglyConnCompFromEdgedVerticesOrdR => [Node key payload] -> [SCC (Node key payload)] stronglyConnCompFromEdgedVerticesOrdR = - stronglyConnCompG . graphFromEdgedVertices reduceNodesIntoVerticesOrd + stronglyConnCompG . graphFromEdgedVerticesOrd -- The "R" interface is used when you expect to apply SCC to -- (some of) the result of SCC, so you don't want to lose the dependency info @@ -345,7 +337,7 @@ stronglyConnCompFromEdgedVerticesUniqR => [Node key payload] -> [SCC (Node key payload)] stronglyConnCompFromEdgedVerticesUniqR = - stronglyConnCompG . graphFromEdgedVertices reduceNodesIntoVerticesUniq + stronglyConnCompG . graphFromEdgedVerticesUniq {- ************************************************************************ @@ -357,7 +349,7 @@ stronglyConnCompFromEdgedVerticesUniqR = topologicalSortG :: Graph node -> [node] topologicalSortG graph = map (gr_vertex_to_node graph) result - where result = {-# SCC "Digraph.topSort" #-} topSort (gr_int_graph graph) + where result = {-# SCC "Digraph.topSort" #-} G.topSort (gr_int_graph graph) reachableG :: Graph node -> node -> [node] reachableG graph from = map (gr_vertex_to_node graph) result @@ -377,22 +369,31 @@ reachablesG graph froms = map (gr_vertex_to_node graph) result vs = [ v | Just v <- map (gr_node_to_vertex graph) froms ] -- | Efficiently construct a map which maps each key to it's set of transitive --- dependencies. +-- dependencies. Only works on acyclic input. allReachable :: Ord key => Graph node -> (node -> key) -> M.Map key (S.Set key) -allReachable (Graph g from _) conv = - M.fromList [(conv (from v), IS.foldr (\k vs -> conv (from k) `S.insert` vs) S.empty vs) - | (v, vs) <- IM.toList int_graph] +allReachable = all_reachable reachableGraph + +-- | Efficiently construct a map which maps each key to it's set of transitive +-- dependencies. Less efficient than @allReachable@, but works on cyclic input as well. +allReachableCyclic :: Ord key => Graph node -> (node -> key) -> M.Map key (S.Set key) +allReachableCyclic = all_reachable reachableGraphCyclic + +all_reachable :: Ord key => (IntGraph -> IM.IntMap IS.IntSet) -> Graph node -> (node -> key) -> M.Map key (S.Set key) +all_reachable int_reachables (Graph g from _) keyOf = + M.fromList [(k, IS.foldr (\v' vs -> keyOf (from v') `S.insert` vs) S.empty vs) + | (v, vs) <- IM.toList int_graph + , let k = keyOf (from v)] where - int_graph = reachableGraph g + int_graph = int_reachables g hasVertexG :: Graph node -> node -> Bool hasVertexG graph node = isJust $ gr_node_to_vertex graph node verticesG :: Graph node -> [node] -verticesG graph = map (gr_vertex_to_node graph) $ vertices (gr_int_graph graph) +verticesG graph = map (gr_vertex_to_node graph) $ G.vertices (gr_int_graph graph) edgesG :: Graph node -> [Edge node] -edgesG graph = map (\(v1, v2) -> Edge (v2n v1) (v2n v2)) $ edges (gr_int_graph graph) +edgesG graph = map (\(v1, v2) -> Edge (v2n v1) (v2n v2)) $ G.edges (gr_int_graph graph) where v2n = gr_vertex_to_node graph transposeG :: Graph node -> Graph node @@ -452,13 +453,63 @@ preorderF ts = concatMap flatten ts -- This generalizes reachable which was found in Data.Graph reachable :: IntGraph -> [Vertex] -> [Vertex] -reachable g vs = preorderF (dfs g vs) +reachable g vs = preorderF (G.dfs g vs) reachableGraph :: IntGraph -> IM.IntMap IS.IntSet reachableGraph g = res where do_one v = IS.unions (IS.fromList (g ! v) : mapMaybe (flip IM.lookup res) (g ! v)) - res = IM.fromList [(v, do_one v) | v <- vertices g] + res = IM.fromList [(v, do_one v) | v <- G.vertices g] + +scc :: IntGraph -> [SCC Vertex] +scc graph = map decode forest + where + forest = {-# SCC "Digraph.scc" #-} G.scc graph + + decode (Node v []) | mentions_itself v = CyclicSCC [v] + | otherwise = AcyclicSCC v + decode other = CyclicSCC (dec other []) + where dec (Node v ts) vs = v : foldr dec vs ts + mentions_itself v = v `elem` (graph ! v) + +reachableGraphCyclic :: IntGraph -> IM.IntMap IS.IntSet +reachableGraphCyclic g = foldl' add_one_comp mempty comps + where + neighboursOf v = g!v + + comps = scc g + + -- To avoid divergence on cyclic input, we build the result + -- strongly connected component by component, in topological + -- order. For each SCC, we know that: + -- + -- * All vertices in the component can reach all other vertices + -- in the component ("local" reachables) + -- + -- * Other reachable vertices ("remote" reachables) must come + -- from earlier components, either via direct neighbourhood, or + -- transitively from earlier reachability map + -- + -- This allows us to build the extension of the reachability map + -- directly, without any self-reference, thereby avoiding a loop. + add_one_comp :: IM.IntMap IS.IntSet -> SCC Vertex -> IM.IntMap IS.IntSet + add_one_comp earlier (AcyclicSCC v) = IM.insert v all_remotes earlier + where + earlier_neighbours = neighboursOf v + earlier_further = mapMaybe (flip IM.lookup earlier) earlier_neighbours + all_remotes = IS.unions (IS.fromList earlier_neighbours : earlier_further) + add_one_comp earlier (CyclicSCC vs) = IM.union (IM.fromList [(v, local v `IS.union` all_remotes) | v <- vs]) earlier + where + all_locals = IS.fromList vs + local v = IS.delete v all_locals + -- Arguably, for a cyclic SCC we should include each + -- vertex in its own reachable set. However, this could + -- lead to a lot of extra pain in client code to avoid + -- looping when traversing the reachability map. + all_neighbours = IS.fromList (concatMap neighboursOf vs) + earlier_neighbours = all_neighbours IS.\\ all_locals + earlier_further = mapMaybe (flip IM.lookup earlier) (IS.toList earlier_neighbours) + all_remotes = IS.unions (earlier_neighbours : earlier_further) {- ************************************************************************ @@ -565,4 +616,4 @@ graphFromVerticesAndAdjacency vertices edges = Graph graph vertex_node (key_vert key_vertex_pair (a, b) = (expectJust "graphFromVerticesAndAdjacency" $ key_vertex a, expectJust "graphFromVerticesAndAdjacency" $ key_vertex b) reduced_edges = map key_vertex_pair edges - graph = buildG bounds reduced_edges + graph = G.buildG bounds reduced_edges ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -315,7 +315,6 @@ rtsPackageArgs = package rts ? do -- provide non-inlined alternatives and hence needs the function to -- be inlined. See https://github.com/snowleopard/hadrian/issues/90. , arg "-O2" - , arg "-g" , arg "-Irts" , arg $ "-I" ++ path ===================================== libraries/base/Data/Array/Byte.hs ===================================== @@ -101,18 +101,20 @@ byteArrayToList arr = go 0 -- | Create a 'ByteArray' from a list of a known length. If the length -- of the list does not match the given length, this throws an exception. byteArrayFromListN :: Int -> [Word8] -> ByteArray -byteArrayFromListN n ys = runST $ do +byteArrayFromListN n ys + | n >= 0 = runST $ do marr <- newByteArray n let go !ix [] = if ix == n then return () - else error $ "Data.Array.Byte.byteArrayFromListN: list length less than specified size" + else errorWithoutStackTrace $ "Data.Array.Byte.byteArrayFromListN: list length less than specified size" go !ix (x : xs) = if ix < n then do writeByteArray marr ix x go (ix + 1) xs - else error $ "Data.Array.Byte.byteArrayFromListN: list length greater than specified size" + else errorWithoutStackTrace $ "Data.Array.Byte.byteArrayFromListN: list length greater than specified size" go 0 ys unsafeFreezeByteArray marr + | otherwise = errorWithoutStackTrace "Data.Array.Byte.ByteArrayFromListN: specified size is negative" -- | Copy a slice of an immutable byte array to a mutable byte array. -- ===================================== libraries/base/Data/Typeable/Internal.hs ===================================== @@ -836,6 +836,8 @@ instance Show (TypeRep (a :: k)) where showTypeable :: Int -> TypeRep (a :: k) -> ShowS showTypeable _ TrType = showChar '*' showTypeable _ rep + | isListTyCon tc, [] <- tys = + showString "[]" | isListTyCon tc, [ty] <- tys = showChar '[' . shows ty . showChar ']' ===================================== libraries/base/Type/Reflection/Unsafe.hs ===================================== @@ -12,7 +12,7 @@ -- type representations. -- ----------------------------------------------------------------------------- -{-# LANGUAGE PolyKinds, DataKinds, ScopedTypeVariables #-} +{-# LANGUAGE PolyKinds, DataKinds, ScopedTypeVariables, Unsafe #-} module Type.Reflection.Unsafe ( -- * Type representations ===================================== libraries/base/changelog.md ===================================== @@ -56,6 +56,7 @@ `malloc` for allocation. It avoids the O(n) overhead of maintaining a list of individually allocated pointers as well as freeing each one of them when freeing a `Pool`. (#14762) (#18338) + * `Type.Reflection.Unsafe` is now marked as unsafe. ## 4.17.0.0 *August 2022* ===================================== rts/eventlog/EventLog.c ===================================== @@ -754,7 +754,17 @@ void postCapsetVecEvent (EventTypeNum tag, for (int i = 0; i < argc; i++) { // 1 + strlen to account for the trailing \0, used as separator - size += 1 + strlen(argv[i]); + int increment = 1 + strlen(argv[i]); + if (size + increment > EVENT_PAYLOAD_SIZE_MAX) { + errorBelch("Event size exceeds EVENT_PAYLOAD_SIZE_MAX, record only %" + FMT_Int " out of %" FMT_Int " args", + (long long) i, + (long long) argc); + argc = i; + break; + } else { + size += increment; + } } ACQUIRE_LOCK(&eventBufMutex); ===================================== testsuite/tests/typecheck/should_run/TestTypeableBinary.hs ===================================== @@ -35,3 +35,4 @@ main = do testRoundtrip (typeRep :: TypeRep 5) testRoundtrip (typeRep :: TypeRep "hello world") testRoundtrip (typeRep :: TypeRep ('Just 5)) + testRoundtrip (typeRep :: TypeRep []) ===================================== testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout ===================================== @@ -13,3 +13,4 @@ good: Int -> Int good: 5 good: "hello world" good: 'Just Natural 5 +good: [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5025fe44cfa7eac0f9f466bb723b3a7cb5e323e8...a0a060266312f6b5f725efed8b389c7e63c6b469 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5025fe44cfa7eac0f9f466bb723b3a7cb5e323e8...a0a060266312f6b5f725efed8b389c7e63c6b469 You're receiving 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 Dec 7 22:24:03 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 07 Dec 2022 17:24:03 -0500 Subject: [Git][ghc/ghc][wip/force-docs] Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <63911283dd5fc_224fca18f7d7543412b1@gitlab.mail> Matthew Pickering pushed to branch wip/force-docs at Glasgow Haskell Compiler / GHC Commits: abeed5eb by Zubin Duggal at 2022-12-07T22:23:46+00:00 Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Involves adding many new NFData instances. Without forcing Docs, references to the TcGblEnv for each module are retained by the Docs structure. Usually these are forced when the ModIface is serialised but not when we aren't writing the interface. - - - - - 10 changed files: - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/FieldLabel.hs - compiler/GHC/Types/Name.hs-boot - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Types/Unique/Map.hs - compiler/GHC/Unit/Module/ModIface.hs Changes: ===================================== compiler/GHC/Data/EnumSet.hs ===================================== @@ -15,11 +15,12 @@ module GHC.Data.EnumSet import GHC.Prelude import GHC.Utils.Binary +import Control.DeepSeq import qualified Data.IntSet as IntSet newtype EnumSet a = EnumSet IntSet.IntSet - deriving (Semigroup, Monoid) + deriving (Semigroup, Monoid, NFData) member :: Enum a => a -> EnumSet a -> Bool member x (EnumSet s) = IntSet.member (fromEnum x) s ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -26,6 +26,7 @@ import GHC.Utils.Outputable import GHC.Utils.Binary import GHC.Data.EnumSet as EnumSet +import Control.DeepSeq import Control.Monad (guard) import Data.List.NonEmpty (NonEmpty(..)) import Data.Maybe (fromMaybe,mapMaybe) @@ -40,6 +41,9 @@ instance Binary Language where put_ bh = put_ bh . fromEnum get bh = toEnum <$> get bh +instance NFData Language where + rnf x = x `seq` () + -- | Debugging flags data DumpFlag -- See Note [Updating flag description in the User's Guide] ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -38,6 +38,7 @@ import GHC.Types.Avail import GHC.Types.Name.Set import GHC.Driver.Flags +import Control.DeepSeq import Data.Data import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap @@ -74,6 +75,8 @@ data WithHsDocIdentifiers a pass = WithHsDocIdentifiers deriving instance (Data pass, Data (IdP pass), Data a) => Data (WithHsDocIdentifiers a pass) deriving instance (Eq (IdP pass), Eq a) => Eq (WithHsDocIdentifiers a pass) +instance (NFData (IdP pass), NFData a) => NFData (WithHsDocIdentifiers a pass) where + rnf (WithHsDocIdentifiers d i) = rnf d `seq` rnf i -- | For compatibility with the existing @-ddump-parsed' output, we only show -- the docstring. @@ -118,19 +121,19 @@ type LHsDoc pass = Located (HsDoc pass) -- | A simplified version of 'HsImpExp.IE'. data DocStructureItem - = DsiSectionHeading Int (HsDoc GhcRn) - | DsiDocChunk (HsDoc GhcRn) - | DsiNamedChunkRef String - | DsiExports Avails + = DsiSectionHeading !Int !(HsDoc GhcRn) + | DsiDocChunk !(HsDoc GhcRn) + | DsiNamedChunkRef !(String) + | DsiExports !Avails | DsiModExport - (NonEmpty ModuleName) -- ^ We might re-export avails from multiple + !(NonEmpty ModuleName) -- ^ We might re-export avails from multiple -- modules with a single export declaration. E.g. -- when we have -- -- > module M (module X) where -- > import R0 as X -- > import R1 as X - Avails + !Avails instance Binary DocStructureItem where put_ bh = \case @@ -179,6 +182,15 @@ instance Outputable DocStructureItem where DsiModExport mod_names avails -> text "re-exported module(s):" <+> ppr mod_names $$ nest 2 (ppr avails) +instance NFData DocStructureItem where + rnf = \case + DsiSectionHeading level doc -> rnf level `seq` rnf doc + DsiDocChunk doc -> rnf doc + DsiNamedChunkRef name -> rnf name + DsiExports avails -> rnf avails + DsiModExport mod_names avails -> rnf mod_names `seq` rnf avails + + type DocStructure = [DocStructureItem] data Docs = Docs @@ -203,6 +215,12 @@ data Docs = Docs -- ^ The full set of language extensions used in the module. } +instance NFData Docs where + rnf (Docs mod_hdr decls args structure named_chunks haddock_opts language extentions) + = rnf mod_hdr `seq` rnf decls `seq` rnf args `seq` rnf structure `seq` rnf named_chunks + `seq` rnf haddock_opts `seq` rnf language `seq` rnf extentions + `seq` () + instance Binary Docs where put_ bh docs = do put_ bh (docs_mod_hdr docs) ===================================== compiler/GHC/Hs/DocString.hs ===================================== @@ -1,5 +1,7 @@ -- | An exactprintable structure for docstrings {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} module GHC.Hs.DocString ( LHsDocString @@ -27,6 +29,7 @@ import GHC.Utils.Binary import GHC.Utils.Encoding import GHC.Utils.Outputable as Outputable hiding ((<>)) import GHC.Types.SrcLoc +import Control.DeepSeq import Data.ByteString (ByteString) import qualified Data.ByteString as BS @@ -59,6 +62,11 @@ data HsDocString instance Outputable HsDocString where ppr = text . renderHsDocString +instance NFData HsDocString where + rnf (MultiLineDocString a b) = rnf a `seq` rnf b + rnf (NestedDocString a b) = rnf a `seq` rnf b + rnf (GeneratedDocString a) = rnf a + -- | Annotate a pretty printed thing with its doc -- The docstring comes after if is 'HsDocStringPrevious' -- Otherwise it comes before. @@ -101,6 +109,12 @@ data HsDocStringDecorator instance Outputable HsDocStringDecorator where ppr = text . printDecorator +instance NFData HsDocStringDecorator where + rnf HsDocStringNext = () + rnf HsDocStringPrevious = () + rnf (HsDocStringNamed x) = rnf x + rnf (HsDocStringGroup x) = rnf x + printDecorator :: HsDocStringDecorator -> String printDecorator HsDocStringNext = "|" printDecorator HsDocStringPrevious = "^" @@ -126,7 +140,8 @@ type LHsDocStringChunk = Located HsDocStringChunk -- | A contiguous chunk of documentation newtype HsDocStringChunk = HsDocStringChunk ByteString - deriving (Eq,Ord,Data, Show) + deriving stock (Eq,Ord,Data, Show) + deriving newtype (NFData) instance Binary HsDocStringChunk where put_ bh (HsDocStringChunk bs) = put_ bh bs @@ -135,7 +150,6 @@ instance Binary HsDocStringChunk where instance Outputable HsDocStringChunk where ppr = text . unpackHDSC - mkHsDocStringChunk :: String -> HsDocStringChunk mkHsDocStringChunk s = HsDocStringChunk (utf8EncodeByteString s) ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -50,6 +50,7 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Constants (debugIsOn) +import Control.DeepSeq import Data.Data ( Data ) import Data.Either ( partitionEithers ) import Data.Functor.Classes ( liftCompare ) @@ -272,6 +273,10 @@ instance Outputable GreName where ppr (NormalGreName n) = ppr n ppr (FieldGreName fl) = ppr fl +instance NFData GreName where + rnf (NormalGreName n) = rnf n + rnf (FieldGreName f) = rnf f + instance HasOccName GreName where occName (NormalGreName n) = occName n occName (FieldGreName fl) = occName fl @@ -385,6 +390,10 @@ instance Binary AvailInfo where ac <- get bh return (AvailTC ab ac) +instance NFData AvailInfo where + rnf (Avail n) = rnf n + rnf (AvailTC a b) = rnf a `seq` rnf b + instance Binary GreName where put_ bh (NormalGreName aa) = do putByte bh 0 @@ -399,3 +408,4 @@ instance Binary GreName where return (NormalGreName aa) _ -> do ab <- get bh return (FieldGreName ab) + ===================================== compiler/GHC/Types/FieldLabel.hs ===================================== @@ -95,6 +95,7 @@ import GHC.Utils.Binary import Language.Haskell.Syntax.Basic (FieldLabelString(..)) +import Control.DeepSeq import Data.Bool import Data.Data @@ -129,6 +130,8 @@ instance Outputable FieldLabelString where instance Uniquable FieldLabelString where getUnique (FieldLabelString fs) = getUnique fs +instance NFData FieldLabel where + rnf (FieldLabel a b c d) = rnf a `seq` rnf b `seq` rnf c `seq` rnf d -- | Flag to indicate whether the DuplicateRecordFields extension is enabled. data DuplicateRecordFields @@ -144,6 +147,8 @@ instance Outputable DuplicateRecordFields where ppr DuplicateRecordFields = text "+dup" ppr NoDuplicateRecordFields = text "-dup" +instance NFData DuplicateRecordFields where + rnf x = x `seq` () -- | Flag to indicate whether the FieldSelectors extension is enabled. data FieldSelectors @@ -159,6 +164,8 @@ instance Outputable FieldSelectors where ppr FieldSelectors = text "+sel" ppr NoFieldSelectors = text "-sel" +instance NFData FieldSelectors where + rnf x = x `seq` () -- | We need the @Binary Name@ constraint here even though there is an instance -- defined in "GHC.Types.Name", because the we have a SOURCE import, so the ===================================== compiler/GHC/Types/Name.hs-boot ===================================== @@ -8,6 +8,7 @@ import {-# SOURCE #-} GHC.Types.Name.Occurrence import GHC.Types.Unique import GHC.Utils.Outputable import Data.Data (Data) +import Control.DeepSeq (NFData) data Name @@ -15,6 +16,7 @@ instance Eq Name instance Data Name instance Uniquable Name instance Outputable Name +instance NFData Name class NamedThing a where getOccName :: a -> OccName ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -735,6 +735,8 @@ pprUserRealSpan show_path (RealSrcSpan' src_path sline scol eline ecol) -- | We attach SrcSpans to lots of things, so let's have a datatype for it. data GenLocated l e = L l e deriving (Eq, Ord, Show, Data, Functor, Foldable, Traversable) +instance (NFData l, NFData e) => NFData (GenLocated l e) where + rnf (L l e) = rnf l `seq` rnf e type Located = GenLocated SrcSpan type RealLocated = GenLocated RealSrcSpan ===================================== compiler/GHC/Types/Unique/Map.hs ===================================== @@ -59,6 +59,7 @@ import Data.Semigroup as Semi ( Semigroup(..) ) import Data.Coerce import Data.Maybe import Data.Data +import Control.DeepSeq -- | Maps indexed by 'Uniquable' keys newtype UniqMap k a = UniqMap { getUniqMap :: UniqFM k (k, a) } @@ -78,6 +79,9 @@ instance (Outputable k, Outputable a) => Outputable (UniqMap k a) where [ ppr k <+> text "->" <+> ppr v | (k, v) <- nonDetEltsUFM m ] +instance (NFData k, NFData a) => NFData (UniqMap k a) where + rnf (UniqMap fm) = seqEltsUFM rnf fm + liftC :: (a -> a -> a) -> (k, a) -> (k, a) -> (k, a) liftC f (_, v) (k', v') = (k', f v v') ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -240,7 +240,7 @@ data ModIface_ (phase :: ModIfacePhase) -- See Note [Trust Own Package] in GHC.Rename.Names mi_complete_matches :: ![IfaceCompleteMatch], - mi_docs :: Maybe Docs, + mi_docs :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- @@ -554,7 +554,7 @@ instance (NFData (IfaceBackendExts (phase :: ModIfacePhase)), NFData (IfaceDeclE f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24) = rnf f1 `seq` rnf f2 `seq` f3 `seq` f4 `seq` f5 `seq` f6 `seq` rnf f7 `seq` f8 `seq` f9 `seq` rnf f10 `seq` rnf f11 `seq` rnf f12 `seq` f13 `seq` rnf f14 `seq` rnf f15 `seq` rnf f16 `seq` - rnf f17 `seq` f18 `seq` rnf f19 `seq` rnf f20 `seq` f21 `seq` f22 `seq` f23 `seq` rnf f24 + rnf f17 `seq` f18 `seq` rnf f19 `seq` rnf f20 `seq` rnf f21 `seq` f22 `seq` f23 `seq` rnf f24 `seq` () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abeed5ebfc5be78c7decc0bad7f7cf8f7d95cfc5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abeed5ebfc5be78c7decc0bad7f7cf8f7d95cfc5 You're receiving 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 Dec 7 22:37:20 2022 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 07 Dec 2022 17:37:20 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/exactprint-epalocation-for-anchor Message-ID: <639115a0901d4_224fca6066c34218f@gitlab.mail> Alan Zimmerman pushed new branch wip/az/exactprint-epalocation-for-anchor at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/exactprint-epalocation-for-anchor You're receiving 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 Dec 8 00:42:36 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Wed, 07 Dec 2022 19:42:36 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-2] Lower min autoconf version for rts configure Message-ID: <639132fc2c9a0_224fcabe792c03568b3@gitlab.mail> John Ericson pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: f8a07f5a by John Ericson at 2022-12-07T19:41:09-05:00 Lower min autoconf version for rts configure we're not sure why it was raised. - - - - - 1 changed file: - rts/configure.ac Changes: ===================================== rts/configure.ac ===================================== @@ -20,7 +20,7 @@ dnl * We need 2.52 due to the use of AS_TR_CPP and AS_TR_SH. dnl * Using autoconf 2.59 started to give nonsense like this dnl #define SIZEOF_CHAR 0 dnl recently. -AC_PREREQ([2.71]) +AC_PREREQ([2.69]) AC_CONFIG_HEADERS([include/ghcautoconf.h]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8a07f5af1caff28ce721f194747fd659c53d544 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f8a07f5af1caff28ce721f194747fd659c53d544 You're receiving 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 Dec 8 09:31:07 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Thu, 08 Dec 2022 04:31:07 -0500 Subject: [Git][ghc/ghc][wip/or-pats] Add Or Patterns (proposal 0522) Message-ID: <6391aedbbc51b_224fcabe792c03994aa@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: d3b2d208 by David Knothe at 2022-12-08T10:30:05+01:00 Add Or Patterns (proposal 0522) - - - - - 30 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Name/Reader.hs - compiler/Language/Haskell/Syntax/Extension.hs - compiler/Language/Haskell/Syntax/Pat.hs - libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs - + testsuite/tests/deSugar/should_run/Or5.hs - + testsuite/tests/deSugar/should_run/Or5.stderr - + testsuite/tests/deSugar/should_run/Or5.stdout - testsuite/tests/deSugar/should_run/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d3b2d20835c7b9c3bed896e1472d67913640b42e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d3b2d20835c7b9c3bed896e1472d67913640b42e You're receiving 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 Dec 8 09:59:09 2022 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Thu, 08 Dec 2022 04:59:09 -0500 Subject: [Git][ghc/ghc][wip/js-fileStat] 91 commits: Fix fragile RULE setup in GHC.Float Message-ID: <6391b56d65bb5_224fca526d4405979@gitlab.mail> Josh Meredith pushed to branch wip/js-fileStat at Glasgow Haskell Compiler / GHC Commits: 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - d2c9c1b6 by Josh Meredith at 2022-12-08T09:58:43+00:00 WIP JS fileStat - - - - - 12 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fc49c596806ca1fec853a8787b1ae3b4730d7c3...d2c9c1b6b166bfee1632efc9b0208a83c6ee4c7a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fc49c596806ca1fec853a8787b1ae3b4730d7c3...d2c9c1b6b166bfee1632efc9b0208a83c6ee4c7a You're receiving 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 Dec 8 10:46:28 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 08 Dec 2022 05:46:28 -0500 Subject: [Git][ghc/ghc][wip/force-docs] Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Message-ID: <6391c084ab470_224fca6068041855d@gitlab.mail> Matthew Pickering pushed to branch wip/force-docs at Glasgow Haskell Compiler / GHC Commits: 38a78f51 by Zubin Duggal at 2022-12-08T10:46:18+00:00 Force the Docs structure to prevent leaks in GHCi with -haddock without -fwrite-interface Involves adding many new NFData instances. Without forcing Docs, references to the TcGblEnv for each module are retained by the Docs structure. Usually these are forced when the ModIface is serialised but not when we aren't writing the interface. - - - - - 11 changed files: - compiler/GHC/Data/EnumSet.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Types/Avail.hs - compiler/GHC/Types/FieldLabel.hs - compiler/GHC/Types/Name.hs-boot - compiler/GHC/Types/SrcLoc.hs - compiler/GHC/Types/Unique/Map.hs - compiler/GHC/Unit/Module/ModIface.hs - compiler/Language/Haskell/Syntax/Basic.hs Changes: ===================================== compiler/GHC/Data/EnumSet.hs ===================================== @@ -15,11 +15,12 @@ module GHC.Data.EnumSet import GHC.Prelude import GHC.Utils.Binary +import Control.DeepSeq import qualified Data.IntSet as IntSet newtype EnumSet a = EnumSet IntSet.IntSet - deriving (Semigroup, Monoid) + deriving (Semigroup, Monoid, NFData) member :: Enum a => a -> EnumSet a -> Bool member x (EnumSet s) = IntSet.member (fromEnum x) s ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -26,6 +26,7 @@ import GHC.Utils.Outputable import GHC.Utils.Binary import GHC.Data.EnumSet as EnumSet +import Control.DeepSeq import Control.Monad (guard) import Data.List.NonEmpty (NonEmpty(..)) import Data.Maybe (fromMaybe,mapMaybe) @@ -40,6 +41,9 @@ instance Binary Language where put_ bh = put_ bh . fromEnum get bh = toEnum <$> get bh +instance NFData Language where + rnf x = x `seq` () + -- | Debugging flags data DumpFlag -- See Note [Updating flag description in the User's Guide] ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -38,6 +38,7 @@ import GHC.Types.Avail import GHC.Types.Name.Set import GHC.Driver.Flags +import Control.DeepSeq import Data.Data import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap @@ -74,6 +75,8 @@ data WithHsDocIdentifiers a pass = WithHsDocIdentifiers deriving instance (Data pass, Data (IdP pass), Data a) => Data (WithHsDocIdentifiers a pass) deriving instance (Eq (IdP pass), Eq a) => Eq (WithHsDocIdentifiers a pass) +instance (NFData (IdP pass), NFData a) => NFData (WithHsDocIdentifiers a pass) where + rnf (WithHsDocIdentifiers d i) = rnf d `seq` rnf i -- | For compatibility with the existing @-ddump-parsed' output, we only show -- the docstring. @@ -118,19 +121,19 @@ type LHsDoc pass = Located (HsDoc pass) -- | A simplified version of 'HsImpExp.IE'. data DocStructureItem - = DsiSectionHeading Int (HsDoc GhcRn) - | DsiDocChunk (HsDoc GhcRn) - | DsiNamedChunkRef String - | DsiExports Avails + = DsiSectionHeading !Int !(HsDoc GhcRn) + | DsiDocChunk !(HsDoc GhcRn) + | DsiNamedChunkRef !(String) + | DsiExports !Avails | DsiModExport - (NonEmpty ModuleName) -- ^ We might re-export avails from multiple + !(NonEmpty ModuleName) -- ^ We might re-export avails from multiple -- modules with a single export declaration. E.g. -- when we have -- -- > module M (module X) where -- > import R0 as X -- > import R1 as X - Avails + !Avails instance Binary DocStructureItem where put_ bh = \case @@ -179,6 +182,15 @@ instance Outputable DocStructureItem where DsiModExport mod_names avails -> text "re-exported module(s):" <+> ppr mod_names $$ nest 2 (ppr avails) +instance NFData DocStructureItem where + rnf = \case + DsiSectionHeading level doc -> rnf level `seq` rnf doc + DsiDocChunk doc -> rnf doc + DsiNamedChunkRef name -> rnf name + DsiExports avails -> rnf avails + DsiModExport mod_names avails -> rnf mod_names `seq` rnf avails + + type DocStructure = [DocStructureItem] data Docs = Docs @@ -203,6 +215,12 @@ data Docs = Docs -- ^ The full set of language extensions used in the module. } +instance NFData Docs where + rnf (Docs mod_hdr decls args structure named_chunks haddock_opts language extentions) + = rnf mod_hdr `seq` rnf decls `seq` rnf args `seq` rnf structure `seq` rnf named_chunks + `seq` rnf haddock_opts `seq` rnf language `seq` rnf extentions + `seq` () + instance Binary Docs where put_ bh docs = do put_ bh (docs_mod_hdr docs) ===================================== compiler/GHC/Hs/DocString.hs ===================================== @@ -1,5 +1,7 @@ -- | An exactprintable structure for docstrings {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} module GHC.Hs.DocString ( LHsDocString @@ -27,6 +29,7 @@ import GHC.Utils.Binary import GHC.Utils.Encoding import GHC.Utils.Outputable as Outputable hiding ((<>)) import GHC.Types.SrcLoc +import Control.DeepSeq import Data.ByteString (ByteString) import qualified Data.ByteString as BS @@ -59,6 +62,11 @@ data HsDocString instance Outputable HsDocString where ppr = text . renderHsDocString +instance NFData HsDocString where + rnf (MultiLineDocString a b) = rnf a `seq` rnf b + rnf (NestedDocString a b) = rnf a `seq` rnf b + rnf (GeneratedDocString a) = rnf a + -- | Annotate a pretty printed thing with its doc -- The docstring comes after if is 'HsDocStringPrevious' -- Otherwise it comes before. @@ -101,6 +109,12 @@ data HsDocStringDecorator instance Outputable HsDocStringDecorator where ppr = text . printDecorator +instance NFData HsDocStringDecorator where + rnf HsDocStringNext = () + rnf HsDocStringPrevious = () + rnf (HsDocStringNamed x) = rnf x + rnf (HsDocStringGroup x) = rnf x + printDecorator :: HsDocStringDecorator -> String printDecorator HsDocStringNext = "|" printDecorator HsDocStringPrevious = "^" @@ -126,7 +140,8 @@ type LHsDocStringChunk = Located HsDocStringChunk -- | A contiguous chunk of documentation newtype HsDocStringChunk = HsDocStringChunk ByteString - deriving (Eq,Ord,Data, Show) + deriving stock (Eq,Ord,Data, Show) + deriving newtype (NFData) instance Binary HsDocStringChunk where put_ bh (HsDocStringChunk bs) = put_ bh bs @@ -135,7 +150,6 @@ instance Binary HsDocStringChunk where instance Outputable HsDocStringChunk where ppr = text . unpackHDSC - mkHsDocStringChunk :: String -> HsDocStringChunk mkHsDocStringChunk s = HsDocStringChunk (utf8EncodeByteString s) ===================================== compiler/GHC/Types/Avail.hs ===================================== @@ -50,6 +50,7 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Constants (debugIsOn) +import Control.DeepSeq import Data.Data ( Data ) import Data.Either ( partitionEithers ) import Data.Functor.Classes ( liftCompare ) @@ -272,6 +273,10 @@ instance Outputable GreName where ppr (NormalGreName n) = ppr n ppr (FieldGreName fl) = ppr fl +instance NFData GreName where + rnf (NormalGreName n) = rnf n + rnf (FieldGreName f) = rnf f + instance HasOccName GreName where occName (NormalGreName n) = occName n occName (FieldGreName fl) = occName fl @@ -385,6 +390,10 @@ instance Binary AvailInfo where ac <- get bh return (AvailTC ab ac) +instance NFData AvailInfo where + rnf (Avail n) = rnf n + rnf (AvailTC a b) = rnf a `seq` rnf b + instance Binary GreName where put_ bh (NormalGreName aa) = do putByte bh 0 @@ -399,3 +408,4 @@ instance Binary GreName where return (NormalGreName aa) _ -> do ab <- get bh return (FieldGreName ab) + ===================================== compiler/GHC/Types/FieldLabel.hs ===================================== @@ -95,6 +95,7 @@ import GHC.Utils.Binary import Language.Haskell.Syntax.Basic (FieldLabelString(..)) +import Control.DeepSeq import Data.Bool import Data.Data @@ -129,6 +130,8 @@ instance Outputable FieldLabelString where instance Uniquable FieldLabelString where getUnique (FieldLabelString fs) = getUnique fs +instance NFData FieldLabel where + rnf (FieldLabel a b c d) = rnf a `seq` rnf b `seq` rnf c `seq` rnf d -- | Flag to indicate whether the DuplicateRecordFields extension is enabled. data DuplicateRecordFields @@ -144,6 +147,8 @@ instance Outputable DuplicateRecordFields where ppr DuplicateRecordFields = text "+dup" ppr NoDuplicateRecordFields = text "-dup" +instance NFData DuplicateRecordFields where + rnf x = x `seq` () -- | Flag to indicate whether the FieldSelectors extension is enabled. data FieldSelectors @@ -159,6 +164,8 @@ instance Outputable FieldSelectors where ppr FieldSelectors = text "+sel" ppr NoFieldSelectors = text "-sel" +instance NFData FieldSelectors where + rnf x = x `seq` () -- | We need the @Binary Name@ constraint here even though there is an instance -- defined in "GHC.Types.Name", because the we have a SOURCE import, so the ===================================== compiler/GHC/Types/Name.hs-boot ===================================== @@ -8,6 +8,7 @@ import {-# SOURCE #-} GHC.Types.Name.Occurrence import GHC.Types.Unique import GHC.Utils.Outputable import Data.Data (Data) +import Control.DeepSeq (NFData) data Name @@ -15,6 +16,7 @@ instance Eq Name instance Data Name instance Uniquable Name instance Outputable Name +instance NFData Name class NamedThing a where getOccName :: a -> OccName ===================================== compiler/GHC/Types/SrcLoc.hs ===================================== @@ -735,6 +735,8 @@ pprUserRealSpan show_path (RealSrcSpan' src_path sline scol eline ecol) -- | We attach SrcSpans to lots of things, so let's have a datatype for it. data GenLocated l e = L l e deriving (Eq, Ord, Show, Data, Functor, Foldable, Traversable) +instance (NFData l, NFData e) => NFData (GenLocated l e) where + rnf (L l e) = rnf l `seq` rnf e type Located = GenLocated SrcSpan type RealLocated = GenLocated RealSrcSpan ===================================== compiler/GHC/Types/Unique/Map.hs ===================================== @@ -59,6 +59,7 @@ import Data.Semigroup as Semi ( Semigroup(..) ) import Data.Coerce import Data.Maybe import Data.Data +import Control.DeepSeq -- | Maps indexed by 'Uniquable' keys newtype UniqMap k a = UniqMap { getUniqMap :: UniqFM k (k, a) } @@ -78,6 +79,9 @@ instance (Outputable k, Outputable a) => Outputable (UniqMap k a) where [ ppr k <+> text "->" <+> ppr v | (k, v) <- nonDetEltsUFM m ] +instance (NFData k, NFData a) => NFData (UniqMap k a) where + rnf (UniqMap fm) = seqEltsUFM rnf fm + liftC :: (a -> a -> a) -> (k, a) -> (k, a) -> (k, a) liftC f (_, v) (k', v') = (k', f v v') ===================================== compiler/GHC/Unit/Module/ModIface.hs ===================================== @@ -240,7 +240,7 @@ data ModIface_ (phase :: ModIfacePhase) -- See Note [Trust Own Package] in GHC.Rename.Names mi_complete_matches :: ![IfaceCompleteMatch], - mi_docs :: Maybe Docs, + mi_docs :: !(Maybe Docs), -- ^ Docstrings and related data for use by haddock, the ghci -- @:doc@ command, and other tools. -- @@ -554,7 +554,7 @@ instance (NFData (IfaceBackendExts (phase :: ModIfacePhase)), NFData (IfaceDeclE f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24) = rnf f1 `seq` rnf f2 `seq` f3 `seq` f4 `seq` f5 `seq` f6 `seq` rnf f7 `seq` f8 `seq` f9 `seq` rnf f10 `seq` rnf f11 `seq` rnf f12 `seq` f13 `seq` rnf f14 `seq` rnf f15 `seq` rnf f16 `seq` - rnf f17 `seq` f18 `seq` rnf f19 `seq` rnf f20 `seq` f21 `seq` f22 `seq` f23 `seq` rnf f24 + rnf f17 `seq` f18 `seq` rnf f19 `seq` rnf f20 `seq` rnf f21 `seq` f22 `seq` f23 `seq` rnf f24 `seq` () ===================================== compiler/Language/Haskell/Syntax/Basic.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE GeneralisedNewtypeDeriving #-} module Language.Haskell.Syntax.Basic where import Data.Data @@ -8,6 +9,7 @@ import Data.Bool import Data.Int (Int) import GHC.Data.FastString (FastString) +import Control.DeepSeq {- ************************************************************************ @@ -54,7 +56,7 @@ Field Labels -- | Field labels are just represented as strings; -- they are not necessarily unique (even within a module) newtype FieldLabelString = FieldLabelString { field_label:: FastString } - deriving (Data, Eq) + deriving (Data, Eq, NFData) {- ************************************************************************ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38a78f51b9b33f8bd39534f7930301b3310e49e2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38a78f51b9b33f8bd39534f7930301b3310e49e2 You're receiving 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 Dec 8 11:22:14 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 08 Dec 2022 06:22:14 -0500 Subject: [Git][ghc/ghc][wip/various-hadrian-fixes] packaging: Build perf builds with -split-sections Message-ID: <6391c8e61033_224fcafbc6768430142@gitlab.mail> Matthew Pickering pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC Commits: 13979253 by Matthew Pickering at 2022-12-08T11:22:03+00:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 5 changed files: - .gitlab-ci.yml - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - hadrian/doc/flavours.md - hadrian/src/Settings/Flavours/Performance.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -423,7 +423,7 @@ doc-tarball: optional: true - job: nightly-x86_64-windows-validate optional: true - - job: release-x86_64-windows-release + - job: release-x86_64-windows-release+no_split_sections optional: true tags: @@ -447,7 +447,7 @@ doc-tarball: || mv "ghc-x86_64-linux-deb10-release.tar.xz" "$LINUX_BINDIST" \ || true mv "ghc-x86_64-windows-validate.tar.xz" "$WINDOWS_BINDIST" \ - || mv "ghc-x86_64-windows-release.tar.xz" "$WINDOWS_BINDIST" \ + || mv "ghc-x86_64-windows-release+no_split_sections.tar.xz" "$WINDOWS_BINDIST" \ || true if [ ! -f "$LINUX_BINDIST" ]; then echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" ===================================== .gitlab/gen_ci.hs ===================================== @@ -130,6 +130,7 @@ data BuildConfig , fullyStatic :: Bool , tablesNextToCode :: Bool , threadSanitiser :: Bool + , noSplitSections :: Bool } -- Extra arguments to pass to ./configure due to the BuildConfig @@ -146,13 +147,14 @@ mkJobFlavour BuildConfig{..} = Flavour buildFlavour opts opts = [Llvm | llvmBootstrap] ++ [Dwarf | withDwarf] ++ [FullyStatic | fullyStatic] ++ - [ThreadSanitiser | threadSanitiser] + [ThreadSanitiser | threadSanitiser] ++ + [NoSplitSections | noSplitSections, buildFlavour == Release ] data Flavour = Flavour BaseFlavour [FlavourTrans] -data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser +data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser | NoSplitSections -data BaseFlavour = Release | Validate | SlowValidate +data BaseFlavour = Release | Validate | SlowValidate deriving Eq ----------------------------------------------------------------------------- -- Build Configs @@ -174,8 +176,12 @@ vanilla = BuildConfig , fullyStatic = False , tablesNextToCode = True , threadSanitiser = False + , noSplitSections = False } +splitSectionsBroken :: BuildConfig -> BuildConfig +splitSectionsBroken bc = bc { noSplitSections = True } + nativeInt :: BuildConfig nativeInt = vanilla { bignumBackend = Native } @@ -290,6 +296,7 @@ flavourString (Flavour base trans) = baseString base ++ concatMap (("+" ++) . fl flavourString Dwarf = "debug_info" flavourString FullyStatic = "fully_static" flavourString ThreadSanitiser = "thread_sanitizer" + flavourString NoSplitSections = "no_split_sections" -- The path to the docker image (just for linux builders) dockerImage :: Arch -> Opsys -> Maybe String @@ -792,22 +799,22 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , disableValidate (standardBuilds Amd64 (Linux Debian11)) -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 -- not being at EOL until April 2023 and they still need tinfo5. - , disableValidate (standardBuilds Amd64 (Linux Debian9)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) (splitSectionsBroken vanilla)) , disableValidate (standardBuilds Amd64 (Linux Ubuntu2004)) - , disableValidate (standardBuilds Amd64 (Linux Centos7)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Centos7) (splitSectionsBroken vanilla)) -- Fedora33 job is always built with perf so there's one job in the normal -- validate pipeline which is built with perf. , (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig) -- This job is only for generating head.hackage docs , hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig)) , disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf) - , fastCI (standardBuilds Amd64 Windows) - , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt) + , fastCI (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla)) + , disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt)) , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , standardBuilds I386 (Linux Debian9) + , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) static , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) ===================================== .gitlab/jobs.yaml ===================================== @@ -1869,7 +1869,7 @@ "XZ_OPT": "-9" } }, - "release-i386-linux-deb9-release": { + "release-i386-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1879,7 +1879,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-i386-linux-deb9-release.tar.xz", + "ghc-i386-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -1921,11 +1921,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-i386-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "i386-linux-deb9-release", + "TEST_ENV": "i386-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2424,7 +2424,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-linux-deb9-release": { + "release-x86_64-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2434,7 +2434,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-deb9-release.tar.xz", + "ghc-x86_64-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2476,11 +2476,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "x86_64-linux-deb9-release", + "TEST_ENV": "x86_64-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2731,7 +2731,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-windows-int_native-release": { + "release-x86_64-windows-int_native-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2740,7 +2740,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-int_native-release.tar.xz", + "ghc-x86_64-windows-int_native-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2778,8 +2778,8 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2787,11 +2787,11 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-int_native-release", + "TEST_ENV": "x86_64-windows-int_native-release+no_split_sections", "XZ_OPT": "-9" } }, - "release-x86_64-windows-release": { + "release-x86_64-windows-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2800,7 +2800,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-release.tar.xz", + "ghc-x86_64-windows-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2838,8 +2838,8 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-windows-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2847,7 +2847,7 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-release", + "TEST_ENV": "x86_64-windows-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== hadrian/doc/flavours.md ===================================== @@ -15,6 +15,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
FlavourSplit Sections Extra arguments
default
+
-O
-H32m
-O2
-H32m
quick + -O0
-H64m
-O0
-H64m
quick-validate + -O0
-H64m
-Werror
-O0
-H64m
-Werror
quick-debug + -O0
-H64m
-O0
-H64m
quickest + -O0
-H64m
-O0
-H64m
perf + Yes (on supported platforms) -O
-H64m
-O
-H64m
bench + -O
-H64m
-O
-H64m
devel1 + -O
-H64m
-O
-H64m
devel2 + -O
-H64m
-O
-H64m
validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
slow-validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
static + -O
-H64m
-fPIC -static
-O
-H64m
-fPIC -static
Enable section splitting for all libraries (except for the GHC library due to the long linking times that this causes).
no_split_sectionsDisable section splitting for all libraries.
thread_sanitizer Build the runtime system with ThreadSanitizer support
+ @@ -35,6 +36,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -46,6 +48,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -57,6 +60,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -68,6 +72,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -79,6 +84,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -90,6 +96,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -112,6 +119,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -123,6 +131,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -134,6 +143,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -145,6 +155,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -156,6 +167,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -167,6 +179,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH ===================================== hadrian/src/Settings/Flavours/Performance.hs ===================================== @@ -6,7 +6,7 @@ import {-# SOURCE #-} Settings.Default -- Please update doc/flavours.md when changing this file. performanceFlavour :: Flavour -performanceFlavour = defaultFlavour +performanceFlavour = splitSections $ defaultFlavour { name = "perf" , args = defaultBuilderArgs <> performanceArgs <> defaultPackageArgs } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13979253b28cc82a0f437ef64ef4cb3482b254ed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13979253b28cc82a0f437ef64ef4cb3482b254ed You're receiving 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 Dec 8 11:44:51 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 08 Dec 2022 06:44:51 -0500 Subject: [Git][ghc/ghc][wip/hackage-bindist] 2 commits: backpack: Be more careful when adding together ImportAvails Message-ID: <6391ce33e8bdf_224fca60680438885@gitlab.mail> Matthew Pickering pushed to branch wip/hackage-bindist at Glasgow Haskell Compiler / GHC Commits: 08552434 by Matthew Pickering at 2022-12-08T11:44:41+00:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - ee599c52 by Matthew Pickering at 2022-12-08T11:44:41+00:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - 10 changed files: - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Tc/Utils/Backpack.hs - testsuite/tests/backpack/should_fail/T19244a.stderr - + testsuite/tests/determinism/determ024/A.hs - + testsuite/tests/determinism/determ024/B.hs - + testsuite/tests/determinism/determ024/Makefile - + testsuite/tests/determinism/determ024/all.T Changes: ===================================== compiler/GHC/HsToCore.hs ===================================== @@ -41,7 +41,7 @@ import GHC.HsToCore.Coverage import GHC.HsToCore.Docs import GHC.Tc.Types -import GHC.Tc.Utils.Monad ( finalSafeMode, fixSafeInstances ) +import GHC.Tc.Utils.Monad ( finalSafeMode, fixSafeInstances, initIfaceLoad ) import GHC.Tc.Module ( runTcInteractive ) import GHC.Core.Type @@ -241,8 +241,9 @@ deSugar hsc_env ; let plugins = hsc_plugins hsc_env ; let fc = hsc_FC hsc_env ; let unit_env = hsc_unit_env hsc_env - ; usages <- mkUsageInfo uc plugins fc unit_env mod (imp_mods imports) used_names - dep_files merged needed_mods needed_pkgs + ; usages <- initIfaceLoad hsc_env $ + mkUsageInfo uc plugins fc unit_env mod (imp_mods imports) used_names + dep_files merged needed_mods needed_pkgs -- id_mod /= mod when we are processing an hsig, but hsigs -- never desugared and compiled (there's no code!) -- Consequently, this should hold for any ModGuts that make ===================================== compiler/GHC/HsToCore/Usage.hs ===================================== @@ -15,10 +15,13 @@ import GHC.Driver.Env import GHC.Tc.Types +import GHC.Iface.Load + import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Fingerprint import GHC.Utils.Panic +import GHC.Utils.Monad import GHC.Types.Name import GHC.Types.Name.Set ( NameSet, allUses ) @@ -70,18 +73,18 @@ data UsageConfig = UsageConfig } mkUsageInfo :: UsageConfig -> Plugins -> FinderCache -> UnitEnv -> Module -> ImportedMods -> NameSet -> [FilePath] - -> [(Module, Fingerprint)] -> [Linkable] -> PkgsLoaded -> IO [Usage] + -> [(Module, Fingerprint)] -> [Linkable] -> PkgsLoaded -> IfG [Usage] mkUsageInfo uc plugins fc unit_env this_mod dir_imp_mods used_names dependent_files merged needed_links needed_pkgs = do - eps <- readIORef (euc_eps (ue_eps unit_env)) - hashes <- mapM getFileHash dependent_files + eps <- liftIO $ readIORef (euc_eps (ue_eps unit_env)) + hashes <- liftIO $ mapM getFileHash dependent_files let hu = unsafeGetHomeUnit unit_env hug = ue_home_unit_graph unit_env -- Dependencies on object files due to TH and plugins - object_usages <- mkObjectUsage (eps_PIT eps) plugins fc hug needed_links needed_pkgs - let mod_usages = mk_mod_usage_info (eps_PIT eps) uc hug hu this_mod + object_usages <- liftIO $ mkObjectUsage (eps_PIT eps) plugins fc hug needed_links needed_pkgs + mod_usages <- mk_mod_usage_info uc hu this_mod dir_imp_mods used_names - usages = mod_usages ++ [ UsageFile { usg_file_path = f + let usages = mod_usages ++ [ UsageFile { usg_file_path = f , usg_file_hash = hash , usg_file_label = Nothing } | (f, hash) <- zip dependent_files hashes ] @@ -189,16 +192,14 @@ mkObjectUsage pit plugins fc hug th_links_needed th_pkgs_needed = do librarySpecToUsage (DLLPath fn) = traverse (fing Nothing) [fn] librarySpecToUsage _ = return [] -mk_mod_usage_info :: PackageIfaceTable - -> UsageConfig - -> HomeUnitGraph +mk_mod_usage_info :: UsageConfig -> HomeUnit -> Module -> ImportedMods -> NameSet - -> [Usage] -mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names - = mapMaybe mkUsage usage_mods + -> IfG [Usage] +mk_mod_usage_info uc home_unit this_mod direct_imports used_names + = mapMaybeM mkUsageM usage_mods where safe_implicit_imps_req = uc_safe_implicit_imps_req uc @@ -234,22 +235,27 @@ mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names in extendModuleEnvWith (\_ xs -> occ:xs) mv_map mod' [occ] where occ = nameOccName name + mkUsageM :: Module -> IfG (Maybe Usage) + mkUsageM mod | mod == this_mod -- We don't care about usages of things in *this* module + || moduleUnit mod == interactiveUnit -- ... or in GHCi + = return Nothing + mkUsageM mod = do + iface <- loadSysInterface (text "mk_mod_usage") mod + -- Make sure the interface is loaded even if we don't directly use + -- any symbols from it, to ensure determinism. See #22217. + return $ mkUsage mod iface + + -- We want to create a Usage for a home module if -- a) we used something from it; has something in used_names -- b) we imported it, even if we used nothing from it -- (need to recompile if its export list changes: export_fprint) - mkUsage :: Module -> Maybe Usage - mkUsage mod - | isNothing maybe_iface -- We can't depend on it if we didn't - -- load its interface. - || mod == this_mod -- We don't care about usages of - -- things in *this* module - = Nothing - + mkUsage :: Module -> ModIface -> Maybe Usage + mkUsage mod iface | not (isHomeModule home_unit mod) - = Just UsagePackageModule{ usg_mod = mod, - usg_mod_hash = mod_hash, - usg_safe = imp_safe } + = Just $ UsagePackageModule{ usg_mod = mod, + usg_mod_hash = mod_hash, + usg_safe = imp_safe } -- for package modules, we record the module hash only | (null used_occs @@ -269,11 +275,6 @@ mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names usg_entities = Map.toList ent_hashs, usg_safe = imp_safe } where - maybe_iface = lookupIfaceByModule hpt pit mod - -- In one-shot mode, the interfaces for home-package - -- modules accumulate in the PIT not HPT. Sigh. - - Just iface = maybe_iface finsts_mod = mi_finsts (mi_final_exts iface) hash_env = mi_hash_fn (mi_final_exts iface) mod_hash = mi_mod_hash (mi_final_exts iface) ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -232,7 +232,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program -- but if you pass that in here, we'll decide it's the local -- module and does not need to be recorded as a dependency. -- See Note [Identity versus semantic module] - usages <- mkUsageInfo uc plugins fc unit_env this_mod (imp_mods imports) used_names + usages <- initIfaceLoad hsc_env $ mkUsageInfo uc plugins fc unit_env this_mod (imp_mods imports) used_names dep_files merged needed_links needed_pkgs docs <- extractDocs (ms_hspp_opts mod_summary) tc_result ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -589,7 +589,7 @@ checkDependencies hsc_env summary iface liftIO $ check_mods (sort hs) prev_dep_mods `recompThen` - let allPkgDeps = sortBy (comparing snd) $ nubOrdOn snd (ps ++ implicit_deps ++ bkpk_units) + let allPkgDeps = sortBy (comparing snd) $ nubOrdOn snd (ps ++ implicit_deps) in check_packages allPkgDeps prev_dep_pkgs where @@ -613,7 +613,6 @@ checkDependencies hsc_env summary iface prev_dep_mods = map (second gwib_mod) $ Set.toAscList $ dep_direct_mods (mi_deps iface) prev_dep_pkgs = Set.toAscList (Set.union (dep_direct_pkgs (mi_deps iface)) (dep_plugin_pkgs (mi_deps iface))) - bkpk_units = map ((fsLit "Signature",) . instUnitInstanceOf . moduleUnit) (requirementMerges units (moduleName (mi_module iface))) implicit_deps = map (fsLit "Implicit",) (implicitPackageDeps dflags) ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -856,7 +856,6 @@ 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) @@ -867,18 +866,17 @@ mergeSignatures (insts, inst_env) = foldl' merge_inst (tcg_insts tcg_env, tcg_inst_env tcg_env) (instEnvElts $ md_insts details) - -- This is a HACK to prevent calculateAvails from including imp_mod - -- in the listing. We don't want it because a module is NOT + -- Use mi_deps directly rather than calculateAvails. + -- 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 - other_home_units = hsc_all_home_unit_ids hsc_env - avails = plusImportAvails (tcg_imports tcg_env) $ - calculateAvails home_unit other_home_units iface' False NotBoot ImportedBySystem + avails = tcg_imports tcg_env + deps = mi_deps iface + avails_with_trans = addTransitiveDepInfo avails deps + return tcg_env { tcg_inst_env = inst_env, tcg_insts = insts, - tcg_imports = avails, + tcg_imports = avails_with_trans, tcg_merged = if outer_mod == mi_module iface -- Don't add ourselves! @@ -912,6 +910,20 @@ mergeSignatures return tcg_env +-- | Add on the necessary transitive information from the merged signature to +-- the 'ImportAvails' of the result of merging. This propagates the orphan instances +-- which were in the transitive closure of the signature through the merge. +addTransitiveDepInfo :: ImportAvails -- ^ From the signature resulting from the merge + -> Dependencies -- ^ From the original signature + -> ImportAvails +addTransitiveDepInfo avails deps = + -- Avails for the merged in signature + -- Add on transitive information from the signature but nothing else.. + -- because we do not "import" the signature. + avails { imp_orphs = imp_orphs avails ++ dep_orphs deps + , imp_finsts = imp_finsts avails ++ dep_finsts deps + , imp_sig_mods = imp_sig_mods avails ++ dep_sig_mods deps } + -- | Top-level driver for signature instantiation (run when compiling -- an @hsig@ file.) tcRnInstantiateSignature :: ===================================== testsuite/tests/backpack/should_fail/T19244a.stderr ===================================== @@ -13,7 +13,17 @@ Instantiating user[Map=ordmap:Map] [1 of 2] Compiling Map[sig] ( user/Map.hsig, T19244a.out/user/user-GzloW2NeDdA2M0V8qzN4g2/Map.o ) -T19244a.bkp:9:9: error: +T19244a.bkp:22:9: error: + • Type constructor ‘Key’ has conflicting definitions in the module + and its hsig file + Main module: type Key :: * -> Constraint + type Key = GHC.Classes.Ord :: * -> Constraint + Hsig file: type Key :: forall {k}. k -> Constraint + class Key k1 + The types have different kinds + • while checking that ordmap:Map implements signature Map in user[Map=ordmap:Map] + +: error: • Type constructor ‘Map’ has conflicting definitions in the module and its hsig file Main module: type role Map nominal representational @@ -31,16 +41,6 @@ T19244a.bkp:9:9: error: The types have different kinds • while checking that ordmap:Map implements signature Map in user[Map=ordmap:Map] -T19244a.bkp:22:9: error: - • Type constructor ‘Key’ has conflicting definitions in the module - and its hsig file - Main module: type Key :: * -> Constraint - type Key = GHC.Classes.Ord :: * -> Constraint - Hsig file: type Key :: forall {k}. k -> Constraint - class Key k1 - The types have different kinds - • while checking that ordmap:Map implements signature Map in user[Map=ordmap:Map] - : error: • Identifier ‘lookup’ has conflicting definitions in the module and its hsig file ===================================== testsuite/tests/determinism/determ024/A.hs ===================================== @@ -0,0 +1,6 @@ +module A +( isExtensionOf +, stripExtension +) where + +import System.FilePath.Posix ===================================== testsuite/tests/determinism/determ024/B.hs ===================================== @@ -0,0 +1,7 @@ +module B +( isExtensionOf +, stripExtension +) where + +import System.FilePath + ===================================== testsuite/tests/determinism/determ024/Makefile ===================================== @@ -0,0 +1,11 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +determ024: + $(RM) A.hi A.o B.hi B.o + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 B.hs + '$(TEST_HC)' --show-iface B.hi > B_clean_iface + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 A.hs B.hs -fforce-recomp + '$(TEST_HC)' --show-iface B.hi > B_dirty_iface + diff B_clean_iface B_dirty_iface ===================================== testsuite/tests/determinism/determ024/all.T ===================================== @@ -0,0 +1 @@ +test('determ024', [extra_files(['A.hs', 'B.hs'])], makefile_test, ['determ024']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2f3277fda3715491eef8be80498ef7befc53480a...ee599c52b4e3cbf449e3348f2e24d8624defdb07 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2f3277fda3715491eef8be80498ef7befc53480a...ee599c52b4e3cbf449e3348f2e24d8624defdb07 You're receiving 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 Dec 8 12:12:18 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 08 Dec 2022 07:12:18 -0500 Subject: [Git][ghc/ghc][wip/andreask/inlineable-threshold] 6 commits: Hadrian: fix ghcDebugAssertions off-by-one error Message-ID: <6391d4a2f3f53_224fca6068044816c@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/inlineable-threshold at Glasgow Haskell Compiler / GHC Commits: cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - afef9b0e by Andreas Klebinger at 2022-12-08T13:08:30+01:00 Make INLINEABLE guidance based on optimized form. We know that if inlined these will optimize to something more similar to their optimized rhs than to the unoptimized unfolding. So make inlining decisions based on the optimized rhs instead of the unoptimized unfolding. - - - - - 17 changed files: - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - + compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/IfaceToCore.hs - + compiler/GHC/Linker/Config.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/SysTools/Tasks.hs - compiler/ghc.cabal.in - hadrian/doc/user-settings.md - hadrian/src/Flavour/Type.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Flavours/Development.hs - hadrian/src/Settings/Packages.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -4198,7 +4198,7 @@ simplLetUnfolding :: SimplEnv -> Unfolding -> SimplM Unfolding simplLetUnfolding env bind_cxt id new_rhs rhs_ty arity unf | isStableUnfolding unf - = simplStableUnfolding env bind_cxt id rhs_ty arity unf + = simplStableUnfolding env bind_cxt id rhs_ty arity unf new_rhs | isExitJoinId id = return noUnfolding -- See Note [Do not inline exit join points] in GHC.Core.Opt.Exitify | otherwise @@ -4230,9 +4230,10 @@ simplStableUnfolding :: SimplEnv -> BindContext -> OutType -> ArityType -- Used to eta expand, but only for non-join-points -> Unfolding + -> CoreExpr ->SimplM Unfolding -- Note [Setting the new unfolding] -simplStableUnfolding env bind_cxt id rhs_ty id_arity unf +simplStableUnfolding env bind_cxt id rhs_ty id_arity unf opt_rhs = case unf of NoUnfolding -> return unf BootUnfolding -> return unf @@ -4243,38 +4244,57 @@ simplStableUnfolding env bind_cxt id rhs_ty id_arity unf ; args' <- mapM (simplExpr env') args ; return (mkDFunUnfolding bndrs' con args') } + CoreUnfolding { uf_tmpl = expr, uf_src = src, uf_guidance = guide } | isStableSource src - -> do { expr' <- case bind_cxt of + -> do { unf_expr' <- case bind_cxt of BC_Join _ cont -> -- Binder is a join point -- See Note [Rules and unfolding for join points] simplJoinRhs unf_env id expr cont BC_Let _ is_rec -> -- Binder is not a join point do { let cont = mkRhsStop rhs_ty is_rec topDmd -- mkRhsStop: switch off eta-expansion at the top level - ; expr' <- simplExprC unf_env expr cont - ; return (eta_expand expr') } + ; unf_expr' <- simplExprC unf_env expr cont + ; return (eta_expand unf_expr') } ; case guide of + -- If we ever considered it ok to inline the stable expression keep + -- it that way. UnfWhen { ug_boring_ok = boring_ok } -- Happens for INLINE things -- Really important to force new_boring_ok since otherwise -- `ug_boring_ok` is a thunk chain of -- inlineBoringExprOk expr0 || inlineBoringExprOk expr1 || ... -- See #20134 - -> let !new_boring_ok = boring_ok || inlineBoringOk expr' + -> let !new_boring_ok = boring_ok || inlineBoringOk unf_expr' guide' = guide { ug_boring_ok = new_boring_ok } - -- Refresh the boring-ok flag, in case expr' + -- Refresh the boring-ok flag, in case unf_expr' -- has got small. This happens, notably in the inlinings -- for dfuns for single-method classes; see -- Note [Single-method classes] in GHC.Tc.TyCl.Instance. -- A test case is #4138 -- But retain a previous boring_ok of True; e.g. see -- the way it is set in calcUnfoldingGuidanceWithArity - in return (mkCoreUnfolding src is_top_lvl expr' guide') + in return (mkCoreUnfolding src is_top_lvl unf_expr' guide') -- See Note [Top-level flag on inline rules] in GHC.Core.Unfold - - _other -- Happens for INLINABLE things - -> mkLetUnfolding uf_opts top_lvl src id expr' } + -- The unoptimized unfolding might be too big to inline. Calculate guidance + -- based on the size of the optimized core. After all this is what the unfolding + -- will optimize to eventually! + _other -> do + let rhs_guide = calcUnfoldingGuidance uf_opts (is_top_lvl && is_bottoming) src opt_rhs + return (mkCoreUnfolding src is_top_lvl unf_expr' rhs_guide) + + -- return $ CoreUnfolding { uf_tmpl = unf_expr', uf_src = src, uf_guidance = rhs_guide } + } + + -- UnfIfGoodArgs {ug_args=_ug_args, ug_size=_ug_size, ug_res=_ug_res} + -- -- Happens for INLINEABLE things + -- -> do fake_unfolding <- mkLetUnfolding uf_opts top_lvl src id opt_rhs + -- case fake_unfolding of + -- CoreUnfolding { uf_guidance = new_guideance } + -- -> return $ fake_unfolding { uf_tmpl = unf_expr' } + -- _ -> mkLetUnfolding uf_opts top_lvl src id unf_expr' + -- _other -- Happens for INLINABLE things too big to ever inline + -- -> mkLetUnfolding uf_opts top_lvl src id unf_expr' } -- If the guidance is UnfIfGoodArgs, this is an INLINABLE -- unfolding, and we need to make sure the guidance is kept up -- to date with respect to any changes in the unfolding. @@ -4286,6 +4306,7 @@ simplStableUnfolding env bind_cxt id rhs_ty id_arity unf -- is small and easy to compute so might as well force it. top_lvl = bindContextLevel bind_cxt !is_top_lvl = isTopLevel top_lvl + is_bottoming = isDeadEndId id act = idInlineActivation id unf_env = updMode (updModeForStableUnfoldings act) env -- See Note [Simplifying inside stable unfoldings] in GHC.Core.Opt.Simplify.Utils ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -229,12 +229,13 @@ inlineBoringOk e calcUnfoldingGuidance :: UnfoldingOpts -> Bool -- Definitely a top-level, bottoming binding + -> UnfoldingSource -- Tells us if this is a stable unfolding -> CoreExpr -- Expression to look at -> UnfoldingGuidance -calcUnfoldingGuidance opts is_top_bottoming (Tick t expr) +calcUnfoldingGuidance opts is_top_bottoming src (Tick t expr) | not (tickishIsCode t) -- non-code ticks don't matter for unfolding - = calcUnfoldingGuidance opts is_top_bottoming expr -calcUnfoldingGuidance opts is_top_bottoming expr + = calcUnfoldingGuidance opts is_top_bottoming src expr +calcUnfoldingGuidance opts is_top_bottoming src expr = case sizeExpr opts bOMB_OUT_SIZE val_bndrs body of TooBig -> UnfNever SizeIs size cased_bndrs scrut_discount @@ -253,8 +254,8 @@ calcUnfoldingGuidance opts is_top_bottoming expr where (bndrs, body) = collectBinders expr + -- Bomb out if size gets bigger than this bOMB_OUT_SIZE = unfoldingCreationThreshold opts - -- Bomb out if size gets bigger than this val_bndrs = filter isId bndrs n_val_bndrs = length val_bndrs ===================================== compiler/GHC/Core/Unfold/Make.hs ===================================== @@ -107,7 +107,7 @@ mkWorkerUnfolding opts work_fn = mkCoreUnfolding src top_lvl new_tmpl guidance where new_tmpl = simpleOptExpr opts (work_fn tmpl) - guidance = calcUnfoldingGuidance (so_uf_opts opts) False new_tmpl + guidance = calcUnfoldingGuidance (so_uf_opts opts) False src new_tmpl mkWorkerUnfolding _ _ _ = noUnfolding @@ -317,7 +317,7 @@ mkUnfolding opts src top_lvl is_bottoming expr = mkCoreUnfolding src top_lvl expr guidance where is_top_bottoming = top_lvl && is_bottoming - guidance = calcUnfoldingGuidance opts is_top_bottoming expr + guidance = calcUnfoldingGuidance opts is_top_bottoming src expr -- NB: *not* (calcUnfoldingGuidance (occurAnalyseExpr expr))! -- See Note [Calculate unfolding guidance on the non-occ-anal'd expression] ===================================== compiler/GHC/Driver/Config/Linker.hs ===================================== @@ -0,0 +1,13 @@ +module GHC.Driver.Config.Linker + ( initFrameworkOpts + ) where + +import GHC.Linker.Config + +import GHC.Driver.Session + +initFrameworkOpts :: DynFlags -> FrameworkOpts +initFrameworkOpts dflags = FrameworkOpts + { foFrameworkPaths = frameworkPaths dflags + , foCmdlineFrameworks = cmdlineFrameworks dflags + } ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -130,7 +130,7 @@ module GHC.Driver.Session ( versionedAppDir, versionedFilePath, extraGccViaCFlags, globalPackageDatabasePath, pgm_L, pgm_P, pgm_F, pgm_c, pgm_cxx, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, - pgm_windres, pgm_ar, pgm_otool, pgm_install_name_tool, + pgm_windres, pgm_ar, 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, @@ -833,10 +833,6 @@ 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]) ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1781,7 +1781,7 @@ tcUnfolding toplvl name _ info (IfCoreUnfold src if_guidance if_expr) ; expr <- tcUnfoldingRhs (isCompulsorySource src) toplvl name if_expr ; let guidance = case if_guidance of IfWhen arity unsat_ok boring_ok -> UnfWhen arity unsat_ok boring_ok - IfNoGuidance -> calcUnfoldingGuidance uf_opts is_top_bottoming expr + IfNoGuidance -> calcUnfoldingGuidance uf_opts is_top_bottoming src expr ; return $ mkCoreUnfolding src True expr guidance } where -- Strictness should occur before unfolding! ===================================== compiler/GHC/Linker/Config.hs ===================================== @@ -0,0 +1,13 @@ +-- | Linker configuration + +module GHC.Linker.Config + ( FrameworkOpts(..) + ) where + +import GHC.Prelude + +-- used on darwin only +data FrameworkOpts = FrameworkOpts + { foFrameworkPaths :: [String] + , foCmdlineFrameworks :: [String] + } ===================================== compiler/GHC/Linker/Dynamic.hs ===================================== @@ -12,6 +12,7 @@ import GHC.Prelude import GHC.Platform import GHC.Platform.Ways +import GHC.Driver.Config.Linker import GHC.Driver.Session import GHC.Unit.Env @@ -23,6 +24,7 @@ import GHC.SysTools.Tasks import GHC.Utils.Logger import GHC.Utils.TmpFs +import Control.Monad (when) import System.FilePath linkDynLib :: Logger -> TmpFs -> DynFlags -> UnitEnv -> [String] -> [UnitId] -> IO () @@ -94,7 +96,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- frameworks pkg_framework_opts <- getUnitFrameworkOpts unit_env (map unitId pkgs) - let framework_opts = getFrameworkOpts dflags platform + let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform case os of OSMinGW32 -> do @@ -193,7 +195,9 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- See Note [Dynamic linking on macOS] ++ [ Option "-Wl,-dead_strip_dylibs", Option "-Wl,-headerpad,8000" ] ) - runInjectRPaths logger dflags pkg_lib_paths output_fn + -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004 + when (gopt Opt_RPath dflags) $ + runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn _ -> do ------------------------------------------------------------------- -- Making a DSO ===================================== compiler/GHC/Linker/MacOS.hs ===================================== @@ -9,12 +9,15 @@ where import GHC.Prelude import GHC.Platform +import GHC.Linker.Config + import GHC.Driver.Session import GHC.Unit.Types import GHC.Unit.State import GHC.Unit.Env +import GHC.Settings import GHC.SysTools.Tasks import GHC.Runtime.Interpreter @@ -46,15 +49,13 @@ import Text.ParserCombinators.ReadP as Parser -- dynamic library through @-add_rpath at . -- -- See Note [Dynamic linking on macOS] -runInjectRPaths :: Logger -> DynFlags -> [FilePath] -> FilePath -> IO () --- Make sure to honour -fno-use-rpaths if set on darwin as well see #20004 -runInjectRPaths _ dflags _ _ | not (gopt Opt_RPath dflags) = return () -runInjectRPaths logger dflags lib_paths dylib = do - info <- lines <$> askOtool logger dflags Nothing [Option "-L", Option dylib] +runInjectRPaths :: Logger -> ToolSettings -> [FilePath] -> FilePath -> IO () +runInjectRPaths logger toolSettings lib_paths dylib = do + info <- lines <$> askOtool logger toolSettings 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 <- lines <$> askOtool logger dflags Nothing [Option "-l", Option dylib] + info <- lines <$> askOtool logger toolSettings Nothing [Option "-l", Option dylib] let paths = mapMaybe get_rpath info lib_paths' = [ p | p <- lib_paths, not (p `elem` paths) ] -- only find those rpaths, that aren't already in the library. @@ -62,7 +63,7 @@ runInjectRPaths logger dflags lib_paths dylib = do -- inject the rpaths case rpaths of [] -> return () - _ -> runInstallNameTool logger dflags $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] + _ -> runInstallNameTool logger toolSettings $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] get_rpath :: String -> Maybe FilePath get_rpath l = case readP_to_S rpath_parser l of @@ -96,15 +97,15 @@ getUnitFrameworkOpts unit_env dep_packages | otherwise = return [] -getFrameworkOpts :: DynFlags -> Platform -> [String] -getFrameworkOpts dflags platform +getFrameworkOpts :: FrameworkOpts -> Platform -> [String] +getFrameworkOpts fwOpts platform | platformUsesFrameworks platform = framework_path_opts ++ framework_opts | otherwise = [] where - framework_paths = frameworkPaths dflags + framework_paths = foFrameworkPaths fwOpts framework_path_opts = map ("-F" ++) framework_paths - frameworks = cmdlineFrameworks dflags + frameworks = foCmdlineFrameworks fwOpts -- reverse because they're added in reverse order from the cmd line: framework_opts = concat [ ["-framework", fw] | fw <- reverse frameworks ] ===================================== compiler/GHC/Linker/Static.hs ===================================== @@ -29,6 +29,7 @@ import GHC.Linker.ExtraObj import GHC.Linker.Windows import GHC.Linker.Static.Utils +import GHC.Driver.Config.Linker import GHC.Driver.Session import System.FilePath @@ -171,7 +172,7 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do -- frameworks pkg_framework_opts <- getUnitFrameworkOpts unit_env dep_units - let framework_opts = getFrameworkOpts dflags platform + let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform -- probably _stub.o files let extra_ld_inputs = ldInputs dflags @@ -183,7 +184,9 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do let link dflags args | platformOS platform == OSDarwin = do GHC.SysTools.runLink logger tmpfs dflags args - GHC.Linker.MacOS.runInjectRPaths logger dflags pkg_lib_paths output_fn + -- Make sure to honour -fno-use-rpaths if set on darwin as well; see #20004 + when (gopt Opt_RPath dflags) $ + GHC.Linker.MacOS.runInjectRPaths logger (toolSettings dflags) pkg_lib_paths output_fn | otherwise = GHC.SysTools.runLink logger tmpfs dflags args ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -16,6 +16,8 @@ import GHC.IO (catchException) import GHC.CmmToLlvm.Config (LlvmVersion, llvmVersionStr, supportedLlvmVersionUpperBound, parseLlvmVersion, supportedLlvmVersionLowerBound) +import GHC.Settings + import GHC.SysTools.Process import GHC.SysTools.Info @@ -362,15 +364,15 @@ runAr logger dflags cwd args = traceSystoolCommand logger "ar" $ do let ar = pgm_ar dflags runSomethingFiltered logger id "Ar" ar args cwd Nothing -askOtool :: Logger -> DynFlags -> Maybe FilePath -> [Option] -> IO String -askOtool logger dflags mb_cwd args = do - let otool = pgm_otool dflags +askOtool :: Logger -> ToolSettings -> Maybe FilePath -> [Option] -> IO String +askOtool logger toolSettings mb_cwd args = do + let otool = toolSettings_pgm_otool toolSettings runSomethingWith logger "otool" otool args $ \real_args -> readCreateProcessWithExitCode' (proc otool real_args){ cwd = mb_cwd } -runInstallNameTool :: Logger -> DynFlags -> [Option] -> IO () -runInstallNameTool logger dflags args = do - let tool = pgm_install_name_tool dflags +runInstallNameTool :: Logger -> ToolSettings -> [Option] -> IO () +runInstallNameTool logger toolSettings args = do + let tool = toolSettings_pgm_install_name_tool toolSettings runSomethingFiltered logger id "Install Name Tool" tool args Nothing Nothing runRanlib :: Logger -> DynFlags -> [Option] -> IO () ===================================== compiler/ghc.cabal.in ===================================== @@ -421,6 +421,7 @@ Library GHC.Driver.Config.HsToCore GHC.Driver.Config.HsToCore.Ticks GHC.Driver.Config.HsToCore.Usage + GHC.Driver.Config.Linker GHC.Driver.Config.Logger GHC.Driver.Config.Parser GHC.Driver.Config.Stg.Debug @@ -529,6 +530,7 @@ Library GHC.JS.Syntax GHC.JS.Transform GHC.Linker + GHC.Linker.Config GHC.Linker.Dynamic GHC.Linker.ExtraObj GHC.Linker.Loader ===================================== hadrian/doc/user-settings.md ===================================== @@ -25,7 +25,7 @@ data Flavour = Flavour { packages :: Stage -> Action [Package], -- | Bignum backend: 'native', 'gmp', 'ffi', etc. bignumBackend :: String, - -- | Check bignum backend against native + -- | Check selected bignum backend against native backend bignumCheck :: Bool, -- | Build libraries these ways. libraryWays :: Ways, @@ -34,15 +34,20 @@ data Flavour = Flavour { -- | Build dynamic GHC programs. dynamicGhcPrograms :: Action Bool, -- | Enable GHCi debugger. - ghciWithDebugger :: Bool, + ghciWithDebugger :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build profiled GHC. - ghcProfiled :: Bool, + ghcProfiled :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build GHC with the debug RTS. - ghcDebugged :: Bool, + ghcDebugged :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build GHC with debug assertions (-DDEBUG). - ghcDebugAssertions :: Bool, + ghcDebugAssertions :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build the GHC executable against the threaded runtime system. - ghcThreaded :: Bool, + ghcThreaded :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Whether to build docs and which ones -- (haddocks, user manual, haddock manual) ghcDocs :: Action DocTargets } ===================================== hadrian/src/Flavour/Type.hs ===================================== @@ -18,9 +18,9 @@ data Flavour = Flavour { args :: Args, -- | Build these packages. packages :: Stage -> Action [Package], - -- | 'native', 'gmp', 'ffi'. + -- | Bignum backend: 'native', 'gmp', 'ffi', etc. bignumBackend :: String, - -- | Check selected backend against native backend + -- | Check selected bignum backend against native backend bignumCheck :: Bool, -- | Build libraries these ways. libraryWays :: Ways, @@ -29,15 +29,20 @@ data Flavour = Flavour { -- | Build dynamic GHC programs. dynamicGhcPrograms :: Action Bool, -- | Enable GHCi debugger. - ghciWithDebugger :: Stage -> Bool, + ghciWithDebugger :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build profiled GHC. - ghcProfiled :: Stage -> Bool, + ghcProfiled :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build GHC with the debug RTS. - ghcDebugged :: Stage -> Bool, - -- | Build GHC with debug assertions. - ghcDebugAssertions :: Stage -> Bool, + ghcDebugged :: Stage -- ^ stage of the /built/ compiler + -> Bool, + -- | Build GHC with debug assertions (-DDEBUG). + ghcDebugAssertions :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Build the GHC executable against the threaded runtime system. - ghcThreaded :: Stage -> Bool, + ghcThreaded :: Stage -- ^ stage of the /built/ compiler + -> Bool, -- | Whether to build docs and which ones -- (haddocks, user manual, haddock manual) ghcDocs :: Action DocTargets } ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -101,7 +101,7 @@ inTreeCompilerArgs stg = do unregisterised <- flag GhcUnregisterised tables_next_to_code <- flag TablesNextToCode withSMP <- targetSupportsSMP - debugAssertions <- ($ stg) . ghcDebugAssertions <$> flavour + debugAssertions <- ($ succStage stg) . ghcDebugAssertions <$> flavour profiled <- ghcProfiled <$> flavour <*> pure stg os <- setting HostOs ===================================== hadrian/src/Settings/Flavours/Development.hs ===================================== @@ -16,12 +16,12 @@ developmentFlavour ghcStage = defaultFlavour , libraryWays = pure $ Set.fromList [vanilla] , rtsWays = Set.fromList <$> mconcat [pure [vanilla, debug], targetSupportsThreadedRts ? pure [threaded, threadedDebug]] , dynamicGhcPrograms = return False - , ghcDebugAssertions = (>= Stage2) } + , ghcDebugAssertions = (== ghcStage) } where stageString Stage2 = "2" stageString Stage1 = "1" stageString Stage3 = "3" - stageString s = error ("developmentFlavour not support for " ++ show s) + stageString s = error ("developmentFlavour not supported for " ++ show s) developmentArgs :: Stage -> Args developmentArgs ghcStage = do ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -13,7 +13,6 @@ packageArgs :: Args packageArgs = do stage <- getStage path <- getBuildPath - root <- getBuildRoot compilerPath <- expr $ buildPath (vanillaContext stage compiler) let -- Do not bind the result to a Boolean: this forces the configure rule @@ -29,7 +28,10 @@ packageArgs = do cursesLibraryDir <- getSetting CursesLibDir ffiIncludeDir <- getSetting FfiIncludeDir ffiLibraryDir <- getSetting FfiLibDir - debugAssertions <- ghcDebugAssertions <$> expr flavour + debugAssertions <- ( `ghcDebugAssertions` (succStage stage) ) <$> expr flavour + -- NB: in this function, "stage" is the stage of the compiler we are + -- using to build, but ghcDebugAssertions wants the stage of the compiler + -- we are building, which we get using succStage. mconcat --------------------------------- base --------------------------------- @@ -52,7 +54,7 @@ packageArgs = do [ builder Alex ? arg "--latin1" , builder (Ghc CompileHs) ? mconcat - [ debugAssertions stage ? arg "-DDEBUG" + [ debugAssertions ? arg "-DDEBUG" , inputs ["**/GHC.hs", "**/GHC/Driver/Make.hs"] ? arg "-fprof-auto" , input "**/Parser.hs" ? @@ -83,7 +85,7 @@ packageArgs = do , package ghc ? mconcat [ builder Ghc ? mconcat [ arg ("-I" ++ compilerPath) - , debugAssertions stage ? arg "-DDEBUG" ] + , debugAssertions ? arg "-DDEBUG" ] , builder (Cabal Flags) ? mconcat [ andM [expr ghcWithInterpreter, notStage0] `cabalFlag` "internal-interpreter" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e64712c0f0069dbd70eab760232d981af2c4a9e3...afef9b0e3123041b156e785291682fc3a5c4a04e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e64712c0f0069dbd70eab760232d981af2c4a9e3...afef9b0e3123041b156e785291682fc3a5c4a04e You're receiving 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 Dec 8 12:35:15 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 08 Dec 2022 07:35:15 -0500 Subject: [Git][ghc/ghc][wip/various-hadrian-fixes] packaging: Build perf builds with -split-sections Message-ID: <6391da03b0373_224fca219996404526ad@gitlab.mail> Matthew Pickering pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC Commits: fba5c716 by Matthew Pickering at 2022-12-08T12:35:04+00:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 5 changed files: - .gitlab-ci.yml - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - hadrian/doc/flavours.md - hadrian/src/Settings/Flavours/Performance.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -423,7 +423,7 @@ doc-tarball: optional: true - job: nightly-x86_64-windows-validate optional: true - - job: release-x86_64-windows-release + - job: release-x86_64-windows-release+no_split_sections optional: true tags: @@ -447,7 +447,7 @@ doc-tarball: || mv "ghc-x86_64-linux-deb10-release.tar.xz" "$LINUX_BINDIST" \ || true mv "ghc-x86_64-windows-validate.tar.xz" "$WINDOWS_BINDIST" \ - || mv "ghc-x86_64-windows-release.tar.xz" "$WINDOWS_BINDIST" \ + || mv "ghc-x86_64-windows-release+no_split_sections.tar.xz" "$WINDOWS_BINDIST" \ || true if [ ! -f "$LINUX_BINDIST" ]; then echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" ===================================== .gitlab/gen_ci.hs ===================================== @@ -130,6 +130,7 @@ data BuildConfig , fullyStatic :: Bool , tablesNextToCode :: Bool , threadSanitiser :: Bool + , noSplitSections :: Bool } -- Extra arguments to pass to ./configure due to the BuildConfig @@ -146,13 +147,14 @@ mkJobFlavour BuildConfig{..} = Flavour buildFlavour opts opts = [Llvm | llvmBootstrap] ++ [Dwarf | withDwarf] ++ [FullyStatic | fullyStatic] ++ - [ThreadSanitiser | threadSanitiser] + [ThreadSanitiser | threadSanitiser] ++ + [NoSplitSections | noSplitSections, buildFlavour == Release ] data Flavour = Flavour BaseFlavour [FlavourTrans] -data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser +data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser | NoSplitSections -data BaseFlavour = Release | Validate | SlowValidate +data BaseFlavour = Release | Validate | SlowValidate deriving Eq ----------------------------------------------------------------------------- -- Build Configs @@ -174,8 +176,12 @@ vanilla = BuildConfig , fullyStatic = False , tablesNextToCode = True , threadSanitiser = False + , noSplitSections = False } +splitSectionsBroken :: BuildConfig -> BuildConfig +splitSectionsBroken bc = bc { noSplitSections = True } + nativeInt :: BuildConfig nativeInt = vanilla { bignumBackend = Native } @@ -290,6 +296,7 @@ flavourString (Flavour base trans) = baseString base ++ concatMap (("+" ++) . fl flavourString Dwarf = "debug_info" flavourString FullyStatic = "fully_static" flavourString ThreadSanitiser = "thread_sanitizer" + flavourString NoSplitSections = "no_split_sections" -- The path to the docker image (just for linux builders) dockerImage :: Arch -> Opsys -> Maybe String @@ -792,22 +799,22 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , disableValidate (standardBuilds Amd64 (Linux Debian11)) -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 -- not being at EOL until April 2023 and they still need tinfo5. - , disableValidate (standardBuilds Amd64 (Linux Debian9)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) (splitSectionsBroken vanilla)) , disableValidate (standardBuilds Amd64 (Linux Ubuntu2004)) - , disableValidate (standardBuilds Amd64 (Linux Centos7)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Centos7) (splitSectionsBroken vanilla)) -- Fedora33 job is always built with perf so there's one job in the normal -- validate pipeline which is built with perf. , (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig) -- This job is only for generating head.hackage docs , hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig)) , disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf) - , fastCI (standardBuilds Amd64 Windows) - , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt) + , fastCI (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla)) + , disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt)) , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , standardBuilds I386 (Linux Debian9) + , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) , standardBuildsWithConfig Amd64 (Linux Alpine) static , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) ===================================== .gitlab/jobs.yaml ===================================== @@ -1869,7 +1869,7 @@ "XZ_OPT": "-9" } }, - "release-i386-linux-deb9-release": { + "release-i386-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1879,7 +1879,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-i386-linux-deb9-release.tar.xz", + "ghc-i386-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -1921,11 +1921,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-i386-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "i386-linux-deb9-release", + "TEST_ENV": "i386-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2183,7 +2183,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-linux-centos7-release": { + "release-x86_64-linux-centos7-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2193,7 +2193,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-centos7-release.tar.xz", + "ghc-x86_64-linux-centos7-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2235,12 +2235,12 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "x86_64-linux-centos7-release", + "TEST_ENV": "x86_64-linux-centos7-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2424,7 +2424,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-linux-deb9-release": { + "release-x86_64-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2434,7 +2434,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-deb9-release.tar.xz", + "ghc-x86_64-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2476,11 +2476,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "x86_64-linux-deb9-release", + "TEST_ENV": "x86_64-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2731,7 +2731,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-windows-int_native-release": { + "release-x86_64-windows-int_native-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2740,7 +2740,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-int_native-release.tar.xz", + "ghc-x86_64-windows-int_native-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2778,8 +2778,8 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2787,11 +2787,11 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-int_native-release", + "TEST_ENV": "x86_64-windows-int_native-release+no_split_sections", "XZ_OPT": "-9" } }, - "release-x86_64-windows-release": { + "release-x86_64-windows-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2800,7 +2800,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-release.tar.xz", + "ghc-x86_64-windows-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2838,8 +2838,8 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-windows-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2847,7 +2847,7 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-release", + "TEST_ENV": "x86_64-windows-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== hadrian/doc/flavours.md ===================================== @@ -15,6 +15,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
FlavourSplit Sections Extra arguments
default
+
-O
-H32m
-O2
-H32m
quick + -O0
-H64m
-O0
-H64m
quick-validate + -O0
-H64m
-Werror
-O0
-H64m
-Werror
quick-debug + -O0
-H64m
-O0
-H64m
quickest + -O0
-H64m
-O0
-H64m
perf + Yes (on supported platforms) -O
-H64m
-O
-H64m
bench + -O
-H64m
-O
-H64m
devel1 + -O
-H64m
-O
-H64m
devel2 + -O
-H64m
-O
-H64m
validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
slow-validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
static + -O
-H64m
-fPIC -static
-O
-H64m
-fPIC -static
+ @@ -35,6 +36,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -46,6 +48,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -57,6 +60,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -68,6 +72,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -79,6 +84,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -90,6 +96,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -112,6 +119,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -123,6 +131,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -134,6 +143,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -145,6 +155,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -156,6 +167,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -167,6 +179,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH ===================================== hadrian/src/Settings/Flavours/Performance.hs ===================================== @@ -6,7 +6,7 @@ import {-# SOURCE #-} Settings.Default -- Please update doc/flavours.md when changing this file. performanceFlavour :: Flavour -performanceFlavour = defaultFlavour +performanceFlavour = splitSections $ defaultFlavour { name = "perf" , args = defaultBuilderArgs <> performanceArgs <> defaultPackageArgs } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fba5c716eca399c1495dea4d405a03e6f33293ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fba5c716eca399c1495dea4d405a03e6f33293ec You're receiving 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 Dec 8 13:30:40 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 08:30:40 -0500 Subject: [Git][ghc/ghc][master] Fix bounds-checking buglet in Data.Array.Byte Message-ID: <6391e700512be_224fca526d4466855@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 1 changed file: - libraries/base/Data/Array/Byte.hs Changes: ===================================== libraries/base/Data/Array/Byte.hs ===================================== @@ -101,18 +101,20 @@ byteArrayToList arr = go 0 -- | Create a 'ByteArray' from a list of a known length. If the length -- of the list does not match the given length, this throws an exception. byteArrayFromListN :: Int -> [Word8] -> ByteArray -byteArrayFromListN n ys = runST $ do +byteArrayFromListN n ys + | n >= 0 = runST $ do marr <- newByteArray n let go !ix [] = if ix == n then return () - else error $ "Data.Array.Byte.byteArrayFromListN: list length less than specified size" + else errorWithoutStackTrace $ "Data.Array.Byte.byteArrayFromListN: list length less than specified size" go !ix (x : xs) = if ix < n then do writeByteArray marr ix x go (ix + 1) xs - else error $ "Data.Array.Byte.byteArrayFromListN: list length greater than specified size" + else errorWithoutStackTrace $ "Data.Array.Byte.byteArrayFromListN: list length greater than specified size" go 0 ys unsafeFreezeByteArray marr + | otherwise = errorWithoutStackTrace "Data.Array.Byte.ByteArrayFromListN: specified size is negative" -- | Copy a slice of an immutable byte array to a mutable byte array. -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e902d771197fd93488938b5eacb1ad6f23d408b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e902d771197fd93488938b5eacb1ad6f23d408b7 You're receiving 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 Dec 8 13:31:40 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 08:31:40 -0500 Subject: [Git][ghc/ghc][master] 2 commits: Remove copy-pasted definitions of `graphFromEdgedVertices*` Message-ID: <6391e73c2c96e_224fca1d7887744721ed@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 1 changed file: - compiler/GHC/Data/Graph/Directed.hs Changes: ===================================== compiler/GHC/Data/Graph/Directed.hs ===================================== @@ -9,11 +9,11 @@ module GHC.Data.Graph.Directed ( Graph, graphFromEdgedVerticesOrd, graphFromEdgedVerticesUniq, graphFromVerticesAndAdjacency, - SCC(..), Node(..), flattenSCC, flattenSCCs, + SCC(..), Node(..), G.flattenSCC, G.flattenSCCs, stronglyConnCompG, topologicalSortG, verticesG, edgesG, hasVertexG, - reachableG, reachablesG, transposeG, allReachable, outgoingG, + reachableG, reachablesG, transposeG, allReachable, allReachableCyclic, outgoingG, emptyG, findCycle, @@ -58,7 +58,7 @@ import qualified Data.Map as Map import qualified Data.Set as Set import qualified Data.Graph as G -import Data.Graph hiding (Graph, Edge, transposeG, reachable) +import Data.Graph ( Vertex, Bounds, SCC(..) ) -- Used in the underlying representation import Data.Tree import GHC.Types.Unique import GHC.Types.Unique.FM @@ -291,19 +291,11 @@ We use the order of nodes to normalize the order of edges. -} stronglyConnCompG :: Graph node -> [SCC node] -stronglyConnCompG graph = decodeSccs graph forest - where forest = {-# SCC "Digraph.scc" #-} scc (gr_int_graph graph) - -decodeSccs :: Graph node -> Forest Vertex -> [SCC node] -decodeSccs Graph { gr_int_graph = graph, gr_vertex_to_node = vertex_fn } forest - = map decode forest - where - decode (Node v []) | mentions_itself v = CyclicSCC [vertex_fn v] - | otherwise = AcyclicSCC (vertex_fn v) - decode other = CyclicSCC (dec other []) - where dec (Node v ts) vs = vertex_fn v : foldr dec vs ts - mentions_itself v = v `elem` (graph ! v) +stronglyConnCompG graph = decodeSccs graph $ scc (gr_int_graph graph) +decodeSccs :: Graph node -> [SCC Vertex] -> [SCC node] +decodeSccs Graph { gr_vertex_to_node = vertex_fn } + = map (fmap vertex_fn) -- The following two versions are provided for backwards compatibility: -- See Note [Deterministic SCC] @@ -334,7 +326,7 @@ stronglyConnCompFromEdgedVerticesOrdR => [Node key payload] -> [SCC (Node key payload)] stronglyConnCompFromEdgedVerticesOrdR = - stronglyConnCompG . graphFromEdgedVertices reduceNodesIntoVerticesOrd + stronglyConnCompG . graphFromEdgedVerticesOrd -- The "R" interface is used when you expect to apply SCC to -- (some of) the result of SCC, so you don't want to lose the dependency info @@ -345,7 +337,7 @@ stronglyConnCompFromEdgedVerticesUniqR => [Node key payload] -> [SCC (Node key payload)] stronglyConnCompFromEdgedVerticesUniqR = - stronglyConnCompG . graphFromEdgedVertices reduceNodesIntoVerticesUniq + stronglyConnCompG . graphFromEdgedVerticesUniq {- ************************************************************************ @@ -357,7 +349,7 @@ stronglyConnCompFromEdgedVerticesUniqR = topologicalSortG :: Graph node -> [node] topologicalSortG graph = map (gr_vertex_to_node graph) result - where result = {-# SCC "Digraph.topSort" #-} topSort (gr_int_graph graph) + where result = {-# SCC "Digraph.topSort" #-} G.topSort (gr_int_graph graph) reachableG :: Graph node -> node -> [node] reachableG graph from = map (gr_vertex_to_node graph) result @@ -377,22 +369,31 @@ reachablesG graph froms = map (gr_vertex_to_node graph) result vs = [ v | Just v <- map (gr_node_to_vertex graph) froms ] -- | Efficiently construct a map which maps each key to it's set of transitive --- dependencies. +-- dependencies. Only works on acyclic input. allReachable :: Ord key => Graph node -> (node -> key) -> M.Map key (S.Set key) -allReachable (Graph g from _) conv = - M.fromList [(conv (from v), IS.foldr (\k vs -> conv (from k) `S.insert` vs) S.empty vs) - | (v, vs) <- IM.toList int_graph] +allReachable = all_reachable reachableGraph + +-- | Efficiently construct a map which maps each key to it's set of transitive +-- dependencies. Less efficient than @allReachable@, but works on cyclic input as well. +allReachableCyclic :: Ord key => Graph node -> (node -> key) -> M.Map key (S.Set key) +allReachableCyclic = all_reachable reachableGraphCyclic + +all_reachable :: Ord key => (IntGraph -> IM.IntMap IS.IntSet) -> Graph node -> (node -> key) -> M.Map key (S.Set key) +all_reachable int_reachables (Graph g from _) keyOf = + M.fromList [(k, IS.foldr (\v' vs -> keyOf (from v') `S.insert` vs) S.empty vs) + | (v, vs) <- IM.toList int_graph + , let k = keyOf (from v)] where - int_graph = reachableGraph g + int_graph = int_reachables g hasVertexG :: Graph node -> node -> Bool hasVertexG graph node = isJust $ gr_node_to_vertex graph node verticesG :: Graph node -> [node] -verticesG graph = map (gr_vertex_to_node graph) $ vertices (gr_int_graph graph) +verticesG graph = map (gr_vertex_to_node graph) $ G.vertices (gr_int_graph graph) edgesG :: Graph node -> [Edge node] -edgesG graph = map (\(v1, v2) -> Edge (v2n v1) (v2n v2)) $ edges (gr_int_graph graph) +edgesG graph = map (\(v1, v2) -> Edge (v2n v1) (v2n v2)) $ G.edges (gr_int_graph graph) where v2n = gr_vertex_to_node graph transposeG :: Graph node -> Graph node @@ -452,13 +453,63 @@ preorderF ts = concatMap flatten ts -- This generalizes reachable which was found in Data.Graph reachable :: IntGraph -> [Vertex] -> [Vertex] -reachable g vs = preorderF (dfs g vs) +reachable g vs = preorderF (G.dfs g vs) reachableGraph :: IntGraph -> IM.IntMap IS.IntSet reachableGraph g = res where do_one v = IS.unions (IS.fromList (g ! v) : mapMaybe (flip IM.lookup res) (g ! v)) - res = IM.fromList [(v, do_one v) | v <- vertices g] + res = IM.fromList [(v, do_one v) | v <- G.vertices g] + +scc :: IntGraph -> [SCC Vertex] +scc graph = map decode forest + where + forest = {-# SCC "Digraph.scc" #-} G.scc graph + + decode (Node v []) | mentions_itself v = CyclicSCC [v] + | otherwise = AcyclicSCC v + decode other = CyclicSCC (dec other []) + where dec (Node v ts) vs = v : foldr dec vs ts + mentions_itself v = v `elem` (graph ! v) + +reachableGraphCyclic :: IntGraph -> IM.IntMap IS.IntSet +reachableGraphCyclic g = foldl' add_one_comp mempty comps + where + neighboursOf v = g!v + + comps = scc g + + -- To avoid divergence on cyclic input, we build the result + -- strongly connected component by component, in topological + -- order. For each SCC, we know that: + -- + -- * All vertices in the component can reach all other vertices + -- in the component ("local" reachables) + -- + -- * Other reachable vertices ("remote" reachables) must come + -- from earlier components, either via direct neighbourhood, or + -- transitively from earlier reachability map + -- + -- This allows us to build the extension of the reachability map + -- directly, without any self-reference, thereby avoiding a loop. + add_one_comp :: IM.IntMap IS.IntSet -> SCC Vertex -> IM.IntMap IS.IntSet + add_one_comp earlier (AcyclicSCC v) = IM.insert v all_remotes earlier + where + earlier_neighbours = neighboursOf v + earlier_further = mapMaybe (flip IM.lookup earlier) earlier_neighbours + all_remotes = IS.unions (IS.fromList earlier_neighbours : earlier_further) + add_one_comp earlier (CyclicSCC vs) = IM.union (IM.fromList [(v, local v `IS.union` all_remotes) | v <- vs]) earlier + where + all_locals = IS.fromList vs + local v = IS.delete v all_locals + -- Arguably, for a cyclic SCC we should include each + -- vertex in its own reachable set. However, this could + -- lead to a lot of extra pain in client code to avoid + -- looping when traversing the reachability map. + all_neighbours = IS.fromList (concatMap neighboursOf vs) + earlier_neighbours = all_neighbours IS.\\ all_locals + earlier_further = mapMaybe (flip IM.lookup earlier) (IS.toList earlier_neighbours) + all_remotes = IS.unions (earlier_neighbours : earlier_further) {- ************************************************************************ @@ -565,4 +616,4 @@ graphFromVerticesAndAdjacency vertices edges = Graph graph vertex_node (key_vert key_vertex_pair (a, b) = (expectJust "graphFromVerticesAndAdjacency" $ key_vertex a, expectJust "graphFromVerticesAndAdjacency" $ key_vertex b) reduced_edges = map key_vertex_pair edges - graph = buildG bounds reduced_edges + graph = G.buildG bounds reduced_edges View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e902d771197fd93488938b5eacb1ad6f23d408b7...c5d8ed3ae14396733e240f6a146a0793f288b296 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e902d771197fd93488938b5eacb1ad6f23d408b7...c5d8ed3ae14396733e240f6a146a0793f288b296 You're receiving 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 Dec 8 13:32:06 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 08:32:06 -0500 Subject: [Git][ghc/ghc][master] Mark Type.Reflection.Unsafe as Unsafe Message-ID: <6391e7563824c_224fca526d4475775@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2 changed files: - libraries/base/Type/Reflection/Unsafe.hs - libraries/base/changelog.md Changes: ===================================== libraries/base/Type/Reflection/Unsafe.hs ===================================== @@ -12,7 +12,7 @@ -- type representations. -- ----------------------------------------------------------------------------- -{-# LANGUAGE PolyKinds, DataKinds, ScopedTypeVariables #-} +{-# LANGUAGE PolyKinds, DataKinds, ScopedTypeVariables, Unsafe #-} module Type.Reflection.Unsafe ( -- * Type representations ===================================== libraries/base/changelog.md ===================================== @@ -56,6 +56,7 @@ `malloc` for allocation. It avoids the O(n) overhead of maintaining a list of individually allocated pointers as well as freeing each one of them when freeing a `Pool`. (#14762) (#18338) + * `Type.Reflection.Unsafe` is now marked as unsafe. ## 4.17.0.0 *August 2022* View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/90cd53960f4e712197efc320b3aa104e95345a23 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/90cd53960f4e712197efc320b3aa104e95345a23 You're receiving 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 Dec 8 13:32:37 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 08:32:37 -0500 Subject: [Git][ghc/ghc][master] Truncate eventlog event for large payload (#20221) Message-ID: <6391e775ed182_224fcabe792c04794f4@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 1 changed file: - rts/eventlog/EventLog.c Changes: ===================================== rts/eventlog/EventLog.c ===================================== @@ -754,7 +754,17 @@ void postCapsetVecEvent (EventTypeNum tag, for (int i = 0; i < argc; i++) { // 1 + strlen to account for the trailing \0, used as separator - size += 1 + strlen(argv[i]); + int increment = 1 + strlen(argv[i]); + if (size + increment > EVENT_PAYLOAD_SIZE_MAX) { + errorBelch("Event size exceeds EVENT_PAYLOAD_SIZE_MAX, record only %" + FMT_Int " out of %" FMT_Int " args", + (long long) i, + (long long) argc); + argc = i; + break; + } else { + size += increment; + } } ACQUIRE_LOCK(&eventBufMutex); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2057c77d08cb8422857d182a3691f98dccd0c7d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2057c77d08cb8422857d182a3691f98dccd0c7d6 You're receiving 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 Dec 8 13:33:22 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 08:33:22 -0500 Subject: [Git][ghc/ghc][master] hadrian: don't add debug info to non-debug ways of rts Message-ID: <6391e7a294f77_224fca2595e17c483198@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 1 changed file: - hadrian/src/Settings/Packages.hs Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -315,7 +315,6 @@ rtsPackageArgs = package rts ? do -- provide non-inlined alternatives and hence needs the function to -- be inlined. See https://github.com/snowleopard/hadrian/issues/90. , arg "-O2" - , arg "-g" , arg "-Irts" , arg $ "-I" ++ path View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9ec76f61c880539114314fc3e4f96a4694f38ebe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9ec76f61c880539114314fc3e4f96a4694f38ebe You're receiving 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 Dec 8 13:33:54 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 08:33:54 -0500 Subject: [Git][ghc/ghc][master] Restore show (typeRep @[]) == "[]" Message-ID: <6391e7c290536_224fca1d7887744867f2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 3 changed files: - libraries/base/Data/Typeable/Internal.hs - testsuite/tests/typecheck/should_run/TestTypeableBinary.hs - testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout Changes: ===================================== libraries/base/Data/Typeable/Internal.hs ===================================== @@ -836,6 +836,8 @@ instance Show (TypeRep (a :: k)) where showTypeable :: Int -> TypeRep (a :: k) -> ShowS showTypeable _ TrType = showChar '*' showTypeable _ rep + | isListTyCon tc, [] <- tys = + showString "[]" | isListTyCon tc, [ty] <- tys = showChar '[' . shows ty . showChar ']' ===================================== testsuite/tests/typecheck/should_run/TestTypeableBinary.hs ===================================== @@ -35,3 +35,4 @@ main = do testRoundtrip (typeRep :: TypeRep 5) testRoundtrip (typeRep :: TypeRep "hello world") testRoundtrip (typeRep :: TypeRep ('Just 5)) + testRoundtrip (typeRep :: TypeRep []) ===================================== testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout ===================================== @@ -13,3 +13,4 @@ good: Int -> Int good: 5 good: "hello world" good: 'Just Natural 5 +good: [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7658cdd47198512b699492688f51fc8682d194cd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7658cdd47198512b699492688f51fc8682d194cd You're receiving 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 Dec 8 13:42:15 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Thu, 08 Dec 2022 08:42:15 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/22022-mark-T21336a-fragile Message-ID: <6391e9b7607f0_224fca2595e17c49071@gitlab.mail> Bryan R pushed new branch wip/22022-mark-T21336a-fragile at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/22022-mark-T21336a-fragile You're receiving 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 Dec 8 14:05:08 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 09:05:08 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 19 commits: Fix bounds-checking buglet in Data.Array.Byte Message-ID: <6391ef14d1278_224fca219996405040d6@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - f146282b by Gergő Érdi at 2022-12-08T09:04:34-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. - - - - - ce279a1e by lrzlin at 2022-12-08T09:04:37-05:00 Add initial support for LoongArch Architecture. - - - - - 76d6d170 by Bodigrim at 2022-12-08T09:04:42-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 1413ee34 by Bodigrim at 2022-12-08T09:04:42-05:00 Allow mtl-2.3 in hadrian - - - - - 25d5a05c by Bodigrim at 2022-12-08T09:04:42-05:00 Support mtl-2.3 in check-exact - - - - - 806992d5 by Bodigrim at 2022-12-08T09:04:42-05:00 Fix tests - - - - - 2d33c0f7 by Sebastian Graf at 2022-12-08T09:04:42-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - d3191735 by Matthew Pickering at 2022-12-08T09:04:43-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 7d0dc5e4 by Sebastian Graf at 2022-12-08T09:04:43-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 312801cb by John Ericson at 2022-12-08T09:04:44-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - 6ddb1fe7 by Krzysztof Gogolewski at 2022-12-08T09:04:44-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - b61f5645 by Bryan Richter at 2022-12-08T09:04:45-05:00 testsuite: Mark conc024 fragile on Windows - - - - - 30 changed files: - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Lit.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Platform.hs - + compiler/GHC/Platform/LoongArch64.hs - compiler/GHC/Platform/Regs.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Types/SourceText.hs - compiler/ghc.cabal.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a0a060266312f6b5f725efed8b389c7e63c6b469...b61f5645be499faa79383c2cc2f1d156c1d69a58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a0a060266312f6b5f725efed8b389c7e63c6b469...b61f5645be499faa79383c2cc2f1d156c1d69a58 You're receiving 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 Dec 8 14:08:15 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 08 Dec 2022 09:08:15 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-2] 15 commits: Hadrian: fix ghcDebugAssertions off-by-one error Message-ID: <6391efcf25109_224fca606805209a1@gitlab.mail> John Ericson pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - d90e7886 by John Ericson at 2022-12-08T09:07:08-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - 21fd913b by Ben Gamari at 2022-12-08T09:07:23-05:00 rts configure script - - - - - bfc287c4 by John Ericson at 2022-12-08T09:07:27-05:00 Lower min autoconf version for rts configure we're not sure why it was raised. - - - - - 30 changed files: - boot - compiler/GHC/Data/Graph/Directed.hs - + compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Session.hs - + compiler/GHC/Linker/Config.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools/Tasks.hs - compiler/ghc.cabal.in - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cabal.project - hadrian/cfg/system.config.in - hadrian/doc/user-settings.md - hadrian/hadrian.cabal - hadrian/src/Flavour/Type.hs - hadrian/src/Oracles/Flag.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Flavours/Development.hs - hadrian/src/Settings/Packages.hs - libraries/base/Data/Array/Byte.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/Type/Reflection/Unsafe.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f8a07f5af1caff28ce721f194747fd659c53d544...bfc287c414fa079ae45ae58d8f7122c1e31ea836 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f8a07f5af1caff28ce721f194747fd659c53d544...bfc287c414fa079ae45ae58d8f7122c1e31ea836 You're receiving 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 Dec 8 14:46:14 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Thu, 08 Dec 2022 09:46:14 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] 8 commits: Fix @since annotations on WithDict and Coercible Message-ID: <6391f8b6b4a88_224fca2595e17c540081@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - be2a3cc2 by Luite Stegeman at 2022-12-08T14:39:53+01:00 Add support for environments that don't have setImmediate - - - - - 2afa7109 by Luite Stegeman at 2022-12-08T14:40:09+01:00 Fix bound thread status - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Rep.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Stg/Lift/Analysis.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Utils/Outputable.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - libraries/base/Data/Coerce.hs - libraries/base/Data/Data.hs - libraries/base/Data/Void.hs - libraries/base/GHC/Base.hs - libraries/base/GHC/Exception/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc25d52e0f65d54c052908c7d91d5946342ab88a...2afa71097ae4782bf7cfe55dc0a664b9e48cc41c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc25d52e0f65d54c052908c7d91d5946342ab88a...2afa71097ae4782bf7cfe55dc0a664b9e48cc41c You're receiving 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 Dec 8 15:08:47 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 08 Dec 2022 10:08:47 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22547 Message-ID: <6391fdffb9213_224fca6061c54296c@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22547 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22547 You're receiving 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 Dec 8 15:12:31 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 08 Dec 2022 10:12:31 -0500 Subject: [Git][ghc/ghc][wip/T21623-faster] 91 commits: Fix a trivial typo in dataConNonlinearType Message-ID: <6391fedf78917_224fca60680547417@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623-faster at Glasgow Haskell Compiler / GHC Commits: 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - 1ec852db by Simon Peyton Jones at 2022-12-08T14:00:21+00:00 Better implementation of typeKind - - - - - e090e8c8 by Simon Peyton Jones at 2022-12-08T14:00:21+00:00 Wibbles - - - - - 10f053db by Simon Peyton Jones at 2022-12-08T14:00:21+00:00 Further wibbles to tyConAppResKind - - - - - f7368332 by Simon Peyton Jones at 2022-12-08T14:00:21+00:00 Wibble unused variable (fix me before finally landign) - - - - - 95949343 by Simon Peyton Jones at 2022-12-08T14:00:21+00:00 Wibbles - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/ProcPoint.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Wasm/Asm.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/Wasm/Types.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e2ef8676962d8497c7e34c6fa0a9151ad98262cd...95949343018a59c9114a5aaf8e1af283de6987d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e2ef8676962d8497c7e34c6fa0a9151ad98262cd...95949343018a59c9114a5aaf8e1af283de6987d6 You're receiving 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 Dec 8 15:52:46 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 08 Dec 2022 10:52:46 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-2] Need `$srcdir` in rts/configure Message-ID: <6392084e7e794_224fca219996405618cc@gitlab.mail> John Ericson pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: 53a33faf by John Ericson at 2022-12-08T10:52:25-05:00 Need `$srcdir` in rts/configure - - - - - 1 changed file: - rts/configure.ac Changes: ===================================== rts/configure.ac ===================================== @@ -170,7 +170,7 @@ dnl ###################################################################### dnl Generate external symbol flags (-Wl,-u...) dnl ###################################################################### -cat external-symbols.list.in \ +cat $srcdir/external-symbols.list.in \ | "$CC" -E -P -traditional -Iinclude - -o - \ | sed '/^$/d' \ > external-symbols.list \ @@ -188,7 +188,7 @@ dnl ###################################################################### dnl Generate build-info dnl ###################################################################### -cat rts.buildinfo.in | \ +cat $srcdir/rts.buildinfo.in | \ "$CC" -E -P -traditional - -o - \ > rts.buildinfo rm -f external-symbols.list View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53a33fafc195ceb46647f4225c4fe6f950fa2fdc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53a33fafc195ceb46647f4225c4fe6f950fa2fdc You're receiving 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 Dec 8 15:59:06 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 08 Dec 2022 10:59:06 -0500 Subject: [Git][ghc/ghc][wip/various-hadrian-fixes] packaging: Build perf builds with -split-sections Message-ID: <639209cabc3cd_224fca1d7887745624c4@gitlab.mail> Matthew Pickering pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC Commits: b6659bbe by Matthew Pickering at 2022-12-08T15:58:56+00:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 5 changed files: - .gitlab-ci.yml - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - hadrian/doc/flavours.md - hadrian/src/Settings/Flavours/Performance.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -423,7 +423,7 @@ doc-tarball: optional: true - job: nightly-x86_64-windows-validate optional: true - - job: release-x86_64-windows-release + - job: release-x86_64-windows-release+no_split_sections optional: true tags: @@ -447,7 +447,7 @@ doc-tarball: || mv "ghc-x86_64-linux-deb10-release.tar.xz" "$LINUX_BINDIST" \ || true mv "ghc-x86_64-windows-validate.tar.xz" "$WINDOWS_BINDIST" \ - || mv "ghc-x86_64-windows-release.tar.xz" "$WINDOWS_BINDIST" \ + || mv "ghc-x86_64-windows-release+no_split_sections.tar.xz" "$WINDOWS_BINDIST" \ || true if [ ! -f "$LINUX_BINDIST" ]; then echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" ===================================== .gitlab/gen_ci.hs ===================================== @@ -130,6 +130,7 @@ data BuildConfig , fullyStatic :: Bool , tablesNextToCode :: Bool , threadSanitiser :: Bool + , noSplitSections :: Bool } -- Extra arguments to pass to ./configure due to the BuildConfig @@ -146,13 +147,14 @@ mkJobFlavour BuildConfig{..} = Flavour buildFlavour opts opts = [Llvm | llvmBootstrap] ++ [Dwarf | withDwarf] ++ [FullyStatic | fullyStatic] ++ - [ThreadSanitiser | threadSanitiser] + [ThreadSanitiser | threadSanitiser] ++ + [NoSplitSections | noSplitSections, buildFlavour == Release ] data Flavour = Flavour BaseFlavour [FlavourTrans] -data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser +data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser | NoSplitSections -data BaseFlavour = Release | Validate | SlowValidate +data BaseFlavour = Release | Validate | SlowValidate deriving Eq ----------------------------------------------------------------------------- -- Build Configs @@ -174,8 +176,12 @@ vanilla = BuildConfig , fullyStatic = False , tablesNextToCode = True , threadSanitiser = False + , noSplitSections = False } +splitSectionsBroken :: BuildConfig -> BuildConfig +splitSectionsBroken bc = bc { noSplitSections = True } + nativeInt :: BuildConfig nativeInt = vanilla { bignumBackend = Native } @@ -290,6 +296,7 @@ flavourString (Flavour base trans) = baseString base ++ concatMap (("+" ++) . fl flavourString Dwarf = "debug_info" flavourString FullyStatic = "fully_static" flavourString ThreadSanitiser = "thread_sanitizer" + flavourString NoSplitSections = "no_split_sections" -- The path to the docker image (just for linux builders) dockerImage :: Arch -> Opsys -> Maybe String @@ -792,23 +799,23 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , disableValidate (standardBuilds Amd64 (Linux Debian11)) -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 -- not being at EOL until April 2023 and they still need tinfo5. - , disableValidate (standardBuilds Amd64 (Linux Debian9)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) (splitSectionsBroken vanilla)) , disableValidate (standardBuilds Amd64 (Linux Ubuntu2004)) - , disableValidate (standardBuilds Amd64 (Linux Centos7)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Centos7) (splitSectionsBroken vanilla)) -- Fedora33 job is always built with perf so there's one job in the normal -- validate pipeline which is built with perf. , (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig) -- This job is only for generating head.hackage docs , hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig)) , disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf) - , fastCI (standardBuilds Amd64 Windows) - , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt) + , fastCI (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla)) + , disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt)) , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , standardBuilds I386 (Linux Debian9) - , standardBuildsWithConfig Amd64 (Linux Alpine) static + , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) + , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure") ===================================== .gitlab/jobs.yaml ===================================== @@ -1869,7 +1869,7 @@ "XZ_OPT": "-9" } }, - "release-i386-linux-deb9-release": { + "release-i386-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1879,7 +1879,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-i386-linux-deb9-release.tar.xz", + "ghc-i386-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -1921,11 +1921,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-i386-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "i386-linux-deb9-release", + "TEST_ENV": "i386-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2120,7 +2120,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-linux-alpine3_12-release+fully_static": { + "release-x86_64-linux-alpine3_12-release+fully_static+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2130,7 +2130,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-alpine3_12-release+fully_static.tar.xz", + "ghc-x86_64-linux-alpine3_12-release+fully_static+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2172,18 +2172,18 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+fully_static", + "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+fully_static+no_split_sections", "BROKEN_TESTS": "encoding004 T10458 ghcilink002 linker_unload_native", - "BUILD_FLAVOUR": "release+fully_static", + "BUILD_FLAVOUR": "release+fully_static+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override ", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", - "TEST_ENV": "x86_64-linux-alpine3_12-release+fully_static", + "TEST_ENV": "x86_64-linux-alpine3_12-release+fully_static+no_split_sections", "XZ_OPT": "-9" } }, - "release-x86_64-linux-centos7-release": { + "release-x86_64-linux-centos7-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2193,7 +2193,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-centos7-release.tar.xz", + "ghc-x86_64-linux-centos7-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2235,12 +2235,12 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "x86_64-linux-centos7-release", + "TEST_ENV": "x86_64-linux-centos7-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2424,7 +2424,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-linux-deb9-release": { + "release-x86_64-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2434,7 +2434,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-deb9-release.tar.xz", + "ghc-x86_64-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2476,11 +2476,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "x86_64-linux-deb9-release", + "TEST_ENV": "x86_64-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2731,7 +2731,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-windows-int_native-release": { + "release-x86_64-windows-int_native-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2740,7 +2740,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-int_native-release.tar.xz", + "ghc-x86_64-windows-int_native-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2778,8 +2778,8 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2787,11 +2787,11 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-int_native-release", + "TEST_ENV": "x86_64-windows-int_native-release+no_split_sections", "XZ_OPT": "-9" } }, - "release-x86_64-windows-release": { + "release-x86_64-windows-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2800,7 +2800,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-release.tar.xz", + "ghc-x86_64-windows-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2838,8 +2838,8 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-windows-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2847,7 +2847,7 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-release", + "TEST_ENV": "x86_64-windows-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== hadrian/doc/flavours.md ===================================== @@ -15,6 +15,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
FlavourSplit Sections Extra arguments
default
+
-O
-H32m
-O2
-H32m
quick + -O0
-H64m
-O0
-H64m
quick-validate + -O0
-H64m
-Werror
-O0
-H64m
-Werror
quick-debug + -O0
-H64m
-O0
-H64m
quickest + -O0
-H64m
-O0
-H64m
perf + Yes (on supported platforms) -O
-H64m
-O
-H64m
bench + -O
-H64m
-O
-H64m
devel1 + -O
-H64m
-O
-H64m
devel2 + -O
-H64m
-O
-H64m
validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
slow-validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
static + -O
-H64m
-fPIC -static
-O
-H64m
-fPIC -static
+ @@ -35,6 +36,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -46,6 +48,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -57,6 +60,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -68,6 +72,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -79,6 +84,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -90,6 +96,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -112,6 +119,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -123,6 +131,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -134,6 +143,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -145,6 +155,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -156,6 +167,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -167,6 +179,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH ===================================== hadrian/src/Settings/Flavours/Performance.hs ===================================== @@ -6,7 +6,7 @@ import {-# SOURCE #-} Settings.Default -- Please update doc/flavours.md when changing this file. performanceFlavour :: Flavour -performanceFlavour = defaultFlavour +performanceFlavour = splitSections $ defaultFlavour { name = "perf" , args = defaultBuilderArgs <> performanceArgs <> defaultPackageArgs } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b6659bbeb64540bf783833c5b8f465316ff068e7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b6659bbeb64540bf783833c5b8f465316ff068e7 You're receiving 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 Dec 8 16:22:23 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 08 Dec 2022 11:22:23 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/t22518 Message-ID: <63920f3f5ab_224fcabe792c05683cf@gitlab.mail> Matthew Pickering pushed new branch wip/t22518 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t22518 You're receiving 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 Dec 8 16:23:09 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 08 Dec 2022 11:23:09 -0500 Subject: [Git][ghc/ghc][wip/t22518] packaging: Fix upload_ghc_libs.py script Message-ID: <63920f6dc8594_224fca6061c568514@gitlab.mail> Matthew Pickering pushed to branch wip/t22518 at Glasgow Haskell Compiler / GHC Commits: 4738efa0 by Matthew Pickering at 2022-12-08T16:22:53+00:00 packaging: Fix upload_ghc_libs.py script This change reflects the changes where .cabal files are now generated by hadrian rather than ./configure. Fixes #22518 - - - - - 1 changed file: - .gitlab/upload_ghc_libs.py Changes: ===================================== .gitlab/upload_ghc_libs.py ===================================== @@ -51,15 +51,19 @@ def prep_base(): def build_copy_file(pkg: Package, f: Path): target = Path('_build') / 'stage1' / pkg.path / 'build' / f dest = pkg.path / f - print(f'Building {target} for {dest}...') + build_file_hadrian(target) + print(f'Copying {target} to {dest}...') + dest.parent.mkdir(exist_ok=True, parents=True) + shutil.copyfile(target, dest) + +def build_file_hadrian(target: Path): build_cabal = Path('hadrian') / 'build-cabal' if not build_cabal.is_file(): build_cabal = Path('hadrian') / 'build.cabal.sh' + print(f'Building {target}...') run([build_cabal, target], check=True) - dest.parent.mkdir(exist_ok=True, parents=True) - shutil.copyfile(target, dest) def modify_file(pkg: Package, fname: Path, f: Callable[[str], str]): target = pkg.path / fname @@ -116,6 +120,7 @@ def prepare_sdist(pkg: Package): print(f'Preparing package {pkg.name}...') shutil.rmtree(pkg.path / 'dist-newstyle', ignore_errors=True) + build_file_hadrian(pkg.path / '{}.cabal'.format(pkg.name)) pkg.prepare_sdist() # Upload source tarball View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4738efa09634030d5987afb5a23851d80aa5465e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4738efa09634030d5987afb5a23851d80aa5465e You're receiving 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 Dec 8 16:23:17 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 08 Dec 2022 11:23:17 -0500 Subject: [Git][ghc/ghc][wip/t22518] packaging: Fix upload_ghc_libs.py script Message-ID: <63920f75e0aaa_224fca18f7d75456872f@gitlab.mail> Matthew Pickering pushed to branch wip/t22518 at Glasgow Haskell Compiler / GHC Commits: 10d1c5d2 by Matthew Pickering at 2022-12-08T16:23:11+00:00 packaging: Fix upload_ghc_libs.py script This change reflects the changes where .cabal files are now generated by hadrian rather than ./configure. Fixes #22518 - - - - - 1 changed file: - .gitlab/upload_ghc_libs.py Changes: ===================================== .gitlab/upload_ghc_libs.py ===================================== @@ -51,15 +51,19 @@ def prep_base(): def build_copy_file(pkg: Package, f: Path): target = Path('_build') / 'stage1' / pkg.path / 'build' / f dest = pkg.path / f - print(f'Building {target} for {dest}...') + build_file_hadrian(target) + print(f'Copying {target} to {dest}...') + dest.parent.mkdir(exist_ok=True, parents=True) + shutil.copyfile(target, dest) + +def build_file_hadrian(target: Path): build_cabal = Path('hadrian') / 'build-cabal' if not build_cabal.is_file(): build_cabal = Path('hadrian') / 'build.cabal.sh' + print(f'Building {target}...') run([build_cabal, target], check=True) - dest.parent.mkdir(exist_ok=True, parents=True) - shutil.copyfile(target, dest) def modify_file(pkg: Package, fname: Path, f: Callable[[str], str]): target = pkg.path / fname @@ -116,6 +120,7 @@ def prepare_sdist(pkg: Package): print(f'Preparing package {pkg.name}...') shutil.rmtree(pkg.path / 'dist-newstyle', ignore_errors=True) + build_file_hadrian(pkg.path / '{}.cabal'.format(pkg.name)) pkg.prepare_sdist() # Upload source tarball View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/10d1c5d28781683fac2252a06e7540821b76aac2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/10d1c5d28781683fac2252a06e7540821b76aac2 You're receiving 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 Dec 8 17:21:33 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 08 Dec 2022 12:21:33 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22272 Message-ID: <63921d1d89eb_224fca526d45828d8@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22272 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22272 You're receiving 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 Dec 8 17:22:59 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 08 Dec 2022 12:22:59 -0500 Subject: [Git][ghc/ghc][wip/T22272] 9 commits: Fix bounds-checking buglet in Data.Array.Byte Message-ID: <63921d73a7698_224fca219996405830b7@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22272 at Glasgow Haskell Compiler / GHC Commits: e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 6563a237 by Gergő Érdi at 2022-12-08T17:22:50+00:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. - - - - - 9eabe4b2 by Simon Peyton Jones at 2022-12-08T17:22:50+00:00 Improve the UnfoldingCache mechanism This small patch adds some documentation around the new UnfoldingCache field. But most important it does two things: * In GHC.Core.Unfold.Make.mkCoreUnfolding we we accidentally forcing the wrong values, which led to duplicate work. * In GHC.Core.Unfold.callSiteInline we were forcing UnfoldingCache which caused unnecessary work. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - hadrian/src/Settings/Packages.hs - libraries/base/Data/Array/Byte.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/Type/Reflection/Unsafe.hs - libraries/base/changelog.md - rts/eventlog/EventLog.c - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/simplCore/should_compile/T22272.hs - + testsuite/tests/simplCore/should_compile/T22272.stderr - + testsuite/tests/simplCore/should_compile/T22272_A.hs - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/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/28944f434538eb4c86f919776f7236c926617908...9eabe4b279f6d585791bd79a2172fcc29a079921 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/28944f434538eb4c86f919776f7236c926617908...9eabe4b279f6d585791bd79a2172fcc29a079921 You're receiving 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 Dec 8 20:55:27 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 15:55:27 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 17 commits: Add test for #22162 Message-ID: <63924f3fe94e2_224fca2595e17c61982d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f5f45cb9 by Matthew Pickering at 2022-12-08T15:55:10-05:00 Add test for #22162 - - - - - 854690aa by Matthew Pickering at 2022-12-08T15:55:10-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - eaea2e33 by Matthew Pickering at 2022-12-08T15:55:10-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 9f1df6bc by Matthew Pickering at 2022-12-08T15:55:10-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - 4ff743c9 by Matthew Pickering at 2022-12-08T15:55:10-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - 2fc792a3 by lrzlin at 2022-12-08T15:55:11-05:00 Add initial support for LoongArch Architecture. - - - - - a45c48ea by Bodigrim at 2022-12-08T15:55:14-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - a1afe06d by Bodigrim at 2022-12-08T15:55:14-05:00 Allow mtl-2.3 in hadrian - - - - - 33316e28 by Bodigrim at 2022-12-08T15:55:14-05:00 Support mtl-2.3 in check-exact - - - - - f82de413 by Bodigrim at 2022-12-08T15:55:14-05:00 Fix tests - - - - - 9dce459b by Sebastian Graf at 2022-12-08T15:55:14-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - c2f39846 by Matthew Pickering at 2022-12-08T15:55:15-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - a17edf78 by Sebastian Graf at 2022-12-08T15:55:15-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 344d1583 by Sebastian Graf at 2022-12-08T15:55:16-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 2d1c7303 by John Ericson at 2022-12-08T15:55:16-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - d64d8742 by Krzysztof Gogolewski at 2022-12-08T15:55:17-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - e839c0af by Bryan Richter at 2022-12-08T15:55:17-05:00 testsuite: Mark conc024 fragile on Windows - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Lit.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Platform.hs - + compiler/GHC/Platform/LoongArch64.hs - compiler/GHC/Platform/Regs.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Types/SourceText.hs - compiler/ghc.cabal.in - configure.ac - hadrian/cabal.project - hadrian/hadrian.cabal - hadrian/src/Oracles/Flag.hs - libraries/Cabal - libraries/base/GHC/List.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b61f5645be499faa79383c2cc2f1d156c1d69a58...e839c0af64e77995a0faf8cee58ba93a117b0ae2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b61f5645be499faa79383c2cc2f1d156c1d69a58...e839c0af64e77995a0faf8cee58ba93a117b0ae2 You're receiving 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 Dec 8 21:43:12 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 08 Dec 2022 16:43:12 -0500 Subject: [Git][ghc/ghc][wip/T22264-9.2] 6 commits: nonmoving: Fix handling of weak pointers Message-ID: <63925a70b0e16_224fca6061c6422e8@gitlab.mail> Ben Gamari pushed to branch wip/T22264-9.2 at Glasgow Haskell Compiler / GHC Commits: 346bdd1c by Ben Gamari at 2022-12-08T16:42:46-05:00 nonmoving: Fix handling of weak pointers This fixes an interaction between aging and weak pointer handling which prevented the finalization of some weak pointers. In particular, weak pointers could have their keys incorrectly marked by the preparatory collector, preventing their finalization by the subsequent concurrent collection. While in the area, we also significantly improve the assertions regarding weak pointers. Fixes #22327. (cherry picked from commit cab678fc11d0a3f28fbf2210c4c0bb04eb52997d) - - - - - 27370959 by Ben Gamari at 2022-12-08T16:42:46-05:00 nonmoving: Handle new closures in nonmovingIsNowAlive (cherry picked from commit 36ca160d0f199a688cf5fbc91d4bb92d2d4ea14e) - - - - - affeb429 by Ben Gamari at 2022-12-08T16:42:46-05:00 nonmoving: Don't clobber update rem sets of old capabilities Previously `storageAddCapabilities` (called by `setNumCapabilities`) would clobber the update remembered sets of existing capabilities when increasing the capability count. Fix this by only initializing the update remembered sets of the newly-created capabilities. (cherry picked from commit 8b64aff0fa978c762dfae8df235dd2b2a340656a) - - - - - 3ebb5514 by Ben Gamari at 2022-12-08T16:42:46-05:00 nonmoving: Add missing write barriers in selector optimisation This fixes the selector optimisation, adding a few write barriers which are necessary for soundness. (cherry picked from commit dde67d6e32ecff0e400f98213d42ae790babac09) - - - - - 1ffe6328 by Ben Gamari at 2022-12-08T16:42:46-05:00 nonmoving: Don't push if nonmoving collector isn't enabled (cherry picked from commit 8adc1750c02e596b4014d2837b4eb3d76bd130f2) - - - - - c461f510 by Ben Gamari at 2022-12-08T16:42:49-05:00 nonmoving: Sync-phase mark budgeting Here we significantly improve the bound on sync phase pause times by imposing a limit on the amount of work that we can perform during the sync. If we find that we have exceeded our marking budget then we allow the mutators to resume, return to concurrent marking, and try synchronizing again later. - - - - - 8 changed files: - rts/RtsStartup.c - rts/sm/Evac.c - rts/sm/MarkWeak.c - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingMark.c - rts/sm/NonMovingMark.h - rts/sm/Storage.c Changes: ===================================== rts/RtsStartup.c ===================================== @@ -472,6 +472,7 @@ hs_exit_(bool wait_foreign) for (g = 0; g < RtsFlags.GcFlags.generations; g++) { runAllCFinalizers(generations[g].weak_ptr_list); } + runAllCFinalizers(nonmoving_weak_ptr_list); #if defined(RTS_USER_SIGNALS) if (RtsFlags.MiscFlags.install_signal_handlers) { ===================================== rts/sm/Evac.c ===================================== @@ -1246,13 +1246,18 @@ selector_chain: bd = Bdescr((StgPtr)p); if (HEAP_ALLOCED_GC(p)) { + uint16_t flags = RELAXED_LOAD(&bd->flags); // If the THUNK_SELECTOR is in to-space or in a generation that we // are not collecting, then bale out early. We won't be able to // 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 (RELAXED_LOAD(&bd->flags) & (BF_EVACUATED | BF_NONMOVING)) { + if (flags & (BF_EVACUATED | BF_NONMOVING)) { unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p); + if (flags & BF_NONMOVING) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) p); + } *q = (StgClosure *)p; // shortcut, behave as for: if (evac) evacuate(q); if (evac && bd->gen_no < gct->evac_gen_no) { @@ -1267,7 +1272,7 @@ selector_chain: // (scavenge_mark_stack doesn't deal with IND). BEWARE! This // bit is very tricky to get right. If you make changes // around here, test by compiling stage 3 with +RTS -c -RTS. - if (bd->flags & BF_MARKED) { + if (flags & BF_MARKED) { // must call evacuate() to mark this closure if evac==true *q = (StgClosure *)p; if (evac) evacuate(q); @@ -1307,6 +1312,12 @@ selector_chain: // - undo the chain we've built to point to p. SET_INFO((StgClosure *)p, (const StgInfoTable *)info_ptr); RELEASE_STORE(q, (StgClosure *) p); + if (Bdescr((StgPtr)p)->flags & BF_NONMOVING) { + // See Note [Non-moving GC: Marking evacuated objects]. + // TODO: This really shouldn't be necessary since whoever won + // the race should have pushed + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) p); + } if (evac) evacuate(q); unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p); return; @@ -1397,6 +1408,11 @@ selector_loop: case THUNK_SELECTOR: // Use payload to make a list of thunk selectors, to be // used in unchain_thunk_selectors + // + // FIXME: This seems racy; should we lock this selector to + // ensure that another thread doesn't clobber this node + // of the chain. This would result in some previous + // selectors not being updated when we unchain. RELAXED_STORE(&((StgClosure*)p)->payload[0], (StgClosure *)prev_thunk_selector); prev_thunk_selector = p; p = (StgSelector*)val; @@ -1421,6 +1437,12 @@ selector_loop: // eval_thunk_selector(), because we know val is not // a THUNK_SELECTOR. if (evac) evacuate(q); + + if (isNonmovingClosure(*q)) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) *q); + } + return; } @@ -1465,6 +1487,10 @@ selector_loop: // recurse indefinitely, so we impose a depth bound. // See Note [Selector optimisation depth limit]. if (gct->thunk_selector_depth >= MAX_THUNK_SELECTOR_DEPTH) { + if (isNonmovingClosure((StgClosure *) p)) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, (StgClosure*) p); + } goto bale_out; } @@ -1511,5 +1537,9 @@ bale_out: if (evac) { copy(q,(const StgInfoTable *)info_ptr,(StgClosure *)p,THUNK_SELECTOR_sizeW(),bd->dest_no); } + if (isNonmovingClosure(*q)) { + // See Note [Non-moving GC: Marking evacuated objects]. + markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, *q); + } unchain_thunk_selectors(prev_thunk_selector, *q); } ===================================== rts/sm/MarkWeak.c ===================================== @@ -50,7 +50,7 @@ - weak_stage == WeakPtrs - We process all the weak pointers whos keys are alive (evacuate + We process all the weak pointers whose keys are alive (evacuate their values and finalizers), and repeat until we can find no new live keys. If no live keys are found in this pass, then we evacuate the finalizers of all the dead weak pointers in order to @@ -82,12 +82,46 @@ static bool tidyWeakList (generation *gen); static bool resurrectUnreachableThreads (generation *gen, StgTSO **resurrected_threads); static void tidyThreadList (generation *gen); +/* + * Note [Weak pointer processing and the non-moving GC] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * When using the non-moving GC we defer weak pointer processing + * until the concurrent marking phase as weaks in the non-moving heap may be + * keyed on objects living in the non-moving generation. To accomplish this + * initWeakForGC keeps all weak pointers on oldest_gen->weak_ptr_list, where + * nonmovingCollect will find them. From there they will be moved to + * nonmoving_old_weak_ptr_list. During the mark loop we will move weaks with + * reachable keys to nonmoving_weak_ptr_list. At the end of concurrent marking + * we tidy the weak list (in nonmovingTidyWeakList) and perform another set of + * marking as necessary, just as is done in tidyWeakList. + * + * Note that this treatment takes advantage of the fact that we usually need + * not worry about Weak#s living in the non-moving heap but being keyed on an + * object in the moving heap since the Weak# must be strictly older than the + * key. Such objects would otherwise pose a problem since the non-moving + * collector would be unable to safely determine the liveness of the key. + * In the rare case that we *do* see such a key (e.g. in the case of a + * pinned ByteArray# living in a partially-filled accumulator block) + * the nonmoving collector assumes that it is live. + * + */ + +/* + * Prepare the weak object lists for GC. Specifically, reset weak_stage + * and move all generations' `weak_ptr_list`s to `old_weak_ptr_list`. + * Weaks with live keys will later be moved back to `weak_ptr_list` by + * `tidyWeakList`. + */ void initWeakForGC(void) { - uint32_t g; + uint32_t oldest = N; + if (RtsFlags.GcFlags.useNonmoving && N == oldest_gen->no) { + // See Note [Weak pointer processing and the non-moving GC]. + oldest = oldest_gen->no - 1; + } - for (g = 0; g <= N; g++) { + for (uint32_t g = 0; g <= oldest; g++) { generation *gen = &generations[g]; gen->old_weak_ptr_list = gen->weak_ptr_list; gen->weak_ptr_list = NULL; @@ -96,6 +130,14 @@ initWeakForGC(void) weak_stage = WeakThreads; } +/* + * Walk the weak pointer lists after having finished a round of scavenging, + * tidying the weak (and possibly thread) lists (depending upon the current + * weak_stage). + * + * Returns true if new live weak pointers were found, implying that another + * round of scavenging is necessary. + */ bool traverseWeakPtrList(StgWeak **dead_weak_ptr_list, StgTSO **resurrected_threads) { @@ -182,6 +224,11 @@ traverseWeakPtrList(StgWeak **dead_weak_ptr_list, StgTSO **resurrected_threads) } } +/* + * Deal with weak pointers with unreachable keys after GC has concluded. + * This means marking the finalizer (and possibly value) in preparation for + * later finalization. + */ static void collectDeadWeakPtrs (generation *gen, StgWeak **dead_weak_ptr_list) { StgWeak *w, *next_w; @@ -198,6 +245,10 @@ static void collectDeadWeakPtrs (generation *gen, StgWeak **dead_weak_ptr_list) } } +/* + * Deal with threads left on the old_threads list after GC has concluded, + * moving them onto the resurrected_threads list where appropriate. + */ static bool resurrectUnreachableThreads (generation *gen, StgTSO **resurrected_threads) { StgTSO *t, *tmp, *next; @@ -233,8 +284,21 @@ static bool resurrectUnreachableThreads (generation *gen, StgTSO **resurrected_t return flag; } +/* + * Walk over the `old_weak_ptr_list` of the given generation and: + * + * - remove any DEAD_WEAKs + * - move any weaks with reachable keys to the `weak_ptr_list` of the + * appropriate to-space and mark the weak's value and finalizer. + */ static bool tidyWeakList(generation *gen) { + if (RtsFlags.GcFlags.useNonmoving && gen == oldest_gen) { + // See Note [Weak pointer processing and the non-moving GC]. + ASSERT(gen->old_weak_ptr_list == NULL); + return false; + } + StgWeak *w, **last_w, *next_w; const StgInfoTable *info; StgClosure *new; @@ -322,6 +386,10 @@ static bool tidyWeakList(generation *gen) return flag; } +/* + * Walk over the `old_threads` list of the given generation and move any + * reachable threads onto the `threads` list. + */ static void tidyThreadList (generation *gen) { StgTSO *t, *tmp, *next, **prev; @@ -381,6 +449,10 @@ static void checkWeakPtrSanity(StgWeak *hd, StgWeak *tl) } #endif +/* + * Traverse the capabilities' local new-weak-pointer lists at the beginning of + * GC and move them to the nursery's weak_ptr_list. + */ void collectFreshWeakPtrs() { uint32_t i; ===================================== rts/sm/NonMoving.c ===================================== @@ -26,7 +26,7 @@ #include "NonMovingCensus.h" #include "StablePtr.h" // markStablePtrTable #include "Schedule.h" // markScheduler -#include "Weak.h" // dead_weak_ptr_list +#include "Weak.h" // scheduleFinalizers struct NonmovingHeap nonmovingHeap; @@ -244,6 +244,12 @@ Mutex concurrent_coll_finished_lock; * how we use the DIRTY flags associated with MUT_VARs and TVARs to improve * barrier efficiency. * + * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) describes + * how weak pointers are handled when the non-moving GC is in use. + * + * - Note [Sync phase marking budget] describes how we avoid long mutator + * pauses during the sync phase + * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage * collector for functional programs on multicore processors. SIGPLAN Not. 51, @@ -282,8 +288,8 @@ Mutex concurrent_coll_finished_lock; * was (unsurprisingly) also found to result in significant amounts of * unnecessary copying. * - * Consequently, we now allow aging. Aging allows the preparatory GC leading up - * to a major collection to evacuate some objects into the young generation. + * Consequently, we now allow "aging", allows the preparatory GC leading up + * to a major collection to evacuate objects into the young generation. * However, this introduces the following tricky case that might arise after * we have finished the preparatory GC: * @@ -493,6 +499,28 @@ Mutex concurrent_coll_finished_lock; * remembered set during the preparatory GC. This allows us to safely skip the * non-moving write barrier without jeopardizing the snapshot invariant. * + * + * Note [Sync phase marking budget] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * The non-moving collector is intended to provide reliably low collection + * latencies. These latencies are primarily due to two sources: + * + * a. the preparatory moving collection at the beginning of the major GC cycle + * b. the post-mark synchronization pause at the end + * + * While the cost of (a) is inherently bounded by the young generation size, + * (b) can in principle be unbounded since the mutator may hide large swathes + * of heap from the collector's concurrent mark phase via mutation. These will + * only become visible to the collector during the post-mark synchronization + * phase. + * + * Since we don't want to do unbounded marking work in the pause, we impose a + * bound on the amount of work that we can do during the pause. If we deplete + * our marking budget during the pause then we allow the mutators to resume + * and return to concurrent marking (keeping the update remembered set write + * barrier enabled). After we have finished marking we will again attempt the + * post-mark synchronization. + * */ memcount nonmoving_live_words = 0; @@ -886,37 +914,6 @@ static void nonmovingPrepareMark(void) #endif } -// Mark weak pointers in the non-moving heap. They'll either end up in -// dead_weak_ptr_list or stay in weak_ptr_list. Either way they need to be kept -// during sweep. See `MarkWeak.c:markWeakPtrList` for the moving heap variant -// of this. -static void nonmovingMarkWeakPtrList(MarkQueue *mark_queue, StgWeak *dead_weak_ptr_list) -{ - for (StgWeak *w = oldest_gen->weak_ptr_list; w; w = w->link) { - markQueuePushClosure_(mark_queue, (StgClosure*)w); - // Do not mark finalizers and values here, those fields will be marked - // in `nonmovingMarkDeadWeaks` (for dead weaks) or - // `nonmovingTidyWeaks` (for live weaks) - } - - // We need to mark dead_weak_ptr_list too. This is subtle: - // - // - By the beginning of this GC we evacuated all weaks to the non-moving - // heap (in `markWeakPtrList`) - // - // - During the scavenging of the moving heap we discovered that some of - // those weaks are dead and moved them to `dead_weak_ptr_list`. Note that - // because of the fact above _all weaks_ are in the non-moving heap at - // this point. - // - // - So, to be able to traverse `dead_weak_ptr_list` and run finalizers we - // need to mark it. - for (StgWeak *w = dead_weak_ptr_list; w; w = w->link) { - markQueuePushClosure_(mark_queue, (StgClosure*)w); - nonmovingMarkDeadWeak(mark_queue, w); - } -} - void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) { #if defined(THREADED_RTS) @@ -950,9 +947,16 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) capabilities[n], true/*don't mark sparks*/); } markScheduler((evac_fn)markQueueAddRoot, mark_queue); - nonmovingMarkWeakPtrList(mark_queue, *dead_weaks); markStablePtrTable((evac_fn)markQueueAddRoot, mark_queue); + // The dead weak pointer list shouldn't contain any weaks in the + // nonmoving heap +#if defined(DEBUG) + for (StgWeak *w = *dead_weaks; w; w = w->link) { + ASSERT(Bdescr((StgPtr) w)->gen != oldest_gen); + } +#endif + // Mark threads resurrected during moving heap scavenging for (StgTSO *tso = *resurrected_threads; tso != END_TSO_QUEUE; tso = tso->global_link) { markQueuePushClosure_(mark_queue, (StgClosure*)tso); @@ -978,8 +982,23 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) // alive). ASSERT(oldest_gen->old_weak_ptr_list == NULL); ASSERT(nonmoving_old_weak_ptr_list == NULL); - nonmoving_old_weak_ptr_list = oldest_gen->weak_ptr_list; - oldest_gen->weak_ptr_list = NULL; + { + // Move both oldest_gen->weak_ptr_list and nonmoving_weak_ptr_list to + // nonmoving_old_weak_ptr_list + StgWeak **weaks = &oldest_gen->weak_ptr_list; + uint32_t n = 0; + while (*weaks) { + weaks = &(*weaks)->link; + n++; + } + debugTrace(DEBUG_nonmoving_gc, "%d new nonmoving weaks", n); + *weaks = nonmoving_weak_ptr_list; + nonmoving_old_weak_ptr_list = oldest_gen->weak_ptr_list; + nonmoving_weak_ptr_list = NULL; + oldest_gen->weak_ptr_list = NULL; + // At this point all weaks in the nonmoving generation are on + // nonmoving_old_weak_ptr_list + } trace(TRACE_nonmoving_gc, "Finished nonmoving GC preparation"); // We are now safe to start concurrent marking @@ -1015,19 +1034,25 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) } /* Mark queue, threads, and weak pointers until no more weaks have been - * resuscitated + * resuscitated. If *budget is non-zero then we will mark no more than + * Returns true if we there is no more marking work to be done, false if + * we exceeded our marking budget. */ -static void nonmovingMarkThreadsWeaks(MarkQueue *mark_queue) +static bool nonmovingMarkThreadsWeaks(MarkBudget *budget, MarkQueue *mark_queue) { while (true) { // Propagate marks - nonmovingMark(mark_queue); + nonmovingMark(budget, mark_queue); + if (*budget == 0) { + return false; + } // Tidy threads and weaks nonmovingTidyThreads(); - if (! nonmovingTidyWeaks(mark_queue)) - return; + if (! nonmovingTidyWeaks(mark_queue)) { + return true; + } } } @@ -1041,7 +1066,6 @@ static void* nonmovingConcurrentMark(void *data) return NULL; } -// TODO: Not sure where to put this function. // Append w2 to the end of w1. static void appendWeakList( StgWeak **w1, StgWeak *w2 ) { @@ -1081,8 +1105,15 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * } } + // Mark Weak#s + nonmovingMarkWeakPtrList(mark_queue); + // Do concurrent marking; most of the heap will get marked here. - nonmovingMarkThreadsWeaks(mark_queue); +concurrent_marking: + { + MarkBudget budget = UNLIMITED_MARK_BUDGET; + nonmovingMarkThreadsWeaks(&budget, mark_queue); + } #if defined(THREADED_RTS) Task *task = newBoundTask(); @@ -1091,21 +1122,13 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * if (sched_state > SCHED_RUNNING) { // Note that we break our invariants here and leave segments in // nonmovingHeap.sweep_list, don't free nonmoving_large_objects etc. - // However because we won't be running mark-sweep in the final GC this + // However because we won't be running sweep in the final GC this // is OK. - - // This is a RTS shutdown so we need to move our copy (snapshot) of - // weaks (nonmoving_old_weak_ptr_list and nonmoving_weak_ptr_list) to - // oldest_gen->threads to be able to run C finalizers in hs_exit_. Note - // that there may be more weaks added to oldest_gen->threads since we - // started mark, so we need to append our list to the tail of - // oldest_gen->threads. - appendWeakList(&nonmoving_old_weak_ptr_list, nonmoving_weak_ptr_list); - appendWeakList(&oldest_gen->weak_ptr_list, nonmoving_old_weak_ptr_list); - // These lists won't be used again so this is not necessary, but still - nonmoving_old_weak_ptr_list = NULL; - nonmoving_weak_ptr_list = NULL; - + // + // However, we must move any weak pointers remaining on + // nonmoving_old_weak_ptr_list back to nonmoving_weak_ptr_list + // such that their C finalizers can be run by hs_exit_. + appendWeakList(&nonmoving_weak_ptr_list, nonmoving_old_weak_ptr_list); goto finish; } @@ -1113,9 +1136,17 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * nonmovingBeginFlush(task); bool all_caps_syncd; + MarkBudget sync_marking_budget = 200000; do { all_caps_syncd = nonmovingWaitForFlush(); - nonmovingMarkThreadsWeaks(mark_queue); + if (nonmovingMarkThreadsWeaks(&sync_marking_budget, mark_queue) == false) { + // We ran out of budget for marking. Abort sync. + // See Note [Sync phase marking budget]. + traceConcSyncEnd(); + stat_endNonmovingGcSync(); + releaseAllCapabilities(n_capabilities, NULL, task); + goto concurrent_marking; + } } while (!all_caps_syncd); #endif @@ -1126,7 +1157,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * // Do last marking of weak pointers while (true) { // Propagate marks - nonmovingMark(mark_queue); + nonmovingMarkUnlimitedBudget(mark_queue); if (!nonmovingTidyWeaks(mark_queue)) break; @@ -1135,7 +1166,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * nonmovingMarkDeadWeaks(mark_queue, dead_weaks); // Propagate marks - nonmovingMark(mark_queue); + nonmovingMarkUnlimitedBudget(mark_queue); // Now remove all dead objects from the mut_list to ensure that a younger // generation collection doesn't attempt to look at them after we've swept. @@ -1177,15 +1208,9 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * nonmoving_old_threads = END_TSO_QUEUE; } - { - StgWeak **weaks = &oldest_gen->weak_ptr_list; - while (*weaks) { - weaks = &(*weaks)->link; - } - *weaks = nonmoving_weak_ptr_list; - nonmoving_weak_ptr_list = NULL; - nonmoving_old_weak_ptr_list = NULL; - } + // At this point point any weak that remains on nonmoving_old_weak_ptr_list + // has a dead key. + nonmoving_old_weak_ptr_list = NULL; // Prune spark lists // See Note [Spark management under the nonmoving collector]. ===================================== rts/sm/NonMoving.h ===================================== @@ -289,20 +289,17 @@ INLINE_HEADER void nonmovingSetClosureMark(StgPtr p) nonmovingSetMark(nonmovingGetSegment(p), nonmovingGetBlockIdx(p)); } -// TODO: Audit the uses of these -/* Was the given closure marked this major GC cycle? */ -INLINE_HEADER bool nonmovingClosureMarkedThisCycle(StgPtr p) +INLINE_HEADER uint8_t nonmovingGetClosureMark(StgPtr p) { struct NonmovingSegment *seg = nonmovingGetSegment(p); nonmoving_block_idx blk_idx = nonmovingGetBlockIdx(p); - return nonmovingGetMark(seg, blk_idx) == nonmovingMarkEpoch; + return nonmovingGetMark(seg, blk_idx); } -INLINE_HEADER bool nonmovingClosureMarked(StgPtr p) +/* Was the given closure marked this major GC cycle? */ +INLINE_HEADER bool nonmovingClosureMarkedThisCycle(StgPtr p) { - struct NonmovingSegment *seg = nonmovingGetSegment(p); - nonmoving_block_idx blk_idx = nonmovingGetBlockIdx(p); - return nonmovingGetMark(seg, blk_idx) != 0; + return nonmovingGetClosureMark(p) == nonmovingMarkEpoch; } // Can be called during a major collection to determine whether a particular @@ -338,7 +335,7 @@ INLINE_HEADER bool nonmovingClosureBeingSwept(StgClosure *p) INLINE_HEADER bool isNonmovingClosure(StgClosure *p) { - return !HEAP_ALLOCED_GC(p) || Bdescr((P_)p)->flags & BF_NONMOVING; + return RtsFlags.GcFlags.useNonmoving && (!HEAP_ALLOCED_GC(p) || Bdescr((P_)p)->flags & BF_NONMOVING); } #if defined(DEBUG) ===================================== rts/sm/NonMovingMark.c ===================================== @@ -35,6 +35,9 @@ static void trace_PAP_payload (MarkQueue *queue, StgClosure *fun, StgClosure **payload, StgWord size); +#if defined(DEBUG) +static bool is_nonmoving_weak(StgWeak *weak); +#endif // How many Array# entries to add to the mark queue at once? #define MARK_ARRAY_CHUNK_LENGTH 128 @@ -623,6 +626,16 @@ void updateRemembSetPushThunkEager(Capability *cap, } break; } + case THUNK_SELECTOR: + { + StgSelector *sel = (StgSelector *) thunk; + if (check_in_nonmoving_heap(sel->selectee)) { + // Don't bother to push origin; it makes the barrier needlessly + // expensive with little benefit. + push_closure(queue, sel->selectee, NULL); + } + break; + } case AP: { StgAP *ap = (StgAP *) thunk; @@ -632,9 +645,11 @@ void updateRemembSetPushThunkEager(Capability *cap, trace_PAP_payload(queue, ap->fun, ap->payload, ap->n_args); break; } - case THUNK_SELECTOR: + // We may end up here if a thunk update races with another update. + // In this case there is nothing to do as the other thread will have + // already pushed the updated thunk's free variables to the update + // remembered set. case BLACKHOLE: - // TODO: This is right, right? break; // The selector optimization performed by the nonmoving mark may have // overwritten a thunk which we are updating with an indirection. @@ -1466,10 +1481,12 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) break; } + case WEAK: + ASSERT(is_nonmoving_weak((StgWeak*) p)); + // fallthrough gen_obj: case CONSTR: case CONSTR_NOCAF: - case WEAK: case PRIM: { for (StgWord i = 0; i < info->layout.payload.ptrs; i++) { @@ -1522,8 +1539,15 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) } case THUNK_SELECTOR: - nonmoving_eval_thunk_selector(queue, (StgSelector*)p, origin); + { + StgSelector *sel = (StgSelector *) p; + // We may be able to evaluate this selector which may render the + // selectee unreachable. However, we must mark the selectee regardless + // to satisfy the snapshot invariant. + PUSH_FIELD(sel, selectee); + nonmoving_eval_thunk_selector(queue, sel, origin); break; + } case AP_STACK: { StgAP_STACK *ap = (StgAP_STACK *)p; @@ -1673,15 +1697,23 @@ done: * b. the nursery has been fully evacuated into the non-moving generation. * c. the mark queue has been seeded with a set of roots. * + * If budget is not UNLIMITED_MARK_BUDGET, then we will mark no more than the + * indicated number of objects and deduct the work done from the budget. */ GNUC_ATTR_HOT void -nonmovingMark (MarkQueue *queue) +nonmovingMark (MarkBudget* budget, MarkQueue *queue) { traceConcMarkBegin(); debugTrace(DEBUG_nonmoving_gc, "Starting mark pass"); - unsigned int count = 0; + uint64_t count = 0; while (true) { count++; + if (*budget == 0) { + return; + } else if (*budget != UNLIMITED_MARK_BUDGET) { + *budget -= 1; + } + MarkQueueEnt ent = markQueuePop(queue); switch (nonmovingMarkQueueEntryType(&ent)) { @@ -1820,10 +1852,46 @@ static bool nonmovingIsNowAlive (StgClosure *p) || (bd->flags & BF_MARKED) != 0; // The object was marked } else { - return nonmovingClosureMarkedThisCycle((P_)p); + struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) p); + StgClosure *snapshot_loc = + (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap); + if (p >= snapshot_loc && nonmovingGetClosureMark((StgPtr) p) == 0) { + /* + * In this case we are looking at a block that wasn't allocated + * at the time that the snapshot was taken. As we do not mark such + * blocks, we must assume that it is reachable. + */ + return true; + } else { + return nonmovingClosureMarkedThisCycle((P_)p); + } + } +} + +// Mark all Weak#s on nonmoving_old_weak_ptr_list. +void nonmovingMarkWeakPtrList (struct MarkQueue_ *queue) +{ + ASSERT(nonmoving_weak_ptr_list == NULL); + for (StgWeak *w = nonmoving_old_weak_ptr_list; w != NULL; w = w->link) { + mark_closure(queue, (StgClosure *) w, NULL); } } +#if defined(DEBUG) +// Determine whether a weak pointer object is on one of the nonmoving +// collector's weak pointer lists. Used for sanity checking. +static bool is_nonmoving_weak(StgWeak *weak) +{ + for (StgWeak *w = nonmoving_old_weak_ptr_list; w != NULL; w = w->link) { + if (w == weak) return true; + } + for (StgWeak *w = nonmoving_weak_ptr_list; w != NULL; w = w->link) { + if (w == weak) return true; + } + return false; +} +#endif + // Non-moving heap variant of `tidyWeakList` bool nonmovingTidyWeaks (struct MarkQueue_ *queue) { @@ -1832,6 +1900,9 @@ bool nonmovingTidyWeaks (struct MarkQueue_ *queue) StgWeak **last_w = &nonmoving_old_weak_ptr_list; StgWeak *next_w; for (StgWeak *w = nonmoving_old_weak_ptr_list; w != NULL; w = next_w) { + // This should have been marked by nonmovingMarkWeaks + ASSERT(nonmovingIsNowAlive((StgClosure *) w)); + if (w->header.info == &stg_DEAD_WEAK_info) { // finalizeWeak# was called on the weak next_w = w->link; @@ -1842,7 +1913,10 @@ bool nonmovingTidyWeaks (struct MarkQueue_ *queue) // Otherwise it's a live weak ASSERT(w->header.info == &stg_WEAK_info); - if (nonmovingIsNowAlive(w->key)) { + // See Note [Weak pointer processing and the non-moving GC] in + // MarkWeak.c + bool key_in_nonmoving = Bdescr((StgPtr) w->key)->flags & BF_NONMOVING; + if (!key_in_nonmoving || nonmovingIsNowAlive(w->key)) { nonmovingMarkLiveWeak(queue, w); did_work = true; @@ -1850,7 +1924,7 @@ bool nonmovingTidyWeaks (struct MarkQueue_ *queue) *last_w = w->link; next_w = w->link; - // and put it on the weak ptr list + // and put it on nonmoving_weak_ptr_list w->link = nonmoving_weak_ptr_list; nonmoving_weak_ptr_list = w; } else { @@ -1872,7 +1946,8 @@ void nonmovingMarkDeadWeak (struct MarkQueue_ *queue, StgWeak *w) void nonmovingMarkLiveWeak (struct MarkQueue_ *queue, StgWeak *w) { - ASSERT(nonmovingClosureMarkedThisCycle((P_)w)); + ASSERT(nonmovingIsNowAlive((StgClosure *) w)); + ASSERT(nonmovingIsNowAlive((StgClosure *) w->key)); markQueuePushClosure_(queue, w->value); markQueuePushClosure_(queue, w->finalizer); markQueuePushClosure_(queue, w->cfinalizers); @@ -1886,9 +1961,9 @@ void nonmovingMarkDeadWeaks (struct MarkQueue_ *queue, StgWeak **dead_weaks) { StgWeak *next_w; for (StgWeak *w = nonmoving_old_weak_ptr_list; w; w = next_w) { - ASSERT(!nonmovingClosureMarkedThisCycle((P_)(w->key))); + ASSERT(!nonmovingIsNowAlive(w->key)); nonmovingMarkDeadWeak(queue, w); - next_w = w ->link; + next_w = w->link; w->link = *dead_weaks; *dead_weaks = w; } ===================================== rts/sm/NonMovingMark.h ===================================== @@ -111,6 +111,11 @@ typedef struct { MarkQueue queue; } UpdRemSet; +// How much marking work we are allowed to perform +// See Note [Sync phase marking budget] in NonMoving.c +typedef int64_t MarkBudget; +#define UNLIMITED_MARK_BUDGET INT64_MIN + // Number of blocks to allocate for a mark queue #define MARK_QUEUE_BLOCKS 16 @@ -155,8 +160,14 @@ void markQueueAddRoot(MarkQueue* q, StgClosure** root); void initMarkQueue(MarkQueue *queue); void freeMarkQueue(MarkQueue *queue); -void nonmovingMark(struct MarkQueue_ *restrict queue); +void nonmovingMark(MarkBudget *budget, struct MarkQueue_ *restrict queue); +INLINE_HEADER void nonmovingMarkUnlimitedBudget(struct MarkQueue_ *restrict queue) { + MarkBudget budget = UNLIMITED_MARK_BUDGET; + nonmovingMark(&budget, queue); +} + +void nonmovingMarkWeakPtrList(struct MarkQueue_ *queue); bool nonmovingTidyWeaks(struct MarkQueue_ *queue); void nonmovingTidyThreads(void); void nonmovingMarkDeadWeaks(struct MarkQueue_ *queue, StgWeak **dead_weak_ptr_list); ===================================== rts/sm/Storage.c ===================================== @@ -323,7 +323,7 @@ void storageAddCapabilities (uint32_t from, uint32_t to) // Initialize NonmovingAllocators and UpdRemSets if (RtsFlags.GcFlags.useNonmoving) { nonmovingAddCapabilities(to); - for (i = 0; i < to; ++i) { + for (i = from; i < to; ++i) { init_upd_rem_set(&capabilities[i]->upd_rem_set); } } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7bf7a61cce31be34953c0a4c023caca74179bf18...c461f51017d9d4ae1842a8455ebf05ab71ee9b16 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7bf7a61cce31be34953c0a4c023caca74179bf18...c461f51017d9d4ae1842a8455ebf05ab71ee9b16 You're receiving 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 Dec 8 22:14:11 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 08 Dec 2022 17:14:11 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/bump-9.4-ci Message-ID: <639261b3c987f_224fca1d788774655144@gitlab.mail> Matthew Pickering pushed new branch wip/bump-9.4-ci at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bump-9.4-ci You're receiving 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 Dec 8 23:23:24 2022 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 08 Dec 2022 18:23:24 -0500 Subject: [Git][ghc/ghc][wip/az/exactprint-epalocation-for-anchor] 2 commits: EPA: remove anchor and anchor_op Message-ID: <639271ec2a093_224fca21999640661556@gitlab.mail> Alan Zimmerman pushed to branch wip/az/exactprint-epalocation-for-anchor at Glasgow Haskell Compiler / GHC Commits: 19bb5840 by Alan Zimmerman at 2022-12-08T21:15:55+00:00 EPA: remove anchor and anchor_op - - - - - 414268f5 by Alan Zimmerman at 2022-12-08T23:22:38+00:00 Remove Anchor = EpaLocation type synonym - - - - - 11 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs - utils/check-exact/Parsers.hs - utils/check-exact/Transform.hs - utils/check-exact/Types.hs - utils/check-exact/Utils.hs - utils/check-ppr/Main.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -4249,7 +4249,7 @@ glA = getLocA glN :: LocatedN a -> SrcSpan glN = getLocA -glR :: Located a -> Anchor +glR :: Located a -> EpaLocation glR la = spanAsAnchor$ getLoc la glAA :: Located a -> EpaLocation @@ -4258,16 +4258,16 @@ glAA = srcSpan2e . getLoc glRR :: Located a -> RealSrcSpan glRR = realSrcSpan . getLoc -glAR :: LocatedAn t a -> Anchor +glAR :: LocatedAn t a -> EpaLocation glAR la = spanAsAnchor $ getLocA la -glNR :: LocatedN a -> Anchor +glNR :: LocatedN a -> EpaLocation glNR ln = spanAsAnchor $ getLocA ln glNRR :: LocatedN a -> EpaLocation glNRR = srcSpan2e . getLocA -anc :: RealSrcSpan -> Anchor +anc :: RealSrcSpan -> EpaLocation anc r = EpaSpan r Strict.Nothing -- AZ:DANGER acs :: MonadP m => (EpAnnComments -> Located a) -> m (Located a) @@ -4397,7 +4397,7 @@ hsDoAnn :: Located a -> LocatedAn t b -> AnnKeywordId -> AnnList hsDoAnn (L l _) (L ll _) kw = AnnList (Just $ spanAsAnchor (locA ll)) Nothing Nothing [AddEpAnn kw (srcSpan2e l)] [] -listAsAnchor :: [LocatedAn t a] -> Anchor +listAsAnchor :: [LocatedAn t a] -> EpaLocation listAsAnchor [] = spanAsAnchor noSrcSpan listAsAnchor (L l _:_) = spanAsAnchor (locA l) ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -17,8 +17,7 @@ module GHC.Parser.Annotation ( TokenLocation(..), DeltaPos(..), deltaPos, getDeltaLine, - EpAnn(..), Anchor, AnchorOperation(..), - anchor, anchor_op, + EpAnn(..), spanAsAnchor, realSpanAsAnchor, noAnn, @@ -453,7 +452,7 @@ epaLocationRealSrcSpan (EpaDelta _ _) = panic "epaLocationRealSrcSpan" epaLocationFromSrcAnn :: SrcAnn ann -> EpaLocation epaLocationFromSrcAnn (SrcSpanAnn EpAnnNotUsed l) = EpaSpan (realSrcSpan l) Strict.Nothing -epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = EpaSpan (anchor anc) Strict.Nothing +epaLocationFromSrcAnn (SrcSpanAnn (EpAnn anc _ _) _) = anc instance Outputable EpaLocation where ppr (EpaSpan r _) = text "EpaSpan" <+> ppr r @@ -498,7 +497,7 @@ instance Outputable AddEpAnn where -- new AST fragments out of old ones, and have them still printed out -- in a precise way. data EpAnn ann - = EpAnn { entry :: !Anchor + = EpAnn { entry :: !EpaLocation -- ^ Base location for the start of the syntactic element -- holding the annotations. , anns :: !ann -- ^ Annotations added by the Parser @@ -525,37 +524,16 @@ data EpAnn ann -- , anchor_op :: AnchorOperation } -- deriving (Data, Eq, Show) -type Anchor = EpaLocation -- Transitional +-- type Anchor = EpaLocation -- Transitional -anchor :: Anchor -> RealSrcSpan -anchor (EpaSpan r _) = r -anchor (EpaDelta _ _) = panic "anchor" --- anchor (EpaDelta _ _) = placeholderRealSpan - --- AZ:TODO: remove AnchorOperation -anchor_op :: Anchor -> AnchorOperation -anchor_op (EpaSpan _ _) = UnchangedAnchor -anchor_op (EpaDelta dp _) = MovedAnchor dp - - --- | If tools modify the parsed source, the 'MovedAnchor' variant can --- directly provide the spacing for this item relative to the previous --- one when printing. This allows AST fragments with a particular --- anchor to be freely moved, without worrying about recalculating the --- appropriate anchor span. -data AnchorOperation = UnchangedAnchor - | MovedAnchor DeltaPos - deriving (Data, Eq, Show) - - -spanAsAnchor :: SrcSpan -> Anchor +spanAsAnchor :: SrcSpan -> EpaLocation spanAsAnchor (RealSrcSpan s b) = EpaSpan s b spanAsAnchor _ = noSpanAnchor -realSpanAsAnchor :: RealSrcSpan -> Anchor +realSpanAsAnchor :: RealSrcSpan -> EpaLocation realSpanAsAnchor s = EpaSpan s Strict.Nothing -- AZ:DANGER -noSpanAnchor :: Anchor +noSpanAnchor :: EpaLocation noSpanAnchor = EpaDelta (SameLine 0) [] -- --------------------------------------------------------------------- @@ -574,7 +552,7 @@ data EpAnnComments = EpaComments , followingComments :: ![LEpaComment] } deriving (Data, Eq) -type LEpaComment = GenLocated Anchor EpaComment +type LEpaComment = GenLocated EpaLocation EpaComment emptyComments :: EpAnnComments emptyComments = EpaComments [] @@ -680,7 +658,7 @@ data AnnListItem -- keywords such as 'where'. data AnnList = AnnList { - al_anchor :: Maybe Anchor, -- ^ start point of a list having layout + al_anchor :: Maybe EpaLocation, -- ^ start point of a list having layout al_open :: Maybe AddEpAnn, al_close :: Maybe AddEpAnn, al_rest :: [AddEpAnn], -- ^ context, such as 'where' keyword @@ -1022,7 +1000,7 @@ realSpanFromAnns as = go Nothing as go acc (AddEpAnn _ (EpaSpan s _):rest) = go (combine acc s) rest go acc (AddEpAnn _ (EpaDelta _ _):rest) = go acc rest -widenAnchor :: Anchor -> [AddEpAnn] -> Anchor +widenAnchor :: EpaLocation -> [AddEpAnn] -> EpaLocation widenAnchor (EpaSpan s b) as = EpaSpan (widenRealSpan s as) b widenAnchor a@(EpaDelta _ _) as = case (realSpanFromAnns as) of Nothing -> a @@ -1031,11 +1009,11 @@ widenAnchor a@(EpaDelta _ _) as = case (realSpanFromAnns as) of -- widenAnchorR :: Anchor -> RealSrcSpan -> Anchor -- widenAnchorR (Anchor s op) r = Anchor (combineRealSrcSpans s r) op -widenAnchorR :: Anchor -> RealSrcSpan -> Anchor +widenAnchorR :: EpaLocation -> RealSrcSpan -> EpaLocation widenAnchorR (EpaSpan s bs) r = EpaSpan (combineRealSrcSpans s r) bs widenAnchorR (EpaDelta _ _) r = EpaSpan r Strict.Nothing -- AZ:DANGER -widenAnchorS :: Anchor -> SrcSpan -> Anchor +widenAnchorS :: EpaLocation -> SrcSpan -> EpaLocation widenAnchorS (EpaSpan s bs) (RealSrcSpan r br) = EpaSpan (combineRealSrcSpans s r) (bs <> br) widenAnchorS (EpaDelta _ _) (RealSrcSpan r b) = EpaSpan r b widenAnchorS anc _ = anc @@ -1266,18 +1244,11 @@ instance (Outputable a) => Outputable (EpAnn a) where instance Outputable NoEpAnns where ppr NoEpAnns = text "NoEpAnns" --- instance Outputable Anchor where --- ppr (Anchor a o) = text "Anchor" <+> ppr a <+> ppr o - -instance Outputable AnchorOperation where - ppr UnchangedAnchor = text "UnchangedAnchor" - ppr (MovedAnchor d) = text "MovedAnchor" <+> ppr d - instance Outputable DeltaPos where ppr (SameLine c) = text "SameLine" <+> ppr c ppr (DifferentLine l c) = text "DifferentLine" <+> ppr l <+> ppr c -instance Outputable (GenLocated Anchor EpaComment) where +instance Outputable (GenLocated EpaLocation EpaComment) where ppr (L l c) = text "L" <+> ppr l <+> ppr c instance Outputable EpAnnComments where ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3674,6 +3674,10 @@ allocateComments ss comment_q = in (comment_q', reverse newAnns) +anchor :: EpaLocation -> RealSrcSpan +anchor (EpaSpan r _) = r +anchor (EpaDelta _ _) = panic "anchor" + allocatePriorComments :: RealSrcSpan -> [LEpaComment] ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -483,13 +483,13 @@ add_where an@(AddEpAnn _ (EpaSpan rs rb)) EpAnnNotUsed cs add_where (AddEpAnn _ (EpaDelta _ _)) _ _ = panic "add_where" -- EpaDelta should only be used for transformations -valid_anchor :: Anchor -> Bool +valid_anchor :: EpaLocation -> Bool valid_anchor (EpaSpan _ _) = True valid_anchor (EpaDelta _ _) = False -- If the decl list for where binds is empty, the anchor ends up -- invalid. In this case, use the parent one -patch_anchor :: RealSrcSpan -> Anchor -> Anchor +patch_anchor :: RealSrcSpan -> EpaLocation -> EpaLocation patch_anchor r (EpaDelta _ _) = EpaSpan r Strict.Nothing -- AZ:DANGER patch_anchor r1 (EpaSpan r0 b0) = EpaSpan r b0 where @@ -500,9 +500,9 @@ fixValbindsAnn EpAnnNotUsed = EpAnnNotUsed fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) = (EpAnn (widenAnchor anchor (map trailingAnnToAddEpAnn t)) (AnnList ma o c r t) cs) --- | The 'Anchor' for a stmtlist is based on either the location or +-- | The 'EpaLocation' for a stmtlist is based on either the location or -- the first semicolon annotion. -stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Maybe Anchor +stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Maybe EpaLocation stmtsAnchor (L (RealSrcSpan l br) ((ConsOL (AddEpAnn _ (EpaSpan r bs)) _), _)) = Just $ widenAnchorS (EpaSpan l br) (RealSrcSpan r bs) stmtsAnchor (L (RealSrcSpan l br) _) = Just $ EpaSpan l br @@ -1042,13 +1042,20 @@ checkTyClHdr is_cls ty newAnns :: SrcSpanAnnA -> EpAnn AnnParen -> SrcSpanAnnN newAnns (SrcSpanAnn EpAnnNotUsed l) (EpAnn as (AnnParen _ o c) cs) = let - lr = combineRealSrcSpans (realSrcSpan l) (anchor as) + lr = case as of + EpaSpan r _ -> combineRealSrcSpans (realSrcSpan l) r + EpaDelta _ _ -> realSrcSpan l -- This should not occur while parsing an = (EpAnn (EpaSpan lr Strict.Nothing) (NameAnn NameParens o (srcSpan2e l) c []) cs) --AZ:DANGER in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) newAnns _ EpAnnNotUsed = panic "missing AnnParen" newAnns (SrcSpanAnn (EpAnn ap (AnnListItem ta) csp) l) (EpAnn as (AnnParen _ o c) cs) = let - lr = combineRealSrcSpans (anchor ap) (anchor as) + -- lr = combineRealSrcSpans (anchor ap) (anchor as) + lr = case (ap, as) of + (EpaSpan pr _pb, EpaSpan sr _sb) -> combineRealSrcSpans pr sr + (EpaSpan pr _pb, EpaDelta _sr _sb) -> pr + (EpaDelta _ _pb, EpaSpan sr _sb) -> sr + (EpaDelta _ _pb, EpaDelta _r _sb) -> panic "newAnns" -- Should not happen while parsing an = (EpAnn (ap Semi.<> as) (NameAnn NameParens o (srcSpan2e l) c ta) (csp Semi.<> cs)) in SrcSpanAnn an (RealSrcSpan lr Strict.Nothing) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -110,6 +110,7 @@ defaultEPState = EPState , dPriorEndPosition = (1,1) , uAnchorSpan = badRealSrcSpan , uExtraDP = Nothing + , pAcceptSpan = False , epComments = [] , epCommentsApplied = [] } @@ -168,8 +169,15 @@ data EPState = EPState { uAnchorSpan :: !RealSrcSpan -- ^ in pre-changed AST -- reference frame, from -- Annotation - , uExtraDP :: !(Maybe Anchor) -- ^ Used to anchor a + , uExtraDP :: !(Maybe EpaLocation) -- ^ Used to anchor a -- list + , pAcceptSpan :: Bool -- ^ When we have processed an + -- entry of EpaDelta, accept the + -- next `EpaSpan` start as the + -- current output position. i.e. do + -- not advance epPos. Achieved by + -- setting dPriorEndPosition to the + -- end of the span. -- Print phase , epPos :: !Pos -- ^ Current output position @@ -213,14 +221,14 @@ data CanUpdateAnchor = CanUpdateAnchor | NoCanUpdateAnchor deriving (Eq, Show) -data Entry = Entry Anchor EpAnnComments FlushComments CanUpdateAnchor +data Entry = Entry EpaLocation EpAnnComments FlushComments CanUpdateAnchor | NoEntryVal -- | For flagging whether to capture comments in an EpaDelta or not data CaptureComments = CaptureComments | NoCaptureComments -mkEntry :: Anchor -> EpAnnComments -> Entry +mkEntry :: EpaLocation -> EpAnnComments -> Entry mkEntry anc cs = Entry anc cs NoFlushComments CanUpdateAnchor instance HasEntry (SrcSpanAnn' (EpAnn an)) where @@ -254,6 +262,7 @@ cua NoCanUpdateAnchor _ = return [] -- | "Enter" an annotation, by using the associated 'anchor' field as -- the new reference point for calculating all DeltaPos positions. +-- This is the heart of the exact printing process. -- -- This is combination of the ghc=exactprint Delta.withAST and -- Print.exactPC functions and effectively does the delta processing @@ -266,10 +275,19 @@ enterAnn NoEntryVal a = do debugM $ "enterAnn:done:NO ANN:p =" ++ show (p, astId a) return r enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do + acceptSpan <- getAcceptSpan + setAcceptSpan False + case anchor' of + EpaDelta _ _ -> setAcceptSpan True + EpaSpan _ _ -> return () p <- getPosP debugM $ "enterAnn:starting:(p,a) =" ++ show (p, astId a) -- debugM $ "enterAnn:(cs) =" ++ showGhc (cs) - let curAnchor = anchor anchor' -- As a base for the current AST element + -- let curAnchor = anchor anchor' -- As a base for the current AST element + priorAnchor <- getAnchorU + let curAnchor = case anchor' of -- As a base for the current AST element + EpaSpan r _ -> r + EpaDelta _ _ -> priorAnchor debugM $ "enterAnn:(curAnchor):=" ++ show (rs2range curAnchor) case canUpdateAnchor of CanUpdateAnchor -> pushAppliedComments @@ -279,14 +297,17 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do printComments curAnchor priorCs <- cua canUpdateAnchor takeAppliedComments -- no pop -- ------------------------- - case anchor_op anchor' of - MovedAnchor dp -> do + case anchor' of + EpaDelta dp _ -> do debugM $ "enterAnn: MovedAnchor:" ++ show dp -- Set the original anchor as prior end, so the rest of this AST -- fragment has a reference setPriorEndNoLayoutD (ss2pos curAnchor) _ -> do - return () + if acceptSpan + then setPriorEndNoLayoutD (ss2pos curAnchor) + else return () + -- ------------------------- if ((fst $ fst $ rs2range curAnchor) >= 0) then @@ -318,8 +339,8 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do -- changed. off (ss2delta priorEndAfterComments curAnchor) debugM $ "enterAnn: (edp',off,priorEndAfterComments,curAnchor):" ++ show (edp',off,priorEndAfterComments,rs2range curAnchor) - let edp'' = case anchor_op anchor' of - MovedAnchor dp -> dp + let edp'' = case anchor' of + EpaDelta dp _ -> dp _ -> edp' -- --------------------------------------------- -- let edp = edp'' @@ -341,7 +362,6 @@ enterAnn (Entry anchor' cs flush canUpdateAnchor) a = do debugM $ "enterAnn.dPriorEndPosition:spanStart=" ++ show spanStart modify (\s -> s { dPriorEndPosition = spanStart } )) - debugM $ "enterAnn: (anchor_op, curAnchor):" ++ show (anchor_op anchor', rs2range curAnchor) debugM $ "enterAnn: (dLHS,spanStart,pec,edp)=" ++ show (off,spanStart,priorEndAfterComments,edp) p0 <- getPosP d <- getPriorEndD @@ -468,7 +488,7 @@ withPpr a = do -- 'ppr'. class (Typeable a) => ExactPrint a where getAnnotationEntry :: a -> Entry - setAnnotationAnchor :: a -> Anchor -> EpAnnComments -> a + setAnnotationAnchor :: a -> EpaLocation -> EpAnnComments -> a exact :: (Monad m, Monoid w) => a -> EP w m a -- --------------------------------------------------------------------- @@ -783,7 +803,7 @@ limportDeclAnnPackage k annImp = fmap (\new -> annImp { importDeclAnnPackage = n -- data AnnList -- = AnnList { --- al_anchor :: Maybe Anchor, -- ^ start point of a list having layout +-- al_anchor :: Maybe EpaLocation, -- ^ start point of a list having layout -- al_open :: Maybe AddEpAnn, -- al_close :: Maybe AddEpAnn, -- al_rest :: [AddEpAnn], -- ^ context, such as 'where' keyword @@ -1235,12 +1255,12 @@ printComments ss = do printOneComment :: (Monad m, Monoid w) => Comment -> EP w m () printOneComment c@(Comment _str loc _r _mo) = do debugM $ "printOneComment:c=" ++ showGhc c - dp <-case anchor_op loc of - MovedAnchor dp -> return dp - _ -> do + dp <-case loc of + EpaDelta dp _ -> return dp + EpaSpan r _ -> do pe <- getPriorEndD - let dp = ss2delta pe (anchor loc) - debugM $ "printOneComment:(dp,pe,anchor loc)=" ++ showGhc (dp,pe,ss2pos $ anchor loc) + let dp = ss2delta pe r + debugM $ "printOneComment:(dp,pe,epaLocationToPos loc)=" ++ showGhc (dp,pe,epaLocationToPos loc) adjustDeltaForOffsetM dp mep <- getExtraDP dp' <- case mep of @@ -1256,7 +1276,7 @@ printOneComment c@(Comment _str loc _r _mo) = do -- End of debug printing -- setPriorEndD (ss2posEnd (anchor loc)) updateAndApplyComment c dp' - printQueuedComment (anchor loc) c dp' + printQueuedComment c dp' -- | For comment-related deltas starting on a new line we have an -- off-by-one problem. Adjust @@ -1334,7 +1354,7 @@ commentAllocation ss = do -- RealSrcSpan, which affects comparison, as the Ord instance for -- RealSrcSpan compares the file first. So we sort via ss2pos -- TODO: this is inefficient, use Pos all the way through - let (earlier,later) = partition (\(Comment _str loc _r _mo) -> (ss2pos $ anchor loc) <= (ss2pos ss)) cs + let (earlier,later) = partition (\(Comment _str loc _r _mo) -> (epaLocationToPos loc) <= (ss2pos ss)) cs putUnallocatedComments later -- debugM $ "commentAllocation:(ss,earlier,later)" ++ show (rs2range ss,earlier,later) return earlier @@ -2967,7 +2987,7 @@ instance ExactPrint (HsExpr GhcPs) where exact (HsUntypedBracket an (DecBrL a e)) = do an0 <- markEpAnnLMS an lidl AnnOpen (Just "[d|") - an1 <- markEpAnnL an lidl AnnOpenC + an1 <- markEpAnnL an0 lidl AnnOpenC e' <- markAnnotated e an2 <- markEpAnnL an1 lidl AnnCloseC an3 <- markEpAnnL an2 lidl AnnCloseQ -- "|]" @@ -4136,7 +4156,7 @@ instance ExactPrint (LocatedN RdrName) where locFromAdd :: AddEpAnn -> EpaLocation locFromAdd (AddEpAnn _ loc) = loc -printUnicode :: (Monad m, Monoid w) => Anchor -> RdrName -> EP w m Anchor +printUnicode :: (Monad m, Monoid w) => EpaLocation -> RdrName -> EP w m EpaLocation printUnicode anc n = do let str = case (showPprUnsafe n) of -- TODO: unicode support? @@ -4819,8 +4839,8 @@ isGoodDeltaWithOffset dp colOffset = isGoodDelta (deltaPos l c) -- | Print a comment, using the current layout offset to convert the -- @DeltaPos@ to an absolute position. -printQueuedComment :: (Monad m, Monoid w) => RealSrcSpan -> Comment -> DeltaPos -> EP w m () -printQueuedComment _loc Comment{commentContents} dp = do +printQueuedComment :: (Monad m, Monoid w) => Comment -> DeltaPos -> EP w m () +printQueuedComment Comment{commentContents} dp = do p <- getPosP d <- getPriorEndD colOffset <- getLayoutOffsetP @@ -4872,10 +4892,10 @@ setPosP l = do -- debugM $ "setPosP:" ++ show l modify (\s -> s {epPos = l}) -getExtraDP :: (Monad m, Monoid w) => EP w m (Maybe Anchor) +getExtraDP :: (Monad m, Monoid w) => EP w m (Maybe EpaLocation) getExtraDP = gets uExtraDP -setExtraDP :: (Monad m, Monoid w) => Maybe Anchor -> EP w m () +setExtraDP :: (Monad m, Monoid w) => Maybe EpaLocation -> EP w m () setExtraDP md = do debugM $ "setExtraDP:" ++ show md modify (\s -> s {uExtraDP = md}) @@ -4886,6 +4906,13 @@ getPriorEndD = gets dPriorEndPosition getAnchorU :: (Monad m, Monoid w) => EP w m RealSrcSpan getAnchorU = gets uAnchorSpan +getAcceptSpan ::(Monad m, Monoid w) => EP w m Bool +getAcceptSpan = gets pAcceptSpan + +setAcceptSpan ::(Monad m, Monoid w) => Bool -> EP w m () +setAcceptSpan f = + modify (\s -> s { pAcceptSpan = f }) + setPriorEndD :: (Monad m, Monoid w) => Pos -> EP w m () setPriorEndD pe = do setPriorEndNoLayoutD pe ===================================== utils/check-exact/Main.hs ===================================== @@ -54,7 +54,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/epw/_buil -- "../../testsuite/tests/ghc-api/exactprint/LocToName.hs" (Just changeLocToName) -- "../../testsuite/tests/ghc-api/exactprint/LetIn1.hs" (Just changeLetIn1) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn4.hs" (Just changeWhereIn4) - -- "../../testsuite/tests/ghc-api/exactprint/AddDecl1.hs" (Just changeAddDecl1) + "../../testsuite/tests/ghc-api/exactprint/AddDecl1.hs" (Just changeAddDecl1) -- "../../testsuite/tests/ghc-api/exactprint/AddDecl2.hs" (Just changeAddDecl2) -- "../../testsuite/tests/ghc-api/exactprint/AddDecl3.hs" (Just changeAddDecl3) -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls.hs" (Just changeLocalDecls) @@ -194,7 +194,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/epw/_buil -- "../../testsuite/tests/printer/Test19834.hs" Nothing -- "../../testsuite/tests/printer/Test19840.hs" Nothing -- "../../testsuite/tests/printer/Test19850.hs" Nothing - "../../testsuite/tests/printer/Test20258.hs" Nothing + -- "../../testsuite/tests/printer/Test20258.hs" Nothing -- "../../testsuite/tests/printer/PprLinearArrow.hs" Nothing -- "../../testsuite/tests/printer/PprSemis.hs" Nothing -- "../../testsuite/tests/printer/PprEmptyMostly.hs" Nothing ===================================== utils/check-exact/Parsers.hs ===================================== @@ -64,6 +64,10 @@ import qualified GHC.Types.SrcLoc as GHC import qualified GHC.LanguageExtensions as LangExt +import qualified GHC.Data.Strict as Strict + +import Types + -- --------------------------------------------------------------------- -- | Wrapper function which returns Annotations along with the parsed @@ -289,7 +293,8 @@ fixModuleTrailingComments (GHC.L l p) = GHC.L l p' let pc = GHC.priorComments cs fc = GHC.getFollowingComments cs - bf (GHC.L anc _) = GHC.anchor anc > ss + -- bf (GHC.L anc _) = GHC.anchor anc > ss + bf (GHC.L anc _) = compareAnchor anc (GHC.EpaSpan ss Strict.Nothing) == GT (prior,f) = break bf fc cs'' = GHC.EpaCommentsBalanced (pc <> prior) f in cs'' ===================================== utils/check-exact/Transform.hs ===================================== @@ -202,6 +202,7 @@ captureLineSpacing (de1:d2:ds) = de1:captureLineSpacing (d2':ds) d2' = setEntryDP d2 (deltaPos (l2-l1) 0) -- --------------------------------------------------------------------- + captureTypeSigSpacing :: LHsDecl GhcPs -> LHsDecl GhcPs captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (HsWC xw ty)))) = (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc' rs') cs) ns (HsWC xw ty')))) @@ -211,10 +212,10 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (EpAnn anc (AnnSig dc rs') cs) ns (H AddEpAnn kw dca = dc `debug` ("captureTypeSigSpacing: anc'=" ++ (showAst $ last ns)) rd = case last ns of - L (SrcSpanAnn EpAnnNotUsed ll) _ -> realSrcSpan ll - L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor? + L (SrcSpanAnn EpAnnNotUsed ll) _ -> ss2posEnd $ realSrcSpan ll + L (SrcSpanAnn (EpAnn anc' _ _) _) _ -> epaLocationToPosEnd anc' dc' = case dca of - EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta (ss2posEnd rd) r) []) + EpaSpan r _ -> AddEpAnn kw (EpaDelta (ss2delta rd r) []) EpaDelta _ _ -> AddEpAnn kw dca -- --------------------------------- @@ -538,7 +539,7 @@ balanceCommentsFB (L lf (FunBind x n (MG o (L lm matches)))) second = do -- + move the interior ones to the first match, -- + move the trailing ones to the last match. let - split = splitCommentsEnd (realSrcSpan $ locA lf) (epAnnComments $ ann lf) + split = splitCommentsEnd (srcAnn2epaLocation lf) (epAnnComments $ ann lf) split2 = splitCommentsStart (realSrcSpan $ locA lf) (EpaComments (sortEpaComments $ priorComments split)) before = sortEpaComments $ priorComments split2 @@ -595,7 +596,7 @@ balanceCommentsMatch (L l (Match am mctxt pats (GRHSs xg grhss binds))) = do -- --------------------------------- (EpAnn anc an lgc) = ag - lgc' = splitCommentsEnd (realSrcSpan $ locA lg) $ addCommentOrigDeltas lgc + lgc' = splitCommentsEnd (srcAnn2epaLocation lg) $ addCommentOrigDeltas lgc ag' = if moved then EpAnn anc an lgc' else EpAnn anc an (lgc' <> (EpaCommentsBalanced [] move)) @@ -672,50 +673,49 @@ balanceComments' la1 la2 = do la2' = L an2' s -- | Like commentsDeltas, but calculates the delta from the end of the anchor, not the start -trailingCommentsDeltas :: RealSrcSpan -> [LEpaComment] +trailingCommentsDeltas :: EpaLocation -> [LEpaComment] -> [(Int, LEpaComment)] trailingCommentsDeltas _ [] = [] -trailingCommentsDeltas anc (la@(L l _):las) - = deltaComment anc la : trailingCommentsDeltas (anchor l) las +trailingCommentsDeltas r (la@(L l _):las) + = deltaComment r la : trailingCommentsDeltas l las where - deltaComment anc' (L loc c) = (abs(ll - al), L loc c) + deltaComment r' (L loc c) = (abs(ll - al), L loc c) where - (al,_) = ss2posEnd anc' - (ll,_) = ss2pos (anchor loc) + (al,_) = epaLocationToPosEnd r' + (ll,_) = epaLocationToPos loc -- AZ:TODO: this is identical to commentsDeltas -priorCommentsDeltas :: RealSrcSpan -> [LEpaComment] +priorCommentsDeltas :: EpaLocation -> [LEpaComment] -> [(Int, LEpaComment)] priorCommentsDeltas anc cs = go anc (reverse $ sortEpaComments cs) where - go :: RealSrcSpan -> [LEpaComment] -> [(Int, LEpaComment)] + go :: EpaLocation -> [LEpaComment] -> [(Int, LEpaComment)] go _ [] = [] - go anc' (la@(L l _):las) = deltaComment anc' la : go (anchor l) las + go anc' (la@(L l _):las) = deltaComment anc' la : go l las - deltaComment :: RealSrcSpan -> LEpaComment -> (Int, LEpaComment) + deltaComment :: EpaLocation -> LEpaComment -> (Int, LEpaComment) deltaComment anc' (L loc c) = (abs(ll - al), L loc c) where - (al,_) = ss2pos anc' - (ll,_) = ss2pos (anchor loc) - + (al,_) = epaLocationToPos anc' + (ll,_) = epaLocationToPos loc -- --------------------------------------------------------------------- -- | Split comments into ones occuring before the end of the reference -- span, and those after it. -splitCommentsEnd :: RealSrcSpan -> EpAnnComments -> EpAnnComments +splitCommentsEnd :: EpaLocation -> EpAnnComments -> EpAnnComments splitCommentsEnd p (EpaComments cs) = cs' where - cmp (L (EpaSpan l _b) _) = ss2pos l > ss2posEnd p - cmp (L (EpaDelta _ _) _) = ss2pos placeholderRealSpan > ss2posEnd p + cmp (L (EpaSpan l _b) _) = ss2pos l > epaLocationToPosEnd p + cmp (L (EpaDelta _ _) _) = ss2pos placeholderRealSpan > epaLocationToPosEnd p (before, after) = break cmp cs cs' = case after of [] -> EpaComments cs _ -> EpaCommentsBalanced before after splitCommentsEnd p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' where - cmp (L (EpaSpan l _b) _) = ss2pos l > ss2posEnd p - cmp (L (EpaDelta _ _) _) = ss2pos placeholderRealSpan > ss2posEnd p + cmp (L (EpaSpan l _b) _) = ss2pos l > epaLocationToPosEnd p + cmp (L (EpaDelta _ _) _) = ss2pos placeholderRealSpan > epaLocationToPosEnd p (before, after) = break cmp cs cs' = before ts' = after <> ts @@ -745,10 +745,10 @@ splitCommentsStart p (EpaCommentsBalanced cs ts) = EpaCommentsBalanced cs' ts' moveLeadingComments :: (Data t, Data u, Monoid t, Monoid u) => LocatedAn t a -> SrcAnn u -> (LocatedAn t a, SrcAnn u) moveLeadingComments from@(L (SrcSpanAnn EpAnnNotUsed _) _) to = (from, to) -moveLeadingComments (L la a) lb = (L la' a, lb') +moveLeadingComments (L la@(SrcSpanAnn (EpAnn l _ _)_) a) lb = (L la' a, lb') `debug` ("moveLeadingComments: (before, after, la', lb'):" ++ showAst (before, after, la', lb')) where - split = splitCommentsEnd (realSrcSpan $ locA la) (epAnnComments $ ann la) + split = splitCommentsEnd l (epAnnComments $ ann la) before = sortEpaComments $ priorComments split after = sortEpaComments $ getFollowingComments split @@ -777,11 +777,11 @@ addCommentOrigDeltasAnn (EpAnn e a cs) = EpAnn e a (addCommentOrigDeltas cs) -- TODO: this is replicating functionality in ExactPrint. Sort out the -- import loop` -anchorFromLocatedA :: LocatedA a -> RealSrcSpan -anchorFromLocatedA (L (SrcSpanAnn an loc) _) +anchorFromLocatedA :: LocatedA a -> EpaLocation +anchorFromLocatedA (L (SrcSpanAnn an _) _) = case an of - EpAnnNotUsed -> realSrcSpan loc - (EpAnn anc _ _) -> anchor anc + EpAnnNotUsed -> EpaDelta (SameLine 0) [] + (EpAnn anc _ _) -> anc -- | A GHC comment includes the span of the preceding token. Take an -- original comment, and convert the 'Anchor to have a have a @@ -836,7 +836,7 @@ balanceSameLineComments (L la (Match anm mctxt pats (GRHSs x grhss lb))) = do (csp,csf) = case anc1 of EpaComments cs -> ([],cs) EpaCommentsBalanced p f -> (p,f) - (move',stay') = break (simpleBreak 0) (trailingCommentsDeltas (anchor anc) csf) + (move',stay') = break (simpleBreak 0) (trailingCommentsDeltas anc csf) move = map snd move' stay = map snd stay' cs1 = EpaCommentsBalanced csp stay @@ -918,8 +918,12 @@ insertAt :: (HasDecls ast) insertAt f t decl = do oldDecls <- hsDecls t oldDeclsb <- balanceCommentsList oldDecls + `debug` ( "oldDecls:" ++ showAst oldDecls) let oldDecls' = map commentsOrigDeltasDecl oldDeclsb - replaceDecls t (f decl oldDecls') + `debug` ("oldDeclsb:" ++ showAst oldDeclsb) + r <- replaceDecls t (f decl oldDecls') + `debug` ("oldDecls':" ++ showAst oldDecls') + return r -- |Insert a declaration at the beginning or end of the subdecls of the given -- AST item ===================================== utils/check-exact/Types.hs ===================================== @@ -31,7 +31,7 @@ data Rigidity = NormalLayout | RigidLayout deriving (Eq, Ord, Show) data Comment = Comment { commentContents :: !String -- ^ The contents of the comment including separators - , commentAnchor :: !Anchor + , commentAnchor :: !EpaLocation , commentPriorTok :: !RealSrcSpan , commentOrigin :: !(Maybe AnnKeywordId) -- ^ We sometimes turn syntax into comments in order to process them properly. } @@ -45,10 +45,20 @@ instance Ord Comment where -- When we have CPP injected comments with a fake filename, or LINE -- pragma, the file name changes, so we need to compare the -- locations only, with out the filename. - compare (Comment _ ss1 _ _) (Comment _ ss2 _ _) = compare (ss2pos $ anchor ss1) (ss2pos $ anchor ss2) + compare (Comment _ ss1 _ _) (Comment _ ss2 _ _) = compareAnchor ss1 ss2 where ss2pos ss = (srcSpanStartLine ss,srcSpanStartCol ss) +compareAnchor :: EpaLocation -> EpaLocation -> Ordering +compareAnchor a1 a2 = go a1 a2 + where + ss2pos ss = (srcSpanStartLine ss,srcSpanStartCol ss) + + go (EpaSpan r1 _) (EpaSpan r2 _) = compare (ss2pos r1) (ss2pos r2) + go (EpaSpan _ _) (EpaDelta _ _) = GT + go (EpaDelta _ _) (EpaSpan _ _) = LT + go (EpaDelta _ _) (EpaDelta _ _) = EQ + instance Outputable Comment where ppr x = text (show x) ===================================== utils/check-exact/Utils.hs ===================================== @@ -47,8 +47,8 @@ import Types -- |Global switch to enable debug tracing in ghc-exactprint Delta / Print debugEnabledFlag :: Bool --- debugEnabledFlag = True -debugEnabledFlag = False +debugEnabledFlag = True +-- debugEnabledFlag = False -- |Provide a version of trace that comes at the end of the line, so it can -- easily be commented out when debugging different things. @@ -136,6 +136,18 @@ adjustDeltaForOffset (LayoutStartCol colOffset) (DifferentLine l c) -- --------------------------------------------------------------------- +srcAnn2epaLocation :: SrcAnn a -> EpaLocation +srcAnn2epaLocation (SrcSpanAnn EpAnnNotUsed _) = EpaDelta (SameLine 0) [] +srcAnn2epaLocation (SrcSpanAnn (EpAnn anc _ _) _) = anc + +epaLocationToPos :: EpaLocation -> Pos +epaLocationToPos (EpaSpan r _) = ss2pos r +epaLocationToPos (EpaDelta _ _) = (0,0) + +epaLocationToPosEnd :: EpaLocation -> Pos +epaLocationToPosEnd (EpaSpan r _) = ss2posEnd r +epaLocationToPosEnd (EpaDelta _ _) = (0,0) + ss2pos :: RealSrcSpan -> Pos ss2pos ss = (srcSpanStartLine ss,srcSpanStartCol ss) @@ -229,11 +241,11 @@ mkEpaComments priorCs postCs comment2LEpaComment :: Comment -> LEpaComment comment2LEpaComment (Comment s anc r _mk) = mkLEpaComment s anc r -mkLEpaComment :: String -> Anchor -> RealSrcSpan -> LEpaComment +mkLEpaComment :: String -> EpaLocation -> RealSrcSpan -> LEpaComment mkLEpaComment "" anc r = (L anc (GHC.EpaComment (EpaEofComment) r)) mkLEpaComment s anc r = (L anc (GHC.EpaComment (EpaLineComment s) r)) -mkComment :: String -> Anchor -> RealSrcSpan -> Comment +mkComment :: String -> EpaLocation -> RealSrcSpan -> Comment mkComment c anc r = Comment c anc r Nothing -- Windows comments include \r in them from the lexer. @@ -244,7 +256,7 @@ normaliseCommentText (x:xs) = x:normaliseCommentText xs -- |Must compare without span filenames, for CPP injected comments with fake filename cmpComments :: Comment -> Comment -> Ordering -cmpComments (Comment _ l1 _ _) (Comment _ l2 _ _) = compare (ss2pos $ anchor l1) (ss2pos $ anchor l2) +cmpComments (Comment _ l1 _ _) (Comment _ l2 _ _) = compareAnchor l1 l2 -- |Sort, comparing without span filenames, for CPP injected comments with fake filename sortComments :: [Comment] -> [Comment] @@ -254,7 +266,7 @@ sortComments cs = sortBy cmpComments cs sortEpaComments :: [LEpaComment] -> [LEpaComment] sortEpaComments cs = sortBy cmp cs where - cmp (L l1 _) (L l2 _) = compare (ss2pos $ anchor l1) (ss2pos $ anchor l2) + cmp (L l1 _) (L l2 _) = compareAnchor l1 l2 -- | Makes a comment which originates from a specific keyword. mkKWComment :: AnnKeywordId -> EpaLocation -> Comment @@ -271,8 +283,8 @@ isKWComment c = isJust (commentOrigin c) noKWComments :: [Comment] -> [Comment] noKWComments = filter (\c -> not (isKWComment c)) -sortAnchorLocated :: [GenLocated Anchor a] -> [GenLocated Anchor a] -sortAnchorLocated = sortBy (compare `on` (anchor . getLoc)) +sortAnchorLocated :: [GenLocated EpaLocation a] -> [GenLocated EpaLocation a] +sortAnchorLocated = sortBy (compareAnchor `on` getLoc) -- | Calculates the distance from the start of a string to the end of -- a string. @@ -325,11 +337,12 @@ name2String = showPprUnsafe locatedAnAnchor :: LocatedAn a t -> RealSrcSpan locatedAnAnchor (L (SrcSpanAnn EpAnnNotUsed l) _) = realSrcSpan l -locatedAnAnchor (L (SrcSpanAnn (EpAnn a _ _) _) _) = anchor a +locatedAnAnchor (L (SrcSpanAnn (EpAnn (EpaSpan r _) _ _) _) _) = r +locatedAnAnchor _ = error "locatedAnAnchor" -- --------------------------------------------------------------------- -setAnchorAn :: (Default an) => LocatedAn an a -> Anchor -> EpAnnComments -> LocatedAn an a +setAnchorAn :: (Default an) => LocatedAn an a -> EpaLocation -> EpAnnComments -> LocatedAn an a setAnchorAn (L (SrcSpanAnn EpAnnNotUsed l) a) anc cs = (L (SrcSpanAnn (EpAnn anc Orphans.def cs) l) a) -- `debug` ("setAnchorAn: anc=" ++ showAst anc) @@ -337,15 +350,15 @@ setAnchorAn (L (SrcSpanAnn (EpAnn _ an _) l) a) anc cs = (L (SrcSpanAnn (EpAnn anc an cs) l) a) -- `debug` ("setAnchorAn: anc=" ++ showAst anc) -setAnchorEpa :: (Default an) => EpAnn an -> Anchor -> EpAnnComments -> EpAnn an +setAnchorEpa :: (Default an) => EpAnn an -> EpaLocation -> EpAnnComments -> EpAnn an setAnchorEpa EpAnnNotUsed anc cs = EpAnn anc Orphans.def cs setAnchorEpa (EpAnn _ an _) anc cs = EpAnn anc an cs -setAnchorEpaL :: EpAnn AnnList -> Anchor -> EpAnnComments -> EpAnn AnnList +setAnchorEpaL :: EpAnn AnnList -> EpaLocation -> EpAnnComments -> EpAnn AnnList setAnchorEpaL EpAnnNotUsed anc cs = EpAnn anc mempty cs setAnchorEpaL (EpAnn _ an _) anc cs = EpAnn anc (an {al_anchor = Nothing}) cs -setAnchorHsModule :: HsModule GhcPs -> Anchor -> EpAnnComments -> HsModule GhcPs +setAnchorHsModule :: HsModule GhcPs -> EpaLocation -> EpAnnComments -> HsModule GhcPs setAnchorHsModule hsmod anc cs = hsmod { hsmodExt = (hsmodExt hsmod) {hsmodAnn = an'} } where -- anc' = anc { anchor_op = UnchangedAnchor } @@ -378,7 +391,7 @@ addEpAnnLoc (AddEpAnn _ l) = l -- TODO: move this to GHC -- AZ:Remove this -anchorToEpaLocation :: Anchor -> EpaLocation +anchorToEpaLocation :: EpaLocation -> EpaLocation anchorToEpaLocation = id -- --------------------------------------------------------------------- @@ -406,7 +419,7 @@ To be absolutely sure, we make the delta versions use -ve values. -} -hackSrcSpanToAnchor :: SrcSpan -> Anchor +hackSrcSpanToAnchor :: SrcSpan -> EpaLocation hackSrcSpanToAnchor (UnhelpfulSpan s) = error $ "hackSrcSpanToAnchor : UnhelpfulSpan:" ++ show s hackSrcSpanToAnchor (RealSrcSpan r b) = case b of @@ -418,7 +431,7 @@ hackSrcSpanToAnchor (RealSrcSpan r b) _ -> EpaSpan r b -- TODO:AZ get rid of this -hackAnchorToSrcSpan :: Anchor -> SrcSpan +hackAnchorToSrcSpan :: EpaLocation -> SrcSpan hackAnchorToSrcSpan (EpaSpan r b) = RealSrcSpan r b hackAnchorToSrcSpan _ = error $ "hackAnchorToSrcSpan" ===================================== utils/check-ppr/Main.hs ===================================== @@ -102,6 +102,10 @@ getPragmas (L _ (HsModule { hsmodExt = XModulePs { hsmodAnn = anns' } })) = prag pragmas = filter (\c -> isPrefixOf "{-#" c ) comments' pragmaStr = intercalate "\n" pragmas +anchor :: EpaLocation -> (Int,Int) +anchor (EpaSpan r _) = (srcSpanStartLine r,srcSpanStartCol r) +anchor (EpaDelta _ _) = (0,0) -- Should not happen for newly-parsed files + pp :: (Outputable a) => a -> String pp a = showPprUnsafe a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/15c72cf788ca8e7f31663eaedb8201ba33e0ec50...414268f575a2ce424b7ac994d32155444a2a6ac0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/15c72cf788ca8e7f31663eaedb8201ba33e0ec50...414268f575a2ce424b7ac994d32155444a2a6ac0 You're receiving 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 Dec 8 23:33:32 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Thu, 08 Dec 2022 18:33:32 -0500 Subject: [Git][ghc/ghc][wip/T22492] Document TH splices' interaction with INCOHERENT instances Message-ID: <6392744c91bc5_224fca605f46623cc@gitlab.mail> Ryan Scott pushed to branch wip/T22492 at Glasgow Haskell Compiler / GHC Commits: 2e3de14f by Ryan Scott at 2022-12-08T18:33:01-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1 changed file: - docs/users_guide/exts/template_haskell.rst Changes: ===================================== docs/users_guide/exts/template_haskell.rst ===================================== @@ -285,6 +285,14 @@ The :extension:`TemplateHaskellQuotes` extension is considered safe under includes all top-level definitions down to but not including the first top-level declaration splice. + Each group is compiled just like a separately compiled module. That is: + + - Later groups can "see" declarations, and instance declarations, from + earlier groups; + + - But earlier groups cannot "see" declarations, or instance declarations, + from later groups. + Each declaration group is mutually recursive only within the group. Declaration groups can refer to definitions within previous groups, but not later ones. @@ -375,6 +383,70 @@ The :extension:`TemplateHaskellQuotes` extension is considered safe under 3. Since the declaration group containing ``D`` is in the previous declaration group, the splice ``$(th2 ...)`` *can* refer to ``D``. + Note that in some cases, the presence or absence of top-level declaration + splices can affect the *runtime* behavior of the surrounding code, because + the resolution of instances may differ depending on their visiblity. One + case where this arises is with + :ref:`incoherent instances ` :: + + module Main where + + main :: IO () + main = do + let i :: Int + i = 42 + putStrLn (m1 i) + putStrLn (m2 i) + + class C1 a where + m1 :: a -> String + + instance {-# INCOHERENT #-} C1 a where + m1 _ = "C1 incoherent" + + instance C1 Int where + m1 = show + + class C2 a where + m2 :: a -> String + + instance {-# INCOHERENT #-} C2 a where + m2 _ = "C2 incoherent" + + $(return []) + + instance C2 Int where + m2 = show + + Here, ``C1`` and ``C2`` are the same classes with nearly identical + instances. The only significant differences between ``C1`` and ``C2``, aside + from the minor name change, is that all of ``C1``'s instances are defined + within the same declaration group, whereas the ``C2 Int`` instance is put in + a separate declaration group from the incoherent ``C2 a`` instance. This has + an impact on the runtime behavior of the ``main`` function :: + + $ runghc Main.hs + 42 + C2 incoherent + + Note that ``m1 i`` returns ``"42"``, but ``m2 i`` returns + ``"C2 incoherent"``. When each of these expressions are typechecked, GHC + must figure out which ``C1 Int`` and ``C2 Int`` instances to use: + + 1. When resolving the ``C1 Int`` instance, GHC discovers two possible + instances in the same declaration group: the incoherent ``C1 a`` instance + and the non-incoherent ``C1 Int`` instance. According to the instance + search rules described in :ref:`instance-overlap`, because there is + exactly one non-incoherent instance to pick, GHC will choose the + ``C1 Int`` instance. As a result, ``m1 i`` will be equivalent to + ``show i`` (i.e., ``"42"``). + 2. When resolving the ``C2 Int`` instance, GHC only discovers one instance + in the same declaration group: the incoherent ``C2 a`` instance. Note + that GHC does *not* see the ``C2 Int`` instance, as that is in a later + declaration group that is made separate by the intervening declaration + splice. As a result, GHC will choose the ``C2 a`` instance, making + ``m2 i`` equivalent to ``"C2 incoherent"``. + - Expression quotations accept most Haskell language constructs. However, there are some GHC-specific extensions which expression quotations currently do not support, including View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2e3de14fea00353bf361646a76a2aaa9c2e5cbc1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2e3de14fea00353bf361646a76a2aaa9c2e5cbc1 You're receiving 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 Dec 8 23:49:04 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 08 Dec 2022 18:49:04 -0500 Subject: [Git][ghc/ghc][wip/T22264] 5 commits: nonmoving: Move current segment array into Capability Message-ID: <639277f050a1d_224fca18f7d7546655b9@gitlab.mail> Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC Commits: 15a16dd6 by Ben Gamari at 2022-12-06T15:55:05-05:00 nonmoving: Move current segment array into Capability - - - - - 97de202f by Ben Gamari at 2022-12-06T15:55:05-05:00 rts: Fix typo - - - - - 74eff8f3 by Ben Gamari at 2022-12-06T15:55:05-05:00 n_capabilities - - - - - b854c8fd by Ben Gamari at 2022-12-06T15:55:05-05:00 rts: Reenable assertion - - - - - 3d7baa30 by Ben Gamari at 2022-12-08T17:28:44-05:00 nonmoving: Sync-phase mark budgeting Here we significantly improve the bound on sync phase pause times by imposing a limit on the amount of work that we can perform during the sync. If we find that we have exceeded our marking budget then we allow the mutators to resume, return to concurrent marking, and try synchronizing again later. - - - - - 14 changed files: - rts/Capability.c - rts/Capability.h - rts/Schedule.c - rts/Trace.c - rts/Trace.h - rts/sm/GC.c - rts/sm/NonMoving.c - rts/sm/NonMoving.h - rts/sm/NonMovingCensus.c - rts/sm/NonMovingCensus.h - rts/sm/NonMovingMark.c - rts/sm/NonMovingMark.h - rts/sm/Sanity.c - rts/sm/Storage.c Changes: ===================================== rts/Capability.c ===================================== @@ -1257,6 +1257,9 @@ freeCapability (Capability *cap) { stgFree(cap->mut_lists); stgFree(cap->saved_mut_lists); + if (cap->current_segments) { + stgFree(cap->current_segments); + } #if defined(THREADED_RTS) freeSparkPool(cap->sparks); #endif ===================================== rts/Capability.h ===================================== @@ -89,6 +89,9 @@ struct Capability_ { // The update remembered set for the non-moving collector UpdRemSet upd_rem_set; + // Array of current segments for the non-moving collector. + // Of length NONMOVING_ALLOCA_CNT. + struct NonmovingSegment **current_segments; // block for allocating pinned objects into bdescr *pinned_object_block; ===================================== rts/Schedule.c ===================================== @@ -2329,7 +2329,7 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) // must be done before calling moreCapabilities(), because that // will emit events about creating the new capabilities and adding // them to existing capsets. - tracingAddCapapilities(n_capabilities, new_n_capabilities); + tracingAddCapabilities(n_capabilities, new_n_capabilities); #endif // Resize the capabilities array @@ -2344,7 +2344,8 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) // update n_capabilities before things start running if (new_n_capabilities > n_capabilities) { - RELAXED_STORE(&n_capabilities, enabled_capabilities = new_n_capabilities); + RELAXED_STORE(&n_capabilities, new_n_capabilities); + RELAXED_STORE(&enabled_capabilities, new_n_capabilities); } // We're done: release the original Capabilities ===================================== rts/Trace.c ===================================== @@ -143,7 +143,7 @@ void flushTrace () } } -void tracingAddCapapilities (uint32_t from, uint32_t to) +void tracingAddCapabilities (uint32_t from, uint32_t to) { if (eventlog_enabled) { moreCapEventBufs(from,to); ===================================== rts/Trace.h ===================================== @@ -28,7 +28,7 @@ void initTracing (void); void endTracing (void); void freeTracing (void); void resetTracing (void); -void tracingAddCapapilities (uint32_t from, uint32_t to); +void tracingAddCapabilities (uint32_t from, uint32_t to); #endif /* TRACING */ ===================================== rts/sm/GC.c ===================================== @@ -837,11 +837,13 @@ GarbageCollect (uint32_t collect_gen, // Flush the update remembered sets. See Note [Eager update remembered set // flushing] in NonMovingMark.c + ACQUIRE_SM_LOCK; if (RtsFlags.GcFlags.useNonmoving) { for (n = 0; n < getNumCapabilities(); n++) { nonmovingAddUpdRemSetBlocks(&getCapability(n)->upd_rem_set); } } + RELEASE_SM_LOCK; // Mark and sweep the oldest generation. // N.B. This can only happen after we've moved ===================================== rts/sm/NonMoving.c ===================================== @@ -253,6 +253,9 @@ Mutex concurrent_coll_finished_lock; * - Note [Weak pointer processing and the non-moving GC] (MarkWeak.c) describes * how weak pointers are handled when the non-moving GC is in use. * + * - Note [Sync phase marking budget] describes how we avoid long mutator + * pauses during the sync phase + * * [ueno 2016]: * Katsuhiro Ueno and Atsushi Ohori. 2016. A fully concurrent garbage * collector for functional programs on multicore processors. SIGPLAN Not. 51, @@ -504,10 +507,44 @@ Mutex concurrent_coll_finished_lock; * remembered set during the preparatory GC. This allows us to safely skip the * non-moving write barrier without jeopardizing the snapshot invariant. * + * + * Note [Sync phase marking budget] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * The non-moving collector is intended to provide reliably low collection + * latencies. These latencies are primarily due to two sources: + * + * a. the preparatory moving collection at the beginning of the major GC cycle + * b. the post-mark synchronization pause at the end + * + * While the cost of (a) is inherently bounded by the young generation size, + * (b) can in principle be unbounded since the mutator may hide large swathes + * of heap from the collector's concurrent mark phase via mutation. These will + * only become visible to the collector during the post-mark synchronization + * phase. + * + * Since we don't want to do unbounded marking work in the pause, we impose a + * limit (specifically, sync_phase_marking_budget) on the amount of work + * (namely, the number of marked closures) that we can do during the pause. If + * we deplete our marking budget during the pause then we allow the mutators to + * resume and return to concurrent marking (keeping the update remembered set + * write barrier enabled). After we have finished marking we will again + * attempt the post-mark synchronization. + * + * The choice of sync_phase_marking_budget was made empirically. On 2022 + * hardware and a "typical" test program we tend to mark ~10^7 closures per + * second. Consequently, a sync_phase_marking_budget of 10^5 should produce + * ~10 ms pauses, which seems like a reasonable tradeoff. + * + * TODO: Perhaps sync_phase_marking_budget should be controllable via a + * command-line argument? + * */ memcount nonmoving_live_words = 0; +// See Note [Sync phase marking budget]. +MarkBudget sync_phase_marking_budget = 200000; + #if defined(THREADED_RTS) static void* nonmovingConcurrentMark(void *mark_queue); #endif @@ -674,10 +711,11 @@ void *nonmovingAllocate(Capability *cap, StgWord sz) // object and not moved) which is covered by allocator 9. ASSERT(log_block_size < NONMOVING_ALLOCA0 + NONMOVING_ALLOCA_CNT); - struct NonmovingAllocator *alloca = nonmovingHeap.allocators[log_block_size - NONMOVING_ALLOCA0]; + unsigned int alloca_idx = log_block_size - NONMOVING_ALLOCA0; + struct NonmovingAllocator *alloca = &nonmovingHeap.allocators[alloca_idx]; // Allocate into current segment - struct NonmovingSegment *current = alloca->current[cap->no]; + struct NonmovingSegment *current = cap->current_segments[alloca_idx]; ASSERT(current); // current is never NULL void *ret = nonmovingSegmentGetBlock_(current, log_block_size, current->next_free); ASSERT(GET_CLOSURE_TAG(ret) == 0); // check alignment @@ -712,29 +750,12 @@ void *nonmovingAllocate(Capability *cap, StgWord sz) // make it current new_current->link = NULL; SET_SEGMENT_STATE(new_current, CURRENT); - alloca->current[cap->no] = new_current; + cap->current_segments[alloca_idx] = new_current; } return ret; } -/* Allocate a nonmovingAllocator */ -static struct NonmovingAllocator *alloc_nonmoving_allocator(uint32_t n_caps) -{ - size_t allocator_sz = - sizeof(struct NonmovingAllocator) + - sizeof(void*) * n_caps; // current segment pointer for each capability - struct NonmovingAllocator *alloc = - stgMallocBytes(allocator_sz, "nonmovingInit"); - memset(alloc, 0, allocator_sz); - return alloc; -} - -static void free_nonmoving_allocator(struct NonmovingAllocator *alloc) -{ - stgFree(alloc); -} - void nonmovingInit(void) { if (! RtsFlags.GcFlags.useNonmoving) return; @@ -743,10 +764,7 @@ void nonmovingInit(void) initCondition(&concurrent_coll_finished); initMutex(&concurrent_coll_finished_lock); #endif - for (unsigned int i = 0; i < NONMOVING_ALLOCA_CNT; i++) { - nonmovingHeap.allocators[i] = alloc_nonmoving_allocator(getNumCapabilities()); - } - nonmovingMarkInitUpdRemSet(); + nonmovingMarkInit(); } // Stop any nonmoving collection in preparation for RTS shutdown. @@ -779,44 +797,24 @@ void nonmovingExit(void) closeCondition(&concurrent_coll_finished); closeMutex(&nonmoving_collection_mutex); #endif - - for (unsigned int i = 0; i < NONMOVING_ALLOCA_CNT; i++) { - free_nonmoving_allocator(nonmovingHeap.allocators[i]); - } } -/* - * Assumes that no garbage collector or mutator threads are running to safely - * resize the nonmoving_allocators. - */ -void nonmovingAddCapabilities(uint32_t new_n_caps) +/* Initialize a new capability. Caller must hold SM_LOCK */ +void nonmovingInitCapability(Capability *cap) { - unsigned int old_n_caps = nonmovingHeap.n_caps; - struct NonmovingAllocator **allocs = nonmovingHeap.allocators; - - ACQUIRE_SM_LOCK; + // Initialize current segment array + struct NonmovingSegment **segs = + stgMallocBytes(sizeof(struct NonmovingSegment*) * NONMOVING_ALLOCA_CNT, "current segment array"); for (unsigned int i = 0; i < NONMOVING_ALLOCA_CNT; i++) { - struct NonmovingAllocator *old = allocs[i]; - allocs[i] = alloc_nonmoving_allocator(new_n_caps); - - // Copy the old state - allocs[i]->filled = old->filled; - allocs[i]->active = old->active; - for (unsigned int j = 0; j < old_n_caps; j++) { - allocs[i]->current[j] = old->current[j]; - } - stgFree(old); - - // Initialize current segments for the new capabilities - for (unsigned int j = old_n_caps; j < new_n_caps; j++) { - allocs[i]->current[j] = nonmovingAllocSegment(getCapability(j)->node); - nonmovingInitSegment(allocs[i]->current[j], NONMOVING_ALLOCA0 + i); - SET_SEGMENT_STATE(allocs[i]->current[j], CURRENT); - allocs[i]->current[j]->link = NULL; - } + segs[i] = nonmovingAllocSegment(cap->node); + nonmovingInitSegment(segs[i], NONMOVING_ALLOCA0 + i); + SET_SEGMENT_STATE(segs[i], CURRENT); } - nonmovingHeap.n_caps = new_n_caps; - RELEASE_SM_LOCK; + cap->current_segments = segs; + + // Initialize update remembered set + cap->upd_rem_set.queue.blocks = NULL; + nonmovingInitUpdRemSet(&cap->upd_rem_set); } void nonmovingClearBitmap(struct NonmovingSegment *seg) @@ -838,11 +836,12 @@ static void nonmovingPrepareMark(void) nonmovingBumpEpoch(); for (int alloca_idx = 0; alloca_idx < NONMOVING_ALLOCA_CNT; ++alloca_idx) { - struct NonmovingAllocator *alloca = nonmovingHeap.allocators[alloca_idx]; + struct NonmovingAllocator *alloca = &nonmovingHeap.allocators[alloca_idx]; // Update current segments' snapshot pointers for (uint32_t cap_n = 0; cap_n < nonmovingHeap.n_caps; ++cap_n) { - struct NonmovingSegment *seg = alloca->current[cap_n]; + Capability *cap = getCapability(cap_n); + struct NonmovingSegment *seg = cap->current_segments[alloca_idx]; nonmovingSegmentInfo(seg)->next_free_snap = seg->next_free; } @@ -925,7 +924,9 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) MarkQueue *mark_queue = stgMallocBytes(sizeof(MarkQueue), "mark queue"); mark_queue->blocks = NULL; + ACQUIRE_SM_LOCK; initMarkQueue(mark_queue); + RELEASE_SM_LOCK; current_mark_queue = mark_queue; // Mark roots @@ -1024,19 +1025,25 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads) } /* Mark queue, threads, and weak pointers until no more weaks have been - * resuscitated + * resuscitated. If *budget is non-zero then we will mark no more than + * Returns true if we there is no more marking work to be done, false if + * we exceeded our marking budget. */ -static void nonmovingMarkThreadsWeaks(MarkQueue *mark_queue) +static bool nonmovingMarkThreadsWeaks(MarkBudget *budget, MarkQueue *mark_queue) { while (true) { // Propagate marks - nonmovingMark(mark_queue); + nonmovingMark(budget, mark_queue); + if (*budget == 0) { + return false; + } // Tidy threads and weaks nonmovingTidyThreads(); - if (! nonmovingTidyWeaks(mark_queue)) - return; + if (! nonmovingTidyWeaks(mark_queue)) { + return true; + } } } @@ -1069,7 +1076,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * // Walk the list of filled segments that we collected during preparation, // updated their snapshot pointers and move them to the sweep list. for (int alloca_idx = 0; alloca_idx < NONMOVING_ALLOCA_CNT; ++alloca_idx) { - struct NonmovingSegment *filled = nonmovingHeap.allocators[alloca_idx]->saved_filled; + struct NonmovingSegment *filled = nonmovingHeap.allocators[alloca_idx].saved_filled; uint32_t n_filled = 0; if (filled) { struct NonmovingSegment *seg = filled; @@ -1088,14 +1095,18 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * seg->link = nonmovingHeap.sweep_list; nonmovingHeap.sweep_list = filled; } - nonmovingHeap.allocators[alloca_idx]->saved_filled = NULL; + nonmovingHeap.allocators[alloca_idx].saved_filled = NULL; } // Mark Weak#s nonmovingMarkWeakPtrList(mark_queue); // Do concurrent marking; most of the heap will get marked here. - nonmovingMarkThreadsWeaks(mark_queue); +concurrent_marking: + { + MarkBudget budget = UNLIMITED_MARK_BUDGET; + nonmovingMarkThreadsWeaks(&budget, mark_queue); + } #if defined(THREADED_RTS) Task *task = newBoundTask(); @@ -1118,9 +1129,17 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * nonmovingBeginFlush(task); bool all_caps_syncd; + MarkBudget sync_marking_budget = sync_phase_marking_budget; do { all_caps_syncd = nonmovingWaitForFlush(); - nonmovingMarkThreadsWeaks(mark_queue); + if (nonmovingMarkThreadsWeaks(&sync_marking_budget, mark_queue) == false) { + // We ran out of budget for marking. Abort sync. + // See Note [Sync phase marking budget]. + traceConcSyncEnd(); + stat_endNonmovingGcSync(); + releaseAllCapabilities(n_capabilities, NULL, task); + goto concurrent_marking; + } } while (!all_caps_syncd); #endif @@ -1131,7 +1150,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * // Do last marking of weak pointers while (true) { // Propagate marks - nonmovingMark(mark_queue); + nonmovingMarkUnlimitedBudget(mark_queue); if (!nonmovingTidyWeaks(mark_queue)) break; @@ -1140,7 +1159,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * nonmovingMarkDeadWeaks(mark_queue, dead_weaks); // Propagate marks - nonmovingMark(mark_queue); + nonmovingMarkUnlimitedBudget(mark_queue); // Now remove all dead objects from the mut_list to ensure that a younger // generation collection doesn't attempt to look at them after we've swept. @@ -1292,10 +1311,12 @@ void assert_in_nonmoving_heap(StgPtr p) } for (int alloca_idx = 0; alloca_idx < NONMOVING_ALLOCA_CNT; ++alloca_idx) { - struct NonmovingAllocator *alloca = nonmovingHeap.allocators[alloca_idx]; + struct NonmovingAllocator *alloca = &nonmovingHeap.allocators[alloca_idx]; + // Search current segments for (uint32_t cap_idx = 0; cap_idx < nonmovingHeap.n_caps; ++cap_idx) { - struct NonmovingSegment *seg = alloca->current[cap_idx]; + Capability *cap = getCapability(cap_idx); + struct NonmovingSegment *seg = cap->current_segments[alloca_idx]; if (p >= (P_)seg && p < (((P_)seg) + NONMOVING_SEGMENT_SIZE_W)) { return; } @@ -1354,33 +1375,16 @@ void nonmovingPrintSegment(struct NonmovingSegment *seg) debugBelch("End of segment\n\n"); } -void nonmovingPrintAllocator(struct NonmovingAllocator *alloc) -{ - debugBelch("Allocator at %p\n", (void*)alloc); - debugBelch("Filled segments:\n"); - for (struct NonmovingSegment *seg = alloc->filled; seg != NULL; seg = seg->link) { - debugBelch("%p ", (void*)seg); - } - debugBelch("\nActive segments:\n"); - for (struct NonmovingSegment *seg = alloc->active; seg != NULL; seg = seg->link) { - debugBelch("%p ", (void*)seg); - } - debugBelch("\nCurrent segments:\n"); - for (uint32_t i = 0; i < nonmovingHeap.n_caps; ++i) { - debugBelch("%p ", alloc->current[i]); - } - debugBelch("\n"); -} - void locate_object(P_ obj) { // Search allocators for (int alloca_idx = 0; alloca_idx < NONMOVING_ALLOCA_CNT; ++alloca_idx) { - struct NonmovingAllocator *alloca = nonmovingHeap.allocators[alloca_idx]; - for (uint32_t cap = 0; cap < nonmovingHeap.n_caps; ++cap) { - struct NonmovingSegment *seg = alloca->current[cap]; + struct NonmovingAllocator *alloca = &nonmovingHeap.allocators[alloca_idx]; + for (uint32_t cap_n = 0; cap_n < getNumCapabilities(); ++cap_n) { + Capability *cap = getCapability(cap_n); + struct NonmovingSegment *seg = cap->current_segments[alloca_idx]; if (obj >= (P_)seg && obj < (((P_)seg) + NONMOVING_SEGMENT_SIZE_W)) { - debugBelch("%p is in current segment of capability %d of allocator %d at %p\n", obj, cap, alloca_idx, (void*)seg); + debugBelch("%p is in current segment of capability %d of allocator %d at %p\n", obj, cap_n, alloca_idx, (void*)seg); return; } } ===================================== rts/sm/NonMoving.h ===================================== @@ -85,8 +85,7 @@ struct NonmovingAllocator { struct NonmovingSegment *filled; struct NonmovingSegment *saved_filled; struct NonmovingSegment *active; - // indexed by capability number - struct NonmovingSegment *current[]; + // N.B. Per-capabilty "current" segment lives in Capability }; // first allocator is of size 2^NONMOVING_ALLOCA0 (in bytes) @@ -100,7 +99,7 @@ struct NonmovingAllocator { #define NONMOVING_MAX_FREE 16 struct NonmovingHeap { - struct NonmovingAllocator *allocators[NONMOVING_ALLOCA_CNT]; + struct NonmovingAllocator allocators[NONMOVING_ALLOCA_CNT]; // free segment list. This is a cache where we keep up to // NONMOVING_MAX_FREE segments to avoid thrashing the block allocator. // Note that segments in this list are still counted towards @@ -151,7 +150,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads); void *nonmovingAllocate(Capability *cap, StgWord sz); -void nonmovingAddCapabilities(uint32_t new_n_caps); +void nonmovingInitCapability(Capability *cap); void nonmovingPushFreeSegment(struct NonmovingSegment *seg); void nonmovingClearBitmap(struct NonmovingSegment *seg); @@ -168,7 +167,7 @@ INLINE_HEADER uint8_t nonmovingSegmentLogBlockSize(struct NonmovingSegment *seg) INLINE_HEADER void nonmovingPushActiveSegment(struct NonmovingSegment *seg) { struct NonmovingAllocator *alloc = - nonmovingHeap.allocators[nonmovingSegmentLogBlockSize(seg) - NONMOVING_ALLOCA0]; + &nonmovingHeap.allocators[nonmovingSegmentLogBlockSize(seg) - NONMOVING_ALLOCA0]; SET_SEGMENT_STATE(seg, ACTIVE); while (true) { struct NonmovingSegment *current_active = RELAXED_LOAD(&alloc->active); @@ -183,7 +182,7 @@ INLINE_HEADER void nonmovingPushActiveSegment(struct NonmovingSegment *seg) INLINE_HEADER void nonmovingPushFilledSegment(struct NonmovingSegment *seg) { struct NonmovingAllocator *alloc = - nonmovingHeap.allocators[nonmovingSegmentLogBlockSize(seg) - NONMOVING_ALLOCA0]; + &nonmovingHeap.allocators[nonmovingSegmentLogBlockSize(seg) - NONMOVING_ALLOCA0]; SET_SEGMENT_STATE(seg, FILLED); while (true) { struct NonmovingSegment *current_filled = (struct NonmovingSegment*) RELAXED_LOAD(&alloc->filled); ===================================== rts/sm/NonMovingCensus.c ===================================== @@ -21,10 +21,12 @@ // stopped. In this case is safe to look at active and current segments so we can // also collect statistics on live words. static struct NonmovingAllocCensus -nonmovingAllocatorCensus_(struct NonmovingAllocator *alloc, bool collect_live_words) +nonmovingAllocatorCensus_(uint32_t alloc_idx, bool collect_live_words) { struct NonmovingAllocCensus census = {collect_live_words, 0, 0, 0, 0}; + struct NonmovingAllocator *alloc = &nonmovingHeap.allocators[alloc_idx]; + // filled segments for (struct NonmovingSegment *seg = alloc->filled; seg != NULL; seg = seg->link) @@ -40,6 +42,7 @@ nonmovingAllocatorCensus_(struct NonmovingAllocator *alloc, bool collect_live_wo } } + // active segments for (struct NonmovingSegment *seg = alloc->active; seg != NULL; seg = seg->link) @@ -56,9 +59,11 @@ nonmovingAllocatorCensus_(struct NonmovingAllocator *alloc, bool collect_live_wo } } - for (unsigned int cap=0; cap < getNumCapabilities(); cap++) + // current segments + for (unsigned int cap_n=0; cap_n < getNumCapabilities(); cap_n++) { - struct NonmovingSegment *seg = alloc->current[cap]; + Capability *cap = getCapability(cap_n); + struct NonmovingSegment *seg = cap->current_segments[alloc_idx]; unsigned int n = nonmovingSegmentBlockCount(seg); for (unsigned int i=0; i < n; i++) { if (nonmovingGetMark(seg, i)) { @@ -76,15 +81,15 @@ nonmovingAllocatorCensus_(struct NonmovingAllocator *alloc, bool collect_live_wo * all blocks in nonmoving heap are valid closures. */ struct NonmovingAllocCensus -nonmovingAllocatorCensusWithWords(struct NonmovingAllocator *alloc) +nonmovingAllocatorCensusWithWords(uint32_t alloc_idx) { - return nonmovingAllocatorCensus_(alloc, true); + return nonmovingAllocatorCensus_(alloc_idx, true); } struct NonmovingAllocCensus -nonmovingAllocatorCensus(struct NonmovingAllocator *alloc) +nonmovingAllocatorCensus(uint32_t alloc_idx) { - return nonmovingAllocatorCensus_(alloc, false); + return nonmovingAllocatorCensus_(alloc_idx, false); } @@ -130,7 +135,7 @@ void nonmovingPrintAllocatorCensus(bool collect_live_words) for (int i=0; i < NONMOVING_ALLOCA_CNT; i++) { struct NonmovingAllocCensus census = - nonmovingAllocatorCensus_(nonmovingHeap.allocators[i], collect_live_words); + nonmovingAllocatorCensus_(i, collect_live_words); print_alloc_census(i, census); } @@ -143,8 +148,7 @@ void nonmovingTraceAllocatorCensus() return; for (int i=0; i < NONMOVING_ALLOCA_CNT; i++) { - const struct NonmovingAllocCensus census = - nonmovingAllocatorCensus(nonmovingHeap.allocators[i]); + const struct NonmovingAllocCensus census = nonmovingAllocatorCensus(i); const uint32_t log_blk_size = i + NONMOVING_ALLOCA0; traceNonmovingHeapCensus(log_blk_size, &census); } ===================================== rts/sm/NonMovingCensus.h ===================================== @@ -20,10 +20,10 @@ struct NonmovingAllocCensus { struct NonmovingAllocCensus -nonmovingAllocatorCensusWithWords(struct NonmovingAllocator *alloc); +nonmovingAllocatorCensusWithWords(uint32_t alloc_idx); struct NonmovingAllocCensus -nonmovingAllocatorCensus(struct NonmovingAllocator *alloc); +nonmovingAllocatorCensus(uint32_t alloc_idx); void nonmovingPrintAllocatorCensus(bool collect_live_words); void nonmovingTraceAllocatorCensus(void); ===================================== rts/sm/NonMovingMark.c ===================================== @@ -253,7 +253,7 @@ StgWord nonmoving_write_barrier_enabled = false; MarkQueue *current_mark_queue = NULL; /* Initialise update remembered set data structures */ -void nonmovingMarkInitUpdRemSet() { +void nonmovingMarkInit() { #if defined(THREADED_RTS) initMutex(&upd_rem_set_lock); initCondition(&upd_rem_set_flushed_cond); @@ -295,7 +295,9 @@ static void nonmovingAddUpdRemSetBlocks_lock(MarkQueue *rset) nonmovingAddUpdRemSetBlocks_(rset); // Reset the state of the remembered set. + ACQUIRE_SM_LOCK; init_mark_queue_(rset); + RELEASE_SM_LOCK; rset->is_upd_rem_set = true; } @@ -928,7 +930,7 @@ static MarkQueueEnt markQueuePop (MarkQueue *q) /* Must hold sm_mutex. */ static void init_mark_queue_ (MarkQueue *queue) { - bdescr *bd = allocGroup_lock(MARK_QUEUE_BLOCKS); + bdescr *bd = allocGroup(MARK_QUEUE_BLOCKS); ASSERT(queue->blocks == NULL); queue->blocks = bd; queue->top = (MarkQueueBlock *) bd->start; @@ -939,12 +941,14 @@ static void init_mark_queue_ (MarkQueue *queue) #endif } +/* Must hold sm_mutex */ void initMarkQueue (MarkQueue *queue) { init_mark_queue_(queue); queue->is_upd_rem_set = false; } +/* Must hold sm_mutex */ void nonmovingInitUpdRemSet (UpdRemSet *rset) { init_mark_queue_(&rset->queue); @@ -1763,15 +1767,23 @@ done: * b. the nursery has been fully evacuated into the non-moving generation. * c. the mark queue has been seeded with a set of roots. * + * If budget is not UNLIMITED_MARK_BUDGET, then we will mark no more than the + * indicated number of objects and deduct the work done from the budget. */ GNUC_ATTR_HOT void -nonmovingMark (MarkQueue *queue) +nonmovingMark (MarkBudget* budget, MarkQueue *queue) { traceConcMarkBegin(); debugTrace(DEBUG_nonmoving_gc, "Starting mark pass"); - unsigned int count = 0; + uint64_t count = 0; while (true) { count++; + if (*budget == 0) { + return; + } else if (*budget != UNLIMITED_MARK_BUDGET) { + *budget -= 1; + } + MarkQueueEnt ent = markQueuePop(queue); switch (nonmovingMarkQueueEntryType(&ent)) { ===================================== rts/sm/NonMovingMark.h ===================================== @@ -112,6 +112,11 @@ typedef struct { MarkQueue queue; } UpdRemSet; +// How much marking work we are allowed to perform +// See Note [Sync phase marking budget] in NonMoving.c +typedef int64_t MarkBudget; +#define UNLIMITED_MARK_BUDGET INT64_MIN + // Number of blocks to allocate for a mark queue #define MARK_QUEUE_BLOCKS 16 @@ -136,7 +141,7 @@ extern MarkQueue *current_mark_queue; extern bdescr *upd_rem_set_block_list; -void nonmovingMarkInitUpdRemSet(void); +void nonmovingMarkInit(void); void nonmovingInitUpdRemSet(UpdRemSet *rset); void updateRemembSetPushClosure(Capability *cap, StgClosure *p); @@ -156,7 +161,12 @@ void markQueueAddRoot(MarkQueue* q, StgClosure** root); void initMarkQueue(MarkQueue *queue); void freeMarkQueue(MarkQueue *queue); -void nonmovingMark(struct MarkQueue_ *__restrict__ queue); +void nonmovingMark(MarkBudget *budget, struct MarkQueue_ *__restrict__ queue); +INLINE_HEADER void nonmovingMarkUnlimitedBudget(struct MarkQueue_ *restrict queue) { + MarkBudget budget = UNLIMITED_MARK_BUDGET; + nonmovingMark(&budget, queue); +} + void nonmovingMarkWeakPtrList(struct MarkQueue_ *queue); bool nonmovingTidyWeaks(struct MarkQueue_ *queue); ===================================== rts/sm/Sanity.c ===================================== @@ -637,12 +637,13 @@ void checkNonmovingHeap (const struct NonmovingHeap *heap) checkLargeObjects(nonmoving_marked_large_objects); checkCompactObjects(nonmoving_compact_objects); for (unsigned int i=0; i < NONMOVING_ALLOCA_CNT; i++) { - const struct NonmovingAllocator *alloc = heap->allocators[i]; + const struct NonmovingAllocator *alloc = &heap->allocators[i]; checkNonmovingSegments(alloc->filled); checkNonmovingSegments(alloc->saved_filled); checkNonmovingSegments(alloc->active); - for (unsigned int cap=0; cap < getNumCapabilities(); cap++) { - checkNonmovingSegments(alloc->current[cap]); + for (unsigned int cap_n=0; cap_n < getNumCapabilities(); cap_n++) { + Capability *cap = getCapability(cap_n); + checkNonmovingSegments(cap->current_segments[i]); } } } @@ -926,7 +927,7 @@ static void checkGeneration (generation *gen, uint32_t n; gen_workspace *ws; - //ASSERT(countBlocks(gen->blocks) == gen->n_blocks); + ASSERT(countBlocks(gen->blocks) == gen->n_blocks); ASSERT(countBlocks(gen->large_objects) == gen->n_large_blocks); #if defined(THREADED_RTS) @@ -1070,12 +1071,13 @@ findMemoryLeak (void) markBlocks(nonmoving_compact_objects); markBlocks(nonmoving_marked_compact_objects); for (i = 0; i < NONMOVING_ALLOCA_CNT; i++) { - struct NonmovingAllocator *alloc = nonmovingHeap.allocators[i]; + struct NonmovingAllocator *alloc = &nonmovingHeap.allocators[i]; markNonMovingSegments(alloc->filled); markNonMovingSegments(alloc->saved_filled); markNonMovingSegments(alloc->active); for (j = 0; j < getNumCapabilities(); j++) { - markNonMovingSegments(alloc->current[j]); + Capability *cap = getCapability(j); + markNonMovingSegments(cap->current_segments[i]); } } markNonMovingSegments(nonmovingHeap.sweep_list); @@ -1180,23 +1182,18 @@ countNonMovingSegments(struct NonmovingSegment *segs) return ret; } -static W_ -countNonMovingAllocator(struct NonmovingAllocator *alloc) -{ - W_ ret = countNonMovingSegments(alloc->filled) - + countNonMovingSegments(alloc->active); - for (uint32_t i = 0; i < getNumCapabilities(); ++i) { - ret += countNonMovingSegments(alloc->current[i]); - } - return ret; -} - static W_ countNonMovingHeap(struct NonmovingHeap *heap) { W_ ret = 0; for (int alloc_idx = 0; alloc_idx < NONMOVING_ALLOCA_CNT; alloc_idx++) { - ret += countNonMovingAllocator(heap->allocators[alloc_idx]); + struct NonmovingAllocator *alloc = &heap->allocators[alloc_idx]; + ret += countNonMovingSegments(alloc->filled); + ret += countNonMovingSegments(alloc->active); + for (uint32_t c = 0; c < getNumCapabilities(); ++c) { + Capability *cap = getCapability(c); + ret += countNonMovingSegments(cap->current_segments[alloc_idx]); + } } ret += countNonMovingSegments(heap->sweep_list); ret += countNonMovingSegments(heap->free); ===================================== rts/sm/Storage.c ===================================== @@ -213,13 +213,10 @@ initStorage (void) generations[g].to = &generations[g+1]; } oldest_gen->to = oldest_gen; - RELEASE_SM_LOCK; // Nonmoving heap uses oldest_gen so initialize it after initializing oldest_gen nonmovingInit(); - - if (RtsFlags.GcFlags.useNonmoving) - nonmovingAddCapabilities(getNumCapabilities()); + RELEASE_SM_LOCK; /* The oldest generation has one step. */ if (RtsFlags.GcFlags.compact || RtsFlags.GcFlags.sweep) { @@ -313,16 +310,14 @@ void storageAddCapabilities (uint32_t from, uint32_t to) allocBlockOnNode(capNoToNumaNode(n)); } } - RELEASE_SM_LOCK; - // Initialize NonmovingAllocators and UpdRemSets + // Initialize non-moving collector if (RtsFlags.GcFlags.useNonmoving) { - nonmovingAddCapabilities(to); for (i = from; i < to; i++) { - getCapability(i)->upd_rem_set.queue.blocks = NULL; - nonmovingInitUpdRemSet(&getCapability(i)->upd_rem_set); + nonmovingInitCapability(getCapability(i)); } } + RELEASE_SM_LOCK; #if defined(THREADED_RTS) && defined(CC_LLVM_BACKEND) && (CC_SUPPORTS_TLS == 0) newThreadLocalKey(&gctKey); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4a91acb13ad757f710c3cbcd35d29c06176cdef0...3d7baa30746e92f39981d2db95de78eb80bd1cdb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4a91acb13ad757f710c3cbcd35d29c06176cdef0...3d7baa30746e92f39981d2db95de78eb80bd1cdb You're receiving 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 Dec 9 03:40:02 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 08 Dec 2022 22:40:02 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-2] 2 commits: Slight cleanup of syntax Message-ID: <6392ae125a9e6_224fca605f46897f5@gitlab.mail> John Ericson pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: f476c792 by John Ericson at 2022-12-08T21:49:52-05:00 Slight cleanup of syntax - - - - - cff1dc32 by John Ericson at 2022-12-08T22:39:27-05:00 Need to use CPP not `if` in rts.buildinfo - - - - - 2 changed files: - rts/configure.ac - rts/rts.buildinfo.in Changes: ===================================== rts/configure.ac ===================================== @@ -138,7 +138,7 @@ dnl as we need to know whether we need libm dnl for math functions or not dnl (see https://gitlab.haskell.org/ghc/ghc/issues/3730) AC_CHECK_LIB([m], [atan], [need_libm=1], [need_libm=0]) -AC_DEFINE_UNQUOTED([GHC_NEED_LIBM], [$need_libm], [Define to 1 if you need to link with libm])], +AC_DEFINE_UNQUOTED([GHC_NEED_LIBM], [$need_libm], [Define to 1 if you need to link with libm]) dnl ** check for librt AC_CHECK_LIB([rt], [clock_gettime], [need_librt=1], [need_librt=1]) @@ -189,6 +189,7 @@ dnl Generate build-info dnl ###################################################################### cat $srcdir/rts.buildinfo.in | \ + sed -e 's/^ *//' | \ "$CC" -E -P -traditional - -o - \ > rts.buildinfo rm -f external-symbols.list ===================================== rts/rts.buildinfo.in ===================================== @@ -3,59 +3,61 @@ ld-options: #include "external-symbols.list" #if GHC_LIBFFI_ADJUSTORS --- Adjustors via libffi -c-sources: adjustor/LibffiAdjustor.c + -- Adjustors via libffi + c-sources: adjustor/LibffiAdjustor.c #else --- Use GHC's native adjustors -if arch(i386) - asm-sources: adjustor/Nativei386Asm.S - c-sources: adjustor/Nativei386.c -if arch(x86_64) - if os(mingw32) - asm-sources: adjustor/NativeAmd64MingwAsm.S - c-sources: adjustor/NativeAmd64Mingw.c - else - asm-sources: adjustor/NativeAmd64Asm.S - c-sources: adjustor/NativeAmd64.c -if arch(ppc) || arch(ppc64) - asm-sources: AdjustorAsm.S - c-sources: adjustor/NativePowerPC.c -if arch(ia64) - c-sources: adjustor/NativeIA64.c + -- Use GHC's native adjustors +# if defined(i386_HOST_ARCH) + asm-sources: adjustor/Nativei386Asm.S + c-sources: adjustor/Nativei386.c +# elif defined(x86_64_HOST_ARCH) +# if defined(mingw32_HOST_OS) + asm-sources: adjustor/NativeAmd64MingwAsm.S + c-sources: adjustor/NativeAmd64Mingw.c +# else + asm-sources: adjustor/NativeAmd64Asm.S + c-sources: adjustor/NativeAmd64.c +# endif +# elif defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) + asm-sources: AdjustorAsm.S + c-sources: adjustor/NativePowerPC.c +# elif defined(ia64_HOST_ARCH) + c-sources: adjustor/NativeIA64.c +# endif #endif #if GHC_NEED_LIBRT -extra-libraries: rt + extra-libraries: rt #endif #if GHC_NEED_LIBM -extra-libraries: m + extra-libraries: m #endif #if GHC_NEED_LIBDL -extra-libraries: dl + extra-libraries: dl #endif #if GHC_NEED_LIBATOMIC --- for sub-word-sized atomic operations (#19119) -extra-libraries: atomic + -- for sub-word-sized atomic operations (#19119) + extra-libraries: atomic #endif #if GHC_NEED_LIBPTHREAD --- for pthread_getthreadid_np, pthread_create, ... -extra-libraries: pthread + -- for pthread_getthreadid_np, pthread_create, ... + extra-libraries: pthread #endif #if USE_LIBBFD --- for debugging -extra-libraries: bfd iberty + -- for debugging + extra-libraries: bfd iberty #endif #if USE_LIBDW --- for backtraces -extra-libraries: elf dw + -- for backtraces + extra-libraries: elf dw #endif #if USE_LIBNUMA -extra-libraries: numa + extra-libraries: numa #endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/53a33fafc195ceb46647f4225c4fe6f950fa2fdc...cff1dc328e03d777d391f94003db7e7f5104f8f8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/53a33fafc195ceb46647f4225c4fe6f950fa2fdc...cff1dc328e03d777d391f94003db7e7f5104f8f8 You're receiving 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 Dec 9 03:45:56 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:45:56 -0500 Subject: [Git][ghc/ghc][master] 5 commits: Add test for #22162 Message-ID: <6392af74b7eac_224fca6061c6990d6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - 16 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Tc/Utils/Backpack.hs - testsuite/tests/backpack/should_fail/T19244a.stderr - + testsuite/tests/determinism/determ023/A.hs - + testsuite/tests/determinism/determ023/Makefile - + testsuite/tests/determinism/determ023/all.T - + testsuite/tests/determinism/determ023/header - + testsuite/tests/determinism/determ024/A.hs - + testsuite/tests/determinism/determ024/B.hs - + testsuite/tests/determinism/determ024/Makefile - + testsuite/tests/determinism/determ024/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -405,6 +405,33 @@ test-cabal-reinstall-x86_64-linux-deb10: rules: - if: $NIGHTLY +######################################## +# Testing ABI is invariant across builds +######################################## + +abi-test-nightly: + stage: full-build + needs: + - job: nightly-x86_64-linux-fedora33-release-hackage + - job: nightly-x86_64-linux-fedora33-release + tags: + - x86_64-linux + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + dependencies: null + before_script: + - mkdir -p normal + - mkdir -p hackage + - tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C normal/ + - tar -xf ghc-x86_64-linux-fedora33-release-hackage_docs.tar.xz -C hackage/ + script: + - .gitlab/ci.sh compare_interfaces_of "normal/ghc-*" "hackage/ghc-*" + artifacts: + paths: + - out + rules: + - if: $NIGHTLY + - if: '$RELEASE_JOB == "yes"' + ############################################################ # Packaging ############################################################ @@ -753,6 +780,46 @@ perf: rules: - if: '$CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/' +############################################################ +# ABI testing +############################################################ + +abi-test: + stage: testing + needs: + - job: x86_64-linux-fedora33-release + optional: true + - job: nightly-x86_64-linux-fedora33-release + optional: true + - job: release-x86_64-linux-fedora33-release + optional: true + dependencies: null + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + rules: + - if: $CI_MERGE_REQUEST_ID + - if: '$CI_COMMIT_BRANCH == "master"' + - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' + tags: + - x86_64-linux + script: + - root=$(pwd)/ghc + - | + mkdir tmp + tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export BOOT_HC=$(which ghc) + - export HC=$root/bin/ghc + - .gitlab/ci.sh abi_test + artifacts: + paths: + - out + rules: + - if: '$CI_MERGE_REQUEST_LABELS !~ /.*fast-ci.*/' + ############################################################ # Documentation deployment via GitLab Pages ===================================== .gitlab/ci.sh ===================================== @@ -663,6 +663,36 @@ function test_hadrian() { } +function summarise_hi_files() { + for iface in $(find . -type f -name "*.hi" | sort); do echo "$iface $($HC --show-iface $iface | grep " ABI hash:")"; done | tee $OUT/abis + for iface in $(find . -type f -name "*.hi" | sort); do echo "$iface $($HC --show-iface $iface | grep " interface hash:")"; done | tee $OUT/interfaces + for iface in $(find . -type f -name "*.hi" | sort); do + fname="$OUT/$(dirname $iface)" + mkdir -p $fname + $HC --show-iface $iface > "$OUT/$iface" + done +} + +function cabal_abi_test() { + if [ -z "$OUT" ]; then + fail "OUT not set" + fi + + cp -r libraries/Cabal $DIR + pushd $DIR + echo $PWD + + start_section "Cabal test: $OUT" + mkdir -p "$OUT" + run "$HC" \ + -hidir tmp -odir tmp -fforce-recomp -haddock \ + -iCabal/Cabal/src -XNoPolyKinds Distribution.Simple -j"$cores" \ + "$@" 2>&1 | tee $OUT/log + summarise_hi_files + popd + end_section "Cabal test: $OUT" +} + function cabal_test() { if [ -z "$OUT" ]; then fail "OUT not set" @@ -693,6 +723,35 @@ function run_perf_test() { OUT=out/Cabal-O2 cabal_test -O2 } +function check_interfaces(){ + difference=$(diff "$1/$3" "$2/$3") || warn "diff failed" + if [ -z "$difference" ] + then + info "$1 and $2 $3 match" + else + echo $difference + for line in $(echo "$difference" | tr ' ' '\n' | grep ".hi" | sort | uniq); do + diff "$1/$line" "$2/$line" + done + fail "$3" + fi +} + +function abi_test() { + for i in {1..20}; do info "iteration $i"; run_abi_test; done +} + +function run_abi_test() { + if [ -z "$HC" ]; then + fail "HC not set" + fi + mkdir -p out + OUT="$PWD/out/run1" DIR=$(mktemp -d XXXX-looooooooong) cabal_abi_test -O0 + OUT="$PWD/out/run2" DIR=$(mktemp -d XXXX-short) cabal_abi_test -O0 + check_interfaces out/run1 out/run2 abis "Mismatched ABI hash" + check_interfaces out/run1 out/run2 interfaces "Mismatched interface hashes" +} + function save_cache () { info "Storing cabal cache from $CABAL_DIR to $CABAL_CACHE..." rm -Rf "$CABAL_CACHE" @@ -742,6 +801,22 @@ function lint_author(){ done } +function abi_of(){ + DIR=$(realpath $1) + mkdir -p "$OUT" + pushd $DIR + summarise_hi_files + popd +} + +# Checks that the interfaces in folder $1 match the interfaces in folder $2 +function compare_interfaces_of(){ + OUT=$PWD/out/run1 abi_of $1 + OUT=$PWD/out/run2 abi_of $2 + check_interfaces out/run1 out/run2 abis "Mismatched ABI hash" + check_interfaces out/run1 out/run2 interfaces "Mismatched interface hashes" +} + setup_locale @@ -837,8 +912,10 @@ case $1 in exit $res ;; run_hadrian) shift; run_hadrian "$@" ;; perf_test) run_perf_test ;; + abi_test) abi_test ;; cabal_test) cabal_test ;; lint_author) shift; lint_author "$@" ;; + compare_interfaces_of) shift; compare_interfaces_of "$@" ;; clean) clean ;; save_cache) save_cache ;; shell) shift; shell "$@" ;; ===================================== compiler/GHC/HsToCore.hs ===================================== @@ -41,7 +41,7 @@ import GHC.HsToCore.Coverage import GHC.HsToCore.Docs import GHC.Tc.Types -import GHC.Tc.Utils.Monad ( finalSafeMode, fixSafeInstances ) +import GHC.Tc.Utils.Monad ( finalSafeMode, fixSafeInstances, initIfaceLoad ) import GHC.Tc.Module ( runTcInteractive ) import GHC.Core.Type @@ -241,8 +241,9 @@ deSugar hsc_env ; let plugins = hsc_plugins hsc_env ; let fc = hsc_FC hsc_env ; let unit_env = hsc_unit_env hsc_env - ; usages <- mkUsageInfo uc plugins fc unit_env mod (imp_mods imports) used_names - dep_files merged needed_mods needed_pkgs + ; usages <- initIfaceLoad hsc_env $ + mkUsageInfo uc plugins fc unit_env mod (imp_mods imports) used_names + dep_files merged needed_mods needed_pkgs -- id_mod /= mod when we are processing an hsig, but hsigs -- never desugared and compiled (there's no code!) -- Consequently, this should hold for any ModGuts that make ===================================== compiler/GHC/HsToCore/Usage.hs ===================================== @@ -15,10 +15,13 @@ import GHC.Driver.Env import GHC.Tc.Types +import GHC.Iface.Load + import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Fingerprint import GHC.Utils.Panic +import GHC.Utils.Monad import GHC.Types.Name import GHC.Types.Name.Set ( NameSet, allUses ) @@ -70,18 +73,18 @@ data UsageConfig = UsageConfig } mkUsageInfo :: UsageConfig -> Plugins -> FinderCache -> UnitEnv -> Module -> ImportedMods -> NameSet -> [FilePath] - -> [(Module, Fingerprint)] -> [Linkable] -> PkgsLoaded -> IO [Usage] + -> [(Module, Fingerprint)] -> [Linkable] -> PkgsLoaded -> IfG [Usage] mkUsageInfo uc plugins fc unit_env this_mod dir_imp_mods used_names dependent_files merged needed_links needed_pkgs = do - eps <- readIORef (euc_eps (ue_eps unit_env)) - hashes <- mapM getFileHash dependent_files + eps <- liftIO $ readIORef (euc_eps (ue_eps unit_env)) + hashes <- liftIO $ mapM getFileHash dependent_files let hu = unsafeGetHomeUnit unit_env hug = ue_home_unit_graph unit_env -- Dependencies on object files due to TH and plugins - object_usages <- mkObjectUsage (eps_PIT eps) plugins fc hug needed_links needed_pkgs - let mod_usages = mk_mod_usage_info (eps_PIT eps) uc hug hu this_mod + object_usages <- liftIO $ mkObjectUsage (eps_PIT eps) plugins fc hug needed_links needed_pkgs + mod_usages <- mk_mod_usage_info uc hu this_mod dir_imp_mods used_names - usages = mod_usages ++ [ UsageFile { usg_file_path = f + let usages = mod_usages ++ [ UsageFile { usg_file_path = f , usg_file_hash = hash , usg_file_label = Nothing } | (f, hash) <- zip dependent_files hashes ] @@ -189,16 +192,14 @@ mkObjectUsage pit plugins fc hug th_links_needed th_pkgs_needed = do librarySpecToUsage (DLLPath fn) = traverse (fing Nothing) [fn] librarySpecToUsage _ = return [] -mk_mod_usage_info :: PackageIfaceTable - -> UsageConfig - -> HomeUnitGraph +mk_mod_usage_info :: UsageConfig -> HomeUnit -> Module -> ImportedMods -> NameSet - -> [Usage] -mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names - = mapMaybe mkUsage usage_mods + -> IfG [Usage] +mk_mod_usage_info uc home_unit this_mod direct_imports used_names + = mapMaybeM mkUsageM usage_mods where safe_implicit_imps_req = uc_safe_implicit_imps_req uc @@ -234,22 +235,27 @@ mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names in extendModuleEnvWith (\_ xs -> occ:xs) mv_map mod' [occ] where occ = nameOccName name + mkUsageM :: Module -> IfG (Maybe Usage) + mkUsageM mod | mod == this_mod -- We don't care about usages of things in *this* module + || moduleUnit mod == interactiveUnit -- ... or in GHCi + = return Nothing + mkUsageM mod = do + iface <- loadSysInterface (text "mk_mod_usage") mod + -- Make sure the interface is loaded even if we don't directly use + -- any symbols from it, to ensure determinism. See #22217. + return $ mkUsage mod iface + + -- We want to create a Usage for a home module if -- a) we used something from it; has something in used_names -- b) we imported it, even if we used nothing from it -- (need to recompile if its export list changes: export_fprint) - mkUsage :: Module -> Maybe Usage - mkUsage mod - | isNothing maybe_iface -- We can't depend on it if we didn't - -- load its interface. - || mod == this_mod -- We don't care about usages of - -- things in *this* module - = Nothing - + mkUsage :: Module -> ModIface -> Maybe Usage + mkUsage mod iface | not (isHomeModule home_unit mod) - = Just UsagePackageModule{ usg_mod = mod, - usg_mod_hash = mod_hash, - usg_safe = imp_safe } + = Just $ UsagePackageModule{ usg_mod = mod, + usg_mod_hash = mod_hash, + usg_safe = imp_safe } -- for package modules, we record the module hash only | (null used_occs @@ -269,11 +275,6 @@ mk_mod_usage_info pit uc hpt home_unit this_mod direct_imports used_names usg_entities = Map.toList ent_hashs, usg_safe = imp_safe } where - maybe_iface = lookupIfaceByModule hpt pit mod - -- In one-shot mode, the interfaces for home-package - -- modules accumulate in the PIT not HPT. Sigh. - - Just iface = maybe_iface finsts_mod = mi_finsts (mi_final_exts iface) hash_env = mi_hash_fn (mi_final_exts iface) mod_hash = mi_mod_hash (mi_final_exts iface) ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -232,7 +232,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program -- but if you pass that in here, we'll decide it's the local -- module and does not need to be recorded as a dependency. -- See Note [Identity versus semantic module] - usages <- mkUsageInfo uc plugins fc unit_env this_mod (imp_mods imports) used_names + usages <- initIfaceLoad hsc_env $ mkUsageInfo uc plugins fc unit_env this_mod (imp_mods imports) used_names dep_files merged needed_links needed_pkgs docs <- extractDocs (ms_hspp_opts mod_summary) tc_result ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -589,7 +589,7 @@ checkDependencies hsc_env summary iface liftIO $ check_mods (sort hs) prev_dep_mods `recompThen` - let allPkgDeps = sortBy (comparing snd) $ nubOrdOn snd (ps ++ implicit_deps ++ bkpk_units) + let allPkgDeps = sortBy (comparing snd) $ nubOrdOn snd (ps ++ implicit_deps) in check_packages allPkgDeps prev_dep_pkgs where @@ -613,7 +613,6 @@ checkDependencies hsc_env summary iface prev_dep_mods = map (second gwib_mod) $ Set.toAscList $ dep_direct_mods (mi_deps iface) prev_dep_pkgs = Set.toAscList (Set.union (dep_direct_pkgs (mi_deps iface)) (dep_plugin_pkgs (mi_deps iface))) - bkpk_units = map ((fsLit "Signature",) . instUnitInstanceOf . moduleUnit) (requirementMerges units (moduleName (mi_module iface))) implicit_deps = map (fsLit "Implicit",) (implicitPackageDeps dflags) ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -856,7 +856,6 @@ 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) @@ -867,18 +866,17 @@ mergeSignatures (insts, inst_env) = foldl' merge_inst (tcg_insts tcg_env, tcg_inst_env tcg_env) (instEnvElts $ md_insts details) - -- This is a HACK to prevent calculateAvails from including imp_mod - -- in the listing. We don't want it because a module is NOT + -- Use mi_deps directly rather than calculateAvails. + -- 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 - other_home_units = hsc_all_home_unit_ids hsc_env - avails = plusImportAvails (tcg_imports tcg_env) $ - calculateAvails home_unit other_home_units iface' False NotBoot ImportedBySystem + avails = tcg_imports tcg_env + deps = mi_deps iface + avails_with_trans = addTransitiveDepInfo avails deps + return tcg_env { tcg_inst_env = inst_env, tcg_insts = insts, - tcg_imports = avails, + tcg_imports = avails_with_trans, tcg_merged = if outer_mod == mi_module iface -- Don't add ourselves! @@ -912,6 +910,20 @@ mergeSignatures return tcg_env +-- | Add on the necessary transitive information from the merged signature to +-- the 'ImportAvails' of the result of merging. This propagates the orphan instances +-- which were in the transitive closure of the signature through the merge. +addTransitiveDepInfo :: ImportAvails -- ^ From the signature resulting from the merge + -> Dependencies -- ^ From the original signature + -> ImportAvails +addTransitiveDepInfo avails deps = + -- Avails for the merged in signature + -- Add on transitive information from the signature but nothing else.. + -- because we do not "import" the signature. + avails { imp_orphs = imp_orphs avails ++ dep_orphs deps + , imp_finsts = imp_finsts avails ++ dep_finsts deps + , imp_sig_mods = imp_sig_mods avails ++ dep_sig_mods deps } + -- | Top-level driver for signature instantiation (run when compiling -- an @hsig@ file.) tcRnInstantiateSignature :: ===================================== testsuite/tests/backpack/should_fail/T19244a.stderr ===================================== @@ -13,7 +13,17 @@ Instantiating user[Map=ordmap:Map] [1 of 2] Compiling Map[sig] ( user/Map.hsig, T19244a.out/user/user-GzloW2NeDdA2M0V8qzN4g2/Map.o ) -T19244a.bkp:9:9: error: +T19244a.bkp:22:9: error: + • Type constructor ‘Key’ has conflicting definitions in the module + and its hsig file + Main module: type Key :: * -> Constraint + type Key = GHC.Classes.Ord :: * -> Constraint + Hsig file: type Key :: forall {k}. k -> Constraint + class Key k1 + The types have different kinds + • while checking that ordmap:Map implements signature Map in user[Map=ordmap:Map] + +: error: • Type constructor ‘Map’ has conflicting definitions in the module and its hsig file Main module: type role Map nominal representational @@ -31,16 +41,6 @@ T19244a.bkp:9:9: error: The types have different kinds • while checking that ordmap:Map implements signature Map in user[Map=ordmap:Map] -T19244a.bkp:22:9: error: - • Type constructor ‘Key’ has conflicting definitions in the module - and its hsig file - Main module: type Key :: * -> Constraint - type Key = GHC.Classes.Ord :: * -> Constraint - Hsig file: type Key :: forall {k}. k -> Constraint - class Key k1 - The types have different kinds - • while checking that ordmap:Map implements signature Map in user[Map=ordmap:Map] - : error: • Identifier ‘lookup’ has conflicting definitions in the module and its hsig file ===================================== testsuite/tests/determinism/determ023/A.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE CPP #-} +module A where + +{-# DEPRECATED foo "abc" #-} +foo = () ===================================== testsuite/tests/determinism/determ023/Makefile ===================================== @@ -0,0 +1,15 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +determ023: + $(RM) A.hi A.o + mkdir -p a + mkdir -p ab + cp A.hs a + cp A.hs ab + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -ia A -hidir=a + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -iab A -hidir=ab + '$(TEST_HC)' $(TEST_HC_OPTS) --show-iface a/A.hi > hi1 + '$(TEST_HC)' $(TEST_HC_OPTS) --show-iface ab/A.hi > hi2 + diff hi1 hi2 ===================================== testsuite/tests/determinism/determ023/all.T ===================================== @@ -0,0 +1 @@ +test('determ023', [extra_files(['A.hs', 'header'])], makefile_test, ['determ023']) ===================================== testsuite/tests/determinism/determ023/header ===================================== @@ -0,0 +1 @@ +qux = () ===================================== testsuite/tests/determinism/determ024/A.hs ===================================== @@ -0,0 +1,6 @@ +module A +( isExtensionOf +, stripExtension +) where + +import System.FilePath.Posix ===================================== testsuite/tests/determinism/determ024/B.hs ===================================== @@ -0,0 +1,7 @@ +module B +( isExtensionOf +, stripExtension +) where + +import System.FilePath + ===================================== testsuite/tests/determinism/determ024/Makefile ===================================== @@ -0,0 +1,11 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +determ024: + $(RM) A.hi A.o B.hi B.o + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 B.hs + '$(TEST_HC)' --show-iface B.hi > B_clean_iface + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 A.hs B.hs -fforce-recomp + '$(TEST_HC)' --show-iface B.hi > B_dirty_iface + diff B_clean_iface B_dirty_iface ===================================== testsuite/tests/determinism/determ024/all.T ===================================== @@ -0,0 +1 @@ +test('determ024', [extra_files(['A.hs', 'B.hs'])], makefile_test, ['determ024']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7658cdd47198512b699492688f51fc8682d194cd...d122e02247a371b14c3e906556900c0d600f424d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7658cdd47198512b699492688f51fc8682d194cd...d122e02247a371b14c3e906556900c0d600f424d You're receiving 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 Dec 9 03:46:28 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:46:28 -0500 Subject: [Git][ghc/ghc][master] Add initial support for LoongArch Architecture. Message-ID: <6392af94eb051_224fca18f7d754703213@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 29 changed files: - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Platform.hs - + compiler/GHC/Platform/LoongArch64.hs - compiler/GHC/Platform/Regs.hs - compiler/ghc.cabal.in - configure.ac - hadrian/src/Oracles/Flag.hs - libraries/base/System/Info.hs - libraries/ghc-boot/GHC/Platform/ArchOS.hs - llvm-targets - m4/fptools_set_haskell_platform_vars.m4 - m4/ghc_convert_cpu.m4 - m4/ghc_tables_next_to_code.m4 - m4/ghc_unregisterised.m4 - rts/StgCRunAsm.S - rts/include/stg/MachRegs.h - rts/include/stg/MachRegsForHost.h - rts/include/stg/SMP.h - rts/linker/Elf.c - rts/rts.cabal.in - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout - utils/llvm-targets/gen-data-layout.sh Changes: ===================================== compiler/CodeGen.Platform.h ===================================== @@ -377,6 +377,74 @@ import GHC.Platform.Reg # define ft10 62 # define ft11 63 +#elif defined(MACHREGS_loongarch64) + +# define zero 0 +# define ra 1 +# define tp 2 +# define sp 3 +# define a0 4 +# define a1 5 +# define a2 6 +# define a3 7 +# define a4 8 +# define a5 9 +# define a6 10 +# define a7 11 +# define t0 12 +# define t1 13 +# define t2 14 +# define t3 15 +# define t4 16 +# define t5 17 +# define t6 18 +# define t7 19 +# define t8 20 +# define u0 21 +# define fp 22 +# define s0 23 +# define s1 24 +# define s2 25 +# define s3 26 +# define s4 27 +# define s5 28 +# define s6 29 +# define s7 30 +# define s8 31 + +# define fa0 32 +# define fa1 33 +# define fa2 34 +# define fa3 35 +# define fa4 36 +# define fa5 37 +# define fa6 38 +# define fa7 39 +# define ft0 40 +# define ft1 41 +# define ft2 42 +# define ft3 43 +# define ft4 44 +# define ft5 45 +# define ft6 46 +# define ft7 47 +# define ft8 48 +# define ft9 49 +# define ft10 50 +# define ft11 51 +# define ft12 52 +# define ft13 53 +# define ft14 54 +# define ft15 55 +# define fs0 56 +# define fs1 57 +# define fs2 58 +# define fs3 59 +# define fs4 60 +# define fs5 61 +# define fs6 62 +# define fs7 63 + #endif callerSaves :: GlobalReg -> Bool @@ -665,7 +733,9 @@ globalRegMaybe :: GlobalReg -> Maybe RealReg || defined(MACHREGS_powerpc) \ || defined(MACHREGS_arm) || defined(MACHREGS_aarch64) \ || defined(MACHREGS_s390x) || defined(MACHREGS_riscv64) \ - || defined(MACHREGS_wasm32) + || defined(MACHREGS_wasm32) \ + || defined(MACHREGS_loongarch64) + # if defined(REG_Base) globalRegMaybe BaseReg = Just (RealRegSingle REG_Base) # endif ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -166,6 +166,7 @@ nativeCodeGen logger config modLoc h us cmms ArchMipseb -> panic "nativeCodeGen: No NCG for mipseb" ArchMipsel -> panic "nativeCodeGen: No NCG for mipsel" ArchRISCV64 -> panic "nativeCodeGen: No NCG for RISCV64" + ArchLoongArch64->panic "nativeCodeGen: No NCG for LoongArch64" ArchUnknown -> panic "nativeCodeGen: No NCG for unknown arch" ArchJavaScript-> panic "nativeCodeGen: No NCG for JavaScript" ArchWasm32 -> Wasm32.ncgWasm platform us modLoc h cmms ===================================== compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs ===================================== @@ -118,6 +118,7 @@ trivColorable platform virtualRegSqueeze realRegSqueeze RcInteger conflicts excl ArchMipsel -> panic "trivColorable ArchMipsel" ArchS390X -> panic "trivColorable ArchS390X" ArchRISCV64 -> panic "trivColorable ArchRISCV64" + ArchLoongArch64->panic "trivColorable ArchLoongArch64" ArchJavaScript-> panic "trivColorable ArchJavaScript" ArchWasm32 -> panic "trivColorable ArchWasm32" ArchUnknown -> panic "trivColorable ArchUnknown") @@ -152,6 +153,7 @@ trivColorable platform virtualRegSqueeze realRegSqueeze RcFloat conflicts exclus ArchMipsel -> panic "trivColorable ArchMipsel" ArchS390X -> panic "trivColorable ArchS390X" ArchRISCV64 -> panic "trivColorable ArchRISCV64" + ArchLoongArch64->panic "trivColorable ArchLoongArch64" ArchJavaScript-> panic "trivColorable ArchJavaScript" ArchWasm32 -> panic "trivColorable ArchWasm32" ArchUnknown -> panic "trivColorable ArchUnknown") @@ -185,6 +187,7 @@ trivColorable platform virtualRegSqueeze realRegSqueeze RcDouble conflicts exclu ArchMipsel -> panic "trivColorable ArchMipsel" ArchS390X -> panic "trivColorable ArchS390X" ArchRISCV64 -> panic "trivColorable ArchRISCV64" + ArchLoongArch64->panic "trivColorable ArchLoongArch64" ArchJavaScript-> panic "trivColorable ArchJavaScript" ArchWasm32 -> panic "trivColorable ArchWasm32" ArchUnknown -> panic "trivColorable ArchUnknown") ===================================== compiler/GHC/CmmToAsm/Reg/Linear.hs ===================================== @@ -224,6 +224,7 @@ linearRegAlloc config entry_ids block_live sccs ArchMipseb -> panic "linearRegAlloc ArchMipseb" ArchMipsel -> panic "linearRegAlloc ArchMipsel" ArchRISCV64 -> panic "linearRegAlloc ArchRISCV64" + ArchLoongArch64-> panic "linearRegAlloc ArchLoongArch64" ArchJavaScript -> panic "linearRegAlloc ArchJavaScript" ArchWasm32 -> panic "linearRegAlloc ArchWasm32" ArchUnknown -> panic "linearRegAlloc ArchUnknown" ===================================== compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs ===================================== @@ -77,6 +77,7 @@ maxSpillSlots config = case platformArch (ncgPlatform config) of ArchMipseb -> panic "maxSpillSlots ArchMipseb" ArchMipsel -> panic "maxSpillSlots ArchMipsel" ArchRISCV64 -> panic "maxSpillSlots ArchRISCV64" + ArchLoongArch64->panic "maxSpillSlots ArchLoongArch64" ArchJavaScript-> panic "maxSpillSlots ArchJavaScript" ArchWasm32 -> panic "maxSpillSlots ArchWasm32" ArchUnknown -> panic "maxSpillSlots ArchUnknown" ===================================== compiler/GHC/CmmToAsm/Reg/Target.hs ===================================== @@ -50,6 +50,7 @@ targetVirtualRegSqueeze platform ArchMipseb -> panic "targetVirtualRegSqueeze ArchMipseb" ArchMipsel -> panic "targetVirtualRegSqueeze ArchMipsel" ArchRISCV64 -> panic "targetVirtualRegSqueeze ArchRISCV64" + ArchLoongArch64->panic "targetVirtualRegSqueeze ArchLoongArch64" ArchJavaScript-> panic "targetVirtualRegSqueeze ArchJavaScript" ArchWasm32 -> panic "targetVirtualRegSqueeze ArchWasm32" ArchUnknown -> panic "targetVirtualRegSqueeze ArchUnknown" @@ -69,6 +70,7 @@ targetRealRegSqueeze platform ArchMipseb -> panic "targetRealRegSqueeze ArchMipseb" ArchMipsel -> panic "targetRealRegSqueeze ArchMipsel" ArchRISCV64 -> panic "targetRealRegSqueeze ArchRISCV64" + ArchLoongArch64->panic "targetRealRegSqueeze ArchLoongArch64" ArchJavaScript-> panic "targetRealRegSqueeze ArchJavaScript" ArchWasm32 -> panic "targetRealRegSqueeze ArchWasm32" ArchUnknown -> panic "targetRealRegSqueeze ArchUnknown" @@ -87,6 +89,7 @@ targetClassOfRealReg platform ArchMipseb -> panic "targetClassOfRealReg ArchMipseb" ArchMipsel -> panic "targetClassOfRealReg ArchMipsel" ArchRISCV64 -> panic "targetClassOfRealReg ArchRISCV64" + ArchLoongArch64->panic "targetClassOfRealReg ArchLoongArch64" ArchJavaScript-> panic "targetClassOfRealReg ArchJavaScript" ArchWasm32 -> panic "targetClassOfRealReg ArchWasm32" ArchUnknown -> panic "targetClassOfRealReg ArchUnknown" @@ -105,6 +108,7 @@ targetMkVirtualReg platform ArchMipseb -> panic "targetMkVirtualReg ArchMipseb" ArchMipsel -> panic "targetMkVirtualReg ArchMipsel" ArchRISCV64 -> panic "targetMkVirtualReg ArchRISCV64" + ArchLoongArch64->panic "targetMkVirtualReg ArchLoongArch64" ArchJavaScript-> panic "targetMkVirtualReg ArchJavaScript" ArchWasm32 -> panic "targetMkVirtualReg ArchWasm32" ArchUnknown -> panic "targetMkVirtualReg ArchUnknown" @@ -123,6 +127,7 @@ targetRegDotColor platform ArchMipseb -> panic "targetRegDotColor ArchMipseb" ArchMipsel -> panic "targetRegDotColor ArchMipsel" ArchRISCV64 -> panic "targetRegDotColor ArchRISCV64" + ArchLoongArch64->panic "targetRegDotColor ArchLoongArch64" ArchJavaScript-> panic "targetRegDotColor ArchJavaScript" ArchWasm32 -> panic "targetRegDotColor ArchWasm32" ArchUnknown -> panic "targetRegDotColor ArchUnknown" ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -1015,6 +1015,7 @@ llvmOptions llvm_config dflags = abi :: String abi = case platformArch (targetPlatform dflags) of ArchRISCV64 -> "lp64d" + ArchLoongArch64 -> "lp64d" _ -> "" -- | What phase to run after one of the backend code generators has run ===================================== compiler/GHC/Platform.hs ===================================== @@ -263,6 +263,7 @@ platformCConvNeedsExtension platform = case platformArch platform of ArchPPC_64 _ -> True ArchS390X -> True ArchRISCV64 -> True + ArchLoongArch64 -> True ArchAArch64 -- Apple's AArch64 ABI requires that the caller sign-extend -- small integer arguments. See ===================================== compiler/GHC/Platform/LoongArch64.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE CPP #-} + +module GHC.Platform.LoongArch64 where + +import GHC.Prelude + +#define MACHREGS_NO_REGS 0 +#define MACHREGS_loongarch64 1 +#include "CodeGen.Platform.h" \ No newline at end of file ===================================== compiler/GHC/Platform/Regs.hs ===================================== @@ -16,6 +16,7 @@ import qualified GHC.Platform.X86 as X86 import qualified GHC.Platform.X86_64 as X86_64 import qualified GHC.Platform.RISCV64 as RISCV64 import qualified GHC.Platform.Wasm32 as Wasm32 +import qualified GHC.Platform.LoongArch64 as LoongArch64 import qualified GHC.Platform.NoRegs as NoRegs -- | Returns 'True' if this global register is stored in a caller-saves @@ -33,6 +34,7 @@ callerSaves platform ArchAArch64 -> AArch64.callerSaves ArchRISCV64 -> RISCV64.callerSaves ArchWasm32 -> Wasm32.callerSaves + ArchLoongArch64 -> LoongArch64.callerSaves arch | arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] -> PPC.callerSaves @@ -56,6 +58,7 @@ activeStgRegs platform ArchAArch64 -> AArch64.activeStgRegs ArchRISCV64 -> RISCV64.activeStgRegs ArchWasm32 -> Wasm32.activeStgRegs + ArchLoongArch64 -> LoongArch64.activeStgRegs arch | arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] -> PPC.activeStgRegs @@ -74,6 +77,7 @@ haveRegBase platform ArchAArch64 -> AArch64.haveRegBase ArchRISCV64 -> RISCV64.haveRegBase ArchWasm32 -> Wasm32.haveRegBase + ArchLoongArch64 -> LoongArch64.haveRegBase arch | arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] -> PPC.haveRegBase @@ -92,6 +96,7 @@ globalRegMaybe platform ArchAArch64 -> AArch64.globalRegMaybe ArchRISCV64 -> RISCV64.globalRegMaybe ArchWasm32 -> Wasm32.globalRegMaybe + ArchLoongArch64 -> LoongArch64.globalRegMaybe arch | arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] -> PPC.globalRegMaybe @@ -110,6 +115,7 @@ freeReg platform ArchAArch64 -> AArch64.freeReg ArchRISCV64 -> RISCV64.freeReg ArchWasm32 -> Wasm32.freeReg + ArchLoongArch64 -> LoongArch64.freeReg arch | arch `elem` [ArchPPC, ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2] -> PPC.freeReg ===================================== compiler/ghc.cabal.in ===================================== @@ -569,6 +569,7 @@ Library GHC.Platform.Reg.Class GHC.Platform.Regs GHC.Platform.RISCV64 + GHC.Platform.LoongArch64 GHC.Platform.S390X GHC.Platform.Wasm32 GHC.Platform.Ways ===================================== configure.ac ===================================== @@ -333,7 +333,7 @@ AC_SUBST(TablesNextToCode) dnl ** Does target have runtime linker support? dnl -------------------------------------------------------------- case "$target" in - powerpc64-*|powerpc64le-*|powerpc-ibm-aix*|s390x-ibm-linux|riscv64-*|wasm*|js-*) + powerpc64-*|powerpc64le-*|powerpc-ibm-aix*|s390x-ibm-linux|riscv64-*|wasm*|js-*|loongarch64-*) TargetHasRTSLinker=NO ;; *) ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -118,7 +118,8 @@ targetSupportsSMP = do , "arm" , "aarch64" , "s390x" - , "riscv64"] + , "riscv64" + , "loongarch64"] if -- The THREADED_RTS requires `BaseReg` to be in a register and the -- Unregisterised mode doesn't allow that. | unreg -> return False ===================================== libraries/base/System/Info.hs ===================================== @@ -89,6 +89,8 @@ os = HOST_OS -- * "powerpc64le" -- * "riscv32" -- * "riscv64" +-- * "loongarch32" +-- * "loongarch64" -- * "rs6000" -- * "s390" -- * "s390x" ===================================== libraries/ghc-boot/GHC/Platform/ArchOS.hs ===================================== @@ -44,6 +44,7 @@ data Arch | ArchMipseb | ArchMipsel | ArchRISCV64 + | ArchLoongArch64 | ArchJavaScript | ArchWasm32 deriving (Read, Show, Eq, Ord) @@ -134,6 +135,7 @@ stringEncodeArch = \case ArchMipseb -> "mipseb" ArchMipsel -> "mipsel" ArchRISCV64 -> "riscv64" + ArchLoongArch64 -> "loongarch64" ArchJavaScript -> "js" ArchWasm32 -> "wasm32" ===================================== llvm-targets ===================================== @@ -43,6 +43,8 @@ ,("s390x-ibm-linux", ("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64", "z10", "")) ,("riscv64-unknown-linux-gnu", ("e-m:e-p:64:64-i64:64-i128:128-n64-S128", "", "+m +a +f +d +c +relax")) ,("riscv64-unknown-linux", ("e-m:e-p:64:64-i64:64-i128:128-n64-S128", "", "+m +a +f +d +c +relax")) +,("loongarch64-unknown-linux-gnu", ("e-m:e-p:64:64-i64:64-i128:128-n64-S128", "", "+f +d")) +,("loongarch64-unknown-linux", ("e-m:e-p:64:64-i64:64-i128:128-n64-S128", "", "+f +d")) ,("i386-apple-darwin", ("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:128-n8:16:32-S128", "penryn", "")) ,("x86_64-apple-darwin", ("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", "penryn", "")) ,("arm64-apple-darwin", ("e-m:o-i64:64-i128:128-n32:64-S128", "generic", "+v8.3a +fp-armv8 +neon +crc +crypto +fullfp16 +ras +lse +rdm +rcpc +zcm +zcz +sha2 +aes")) ===================================== m4/fptools_set_haskell_platform_vars.m4 ===================================== @@ -45,7 +45,10 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS_SHELL_FUNCTIONS], wasm32) test -z "[$]2" || eval "[$]2=ArchWasm32" ;; - hppa|hppa1_1|ia64|m68k|nios2|riscv32|rs6000|s390|sh4|vax) + loongarch64) + test -z "[$]2" || eval "[$]2=ArchLoongArch64" + ;; + hppa|hppa1_1|ia64|m68k|nios2|riscv32|loongarch32|rs6000|s390|sh4|vax) test -z "[$]2" || eval "[$]2=ArchUnknown" ;; js) ===================================== m4/ghc_convert_cpu.m4 ===================================== @@ -56,6 +56,12 @@ case "$1" in riscv|riscv32*) $2="riscv32" ;; + loongarch64*) + $2="loongarch64" + ;; + loongarch32*) + $2="loongarch32" + ;; rs6000) $2="rs6000" ;; ===================================== m4/ghc_tables_next_to_code.m4 ===================================== @@ -17,7 +17,7 @@ AC_DEFUN([GHC_TABLES_NEXT_TO_CODE], case "$Unregisterised" in NO) case "$TargetArch" in - ia64|powerpc64|powerpc64le|s390x|wasm32) + ia64|powerpc64|powerpc64le|s390x|wasm32|loongarch64) TablesNextToCodeDefault=NO AC_MSG_RESULT([no]) ;; ===================================== m4/ghc_unregisterised.m4 ===================================== @@ -5,7 +5,7 @@ AC_DEFUN([GHC_UNREGISTERISED], [ AC_MSG_CHECKING(whether target supports a registerised ABI) case "$TargetArch" in - i386|x86_64|powerpc|powerpc64|powerpc64le|s390x|arm|aarch64|riscv64|wasm32|js) + i386|x86_64|powerpc|powerpc64|powerpc64le|s390x|arm|aarch64|riscv64|wasm32|js|loongarch64) UnregisterisedDefault=NO AC_MSG_RESULT([yes]) ;; ===================================== rts/StgCRunAsm.S ===================================== @@ -370,6 +370,126 @@ StgReturn: ret .cfi_endproc .size StgReturn, .-StgReturn + +#elif defined(loongarch64_HOST_ARCH) +# define STACK_FRAME_SIZE (RESERVED_C_STACK_BYTES+160) + .text + .align 1 + .globl StgRun + .type StgRun, @function +StgRun: + .cfi_startproc + addi.d $sp,$sp,-160 + .cfi_def_cfa_offset 160 + /* save callee-saved registers plus ra */ + st.d $ra,$sp,152 + st.d $fp,$sp,144 + st.d $s0,$sp,136 + st.d $s1,$sp,128 + st.d $s2,$sp,120 + st.d $s3,$sp,112 + st.d $s4,$sp,104 + st.d $s5,$sp,96 + st.d $s6,$sp,88 + st.d $s7,$sp,80 + st.d $s8,$sp,72 + fst.d $fs0,$sp,56 + fst.d $fs1,$sp,48 + fst.d $fs2,$sp,40 + fst.d $fs3,$sp,32 + fst.d $fs4,$sp,24 + fst.d $fs5,$sp,16 + fst.d $fs6,$sp,8 + fst.d $fs7,$sp,0 + /* allocate stack frame */ + li.d $t0,RESERVED_C_STACK_BYTES + sub.d $sp,$sp,$t0 + .cfi_def_cfa_offset STACK_FRAME_SIZE + .cfi_offset 1, -8 + .cfi_offset 22, -16 + .cfi_offset 23, -24 + .cfi_offset 24, -32 + .cfi_offset 25, -40 + .cfi_offset 26, -48 + .cfi_offset 27, -56 + .cfi_offset 28, -64 + .cfi_offset 29, -72 + .cfi_offset 30, -80 + .cfi_offset 31, -88 + .cfi_offset 56, -104 + .cfi_offset 57, -112 + .cfi_offset 58, -120 + .cfi_offset 59, -128 + .cfi_offset 60, -136 + .cfi_offset 61, -144 + .cfi_offset 62, -152 + .cfi_offset 63, -160 + /* set STGs BaseReg from LoongArch a1 */ + move $s0,$a1 + /* jump to STG function */ + jr $a0 + .cfi_endproc + .size StgRun, .-StgRun + + .text + .align 2 + .globl StgReturn + .type StgReturn, @function +StgReturn: + .cfi_startproc + /* set return value from STGs R1 (LoongArch64 s3) */ + move $a0,$s3 + /* deallocate stack frame */ + li.d $t0,RESERVED_C_STACK_BYTES + add.d $sp,$sp,$t0 + .cfi_def_cfa_offset 160 + /* restore callee-saved registers and ra */ + ld.d $ra,$sp,152 + .cfi_restore 1 + ld.d $fp,$sp,144 + .cfi_restore 22 + ld.d $s0,$sp,136 + .cfi_restore 23 + ld.d $s1,$sp,128 + .cfi_restore 24 + ld.d $s2,$sp,120 + .cfi_restore 25 + ld.d $s3,$sp,112 + .cfi_restore 26 + ld.d $s4,$sp,104 + .cfi_restore 27 + ld.d $s5,$sp,96 + .cfi_restore 28 + ld.d $s6,$sp,88 + .cfi_restore 29 + ld.d $s7,$sp,80 + .cfi_restore 30 + ld.d $s8,$sp,72 + .cfi_restore 31 + fld.d $fs0,$sp,56 + .cfi_restore 56 + fld.d $fs1,$sp,48 + .cfi_restore 57 + fld.d $fs2,$sp,40 + .cfi_restore 58 + fld.d $fs3,$sp,32 + .cfi_restore 59 + fld.d $fs4,$sp,24 + .cfi_restore 60 + fld.d $fs5,$sp,16 + .cfi_restore 61 + fld.d $fs6,$sp,8 + .cfi_restore 62 + fld.d $fs7,$sp,0 + .cfi_restore 63 + addi.d $sp,$sp,160 + .cfi_def_cfa_offset 0 + /* jump back to caller of StgRun() */ + ret + .cfi_endproc + .size StgReturn, .-StgReturn + + .section .note.GNU-stack,"", at progbits #endif #endif /* !USE_MINIINTERPRETER */ ===================================== rts/include/stg/MachRegs.h ===================================== @@ -626,6 +626,57 @@ the stack. See Note [Overlapping global registers] for implications. #define REG_HpLim 27 #define REG_CCCS 28 +/* ----------------------------------------------------------------------------- + The loongarch64 register mapping + + Register | Role(s) | Call effect + ------------+-----------------------------------------+------------- + zero | Hard-wired zero | - + ra | Return address | caller-saved + tp | Thread pointer | - + sp | Stack pointer | callee-saved + a0,a1 | Arguments / return values | caller-saved + a2..a7 | Arguments | caller-saved + t0..t8 | - | caller-saved + u0 | Reserve | - + fp | Frame pointer | callee-saved + s0..s8 | - | callee-saved + fa0,fa1 | Arguments / return values | caller-saved + fa2..fa7 | Arguments | caller-saved + ft0..ft15 | - | caller-saved + fs0..fs7 | - | callee-saved + + Each general purpose register as well as each floating-point + register is 64 bits wide, also, the u0 register is called r21 in some cases. + + -------------------------------------------------------------------------- */ +#elif defined(MACHREGS_loongarch64) + +#define REG(x) __asm__("$" #x) + +#define REG_Base s0 +#define REG_Sp s1 +#define REG_Hp s2 +#define REG_R1 s3 +#define REG_R2 s4 +#define REG_R3 s5 +#define REG_R4 s6 +#define REG_R5 s7 +#define REG_SpLim s8 + +#define REG_F1 fs0 +#define REG_F2 fs1 +#define REG_F3 fs2 +#define REG_F4 fs3 + +#define REG_D1 fs4 +#define REG_D2 fs5 +#define REG_D3 fs6 +#define REG_D4 fs7 + +#define MAX_REAL_FLOAT_REG 4 +#define MAX_REAL_DOUBLE_REG 4 + #else #error Cannot find platform to give register info for ===================================== rts/include/stg/MachRegsForHost.h ===================================== @@ -79,6 +79,10 @@ #define MACHREGS_NO_REGS 1 #endif +#if defined(loongarch64_HOST_ARCH) +#define MACHREGS_loongarch64 1 +#endif + #endif #include "MachRegs.h" ===================================== rts/include/stg/SMP.h ===================================== @@ -393,6 +393,8 @@ write_barrier(void) { __asm__ __volatile__ ("dmb st" : : : "memory"); #elif defined(riscv64_HOST_ARCH) __asm__ __volatile__ ("fence w,w" : : : "memory"); +#elif defined(loongarch64_HOST_ARCH) + __asm__ __volatile__ ("dbar 0" : : : "memory"); #else #error memory barriers unimplemented on this architecture #endif @@ -417,6 +419,8 @@ store_load_barrier(void) { __asm__ __volatile__ ("dmb sy" : : : "memory"); #elif defined(riscv64_HOST_ARCH) __asm__ __volatile__ ("fence w,r" : : : "memory"); +#elif defined(loongarch64_HOST_ARCH) + __asm__ __volatile__ ("dbar 0" : : : "memory"); #else #error memory barriers unimplemented on this architecture #endif @@ -441,6 +445,8 @@ load_load_barrier(void) { __asm__ __volatile__ ("dmb ld" : : : "memory"); #elif defined(riscv64_HOST_ARCH) __asm__ __volatile__ ("fence r,r" : : : "memory"); +#elif defined(loongarch64_HOST_ARCH) + __asm__ __volatile__ ("dbar 0" : : : "memory"); #else #error memory barriers unimplemented on this architecture #endif ===================================== rts/linker/Elf.c ===================================== @@ -416,6 +416,12 @@ ocVerifyImage_ELF ( ObjectCode* oc ) errorBelch("%s: RTS linker not implemented on riscv", oc->fileName); return 0; +#endif +#if defined(EM_LOONGARCH) + case EM_LOONGARCH: IF_DEBUG(linker,debugBelch( "loongarch64" )); + errorBelch("%s: RTS linker not implemented on loongarch64", + oc->fileName); + return 0; #endif default: IF_DEBUG(linker,debugBelch( "unknown" )); errorBelch("%s: unknown architecture (e_machine == %d)" ===================================== rts/rts.cabal.in ===================================== @@ -516,7 +516,7 @@ library c-sources: adjustor/NativeIA64.c -- Use assembler STG entrypoint on architectures where it is used - if arch(ppc) || arch(ppc64) || arch(s390x) || arch(riscv64) + if arch(ppc) || arch(ppc64) || arch(s390x) || arch(riscv64) || arch(loongarch64) asm-sources: StgCRunAsm.S c-sources: Adjustor.c ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -155,6 +155,7 @@ GHC.Platform GHC.Platform.AArch64 GHC.Platform.ARM GHC.Platform.Constants +GHC.Platform.LoongArch64 GHC.Platform.NoRegs GHC.Platform.PPC GHC.Platform.Profile ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -162,6 +162,7 @@ GHC.Platform GHC.Platform.AArch64 GHC.Platform.ARM GHC.Platform.Constants +GHC.Platform.LoongArch64 GHC.Platform.NoRegs GHC.Platform.PPC GHC.Platform.Profile ===================================== utils/llvm-targets/gen-data-layout.sh ===================================== @@ -82,6 +82,9 @@ TARGETS=( # Linux riscv64 "riscv64-unknown-linux-gnu" "riscv64-unknown-linux" + # Linux loongarch64 + "loongarch64-unknown-linux-gnu" + "loongarch64-unknown-linux" ######################### # Darwin View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea25088d4edd9f96e48f0a7f9407fd8eb9c2ae9c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea25088d4edd9f96e48f0a7f9407fd8eb9c2ae9c You're receiving 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 Dec 9 03:47:08 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:47:08 -0500 Subject: [Git][ghc/ghc][master] 4 commits: Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD Message-ID: <6392afbc3c3a4_224fca60680706961@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 15 changed files: - hadrian/cabal.project - hadrian/hadrian.cabal - libraries/Cabal - libraries/mtl - libraries/parsec - testsuite/tests/deriving/should_compile/deriving-via-compile.hs - testsuite/tests/driver/T4437.hs - testsuite/tests/haddock/perf/Makefile - testsuite/tests/module/mod133.hs - testsuite/tests/simplCore/should_compile/T17810a.hs - testsuite/tests/typecheck/should_compile/tc223.hs - testsuite/tests/typecheck/should_run/T4809_XMLGenerator.hs - utils/check-exact/ExactPrint.hs - utils/check-exact/Parsers.hs - utils/check-exact/Utils.hs Changes: ===================================== hadrian/cabal.project ===================================== @@ -1,7 +1,7 @@ packages: ./ -- This essentially freezes the build plan for hadrian -index-state: 2022-09-10T18:46:55Z +index-state: 2022-11-19T22:13:06Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. ===================================== hadrian/hadrian.cabal ===================================== @@ -155,7 +155,7 @@ executable hadrian , extra >= 1.4.7 , filepath , time - , mtl == 2.2.* + , mtl >= 2.2 && < 2.4 , parsec >= 3.1 && < 3.2 , shake >= 0.18.3 && < 0.20 , transformers >= 0.4 && < 0.6 ===================================== libraries/Cabal ===================================== @@ -1 +1 @@ -Subproject commit 410f871df899e5af0847089354e0031fe051551d +Subproject commit 6cd29789ca866464dc3af89f62c98c41264ce3cd ===================================== libraries/mtl ===================================== @@ -1 +1 @@ -Subproject commit c7d396732bd45e409478bd4df1d0ca95d6f39356 +Subproject commit 37cbd924cb71eba591a2e2b6b131767f632d22c9 ===================================== libraries/parsec ===================================== @@ -1 +1 @@ -Subproject commit a74c68e948c99621100447014f48ccac7ee0448e +Subproject commit f1171a4b212070bb0299b636aeee7d0534a6c76c ===================================== testsuite/tests/deriving/should_compile/deriving-via-compile.hs ===================================== @@ -25,6 +25,7 @@ import Data.Complex import Data.Functor.Const import Data.Functor.Identity import Data.Ratio +import Control.Monad (liftM, ap) import Control.Monad.Reader import Control.Monad.State import Control.Monad.Writer ===================================== testsuite/tests/driver/T4437.hs ===================================== @@ -37,8 +37,7 @@ check title expected got -- See Note [Adding a language extension] in compiler/GHC/Driver/Session.hs. expectedGhcOnlyExtensions :: [String] expectedGhcOnlyExtensions = - [ "DeepSubsumption" - , "TypeData" + [ ] expectedCabalOnlyExtensions :: [String] @@ -54,5 +53,7 @@ expectedCabalOnlyExtensions = ["Generics", "Unsafe", "Trustworthy", "MonadFailDesugaring", - "MonoPatBinds" + "MonoPatBinds", + -- https://github.com/haskell/cabal/pull/8521 + "RequiredTypeArguments" ] ===================================== testsuite/tests/haddock/perf/Makefile ===================================== @@ -12,4 +12,4 @@ haddock_parser_perf : haddock_renamer_perf : WithoutHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fforce-recomp -Wno-all -ddump-timings -O0 Fold.hs 2>/dev/null | grep Renamer | egrep -o 'alloc=[0-9]+' | cut -c7- ) ; \ WithHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fforce-recomp -Wno-all -ddump-timings -haddock -O0 Fold.hs 2>/dev/null | grep Renamer | egrep -o 'alloc=[0-9]+' | cut -c7- ) ; \ - awk "BEGIN { ratio = ($$WithHaddock / $$WithoutHaddock); if (ratio > 1.05) {print \"-haddock allocation ratio too high:\", ratio; exit 1} else {exit 0} }" + awk "BEGIN { ratio = ($$WithHaddock / $$WithoutHaddock); if (ratio > 1.20) {print \"-haddock allocation ratio too high:\", ratio; exit 1} else {exit 0} }" ===================================== testsuite/tests/module/mod133.hs ===================================== @@ -1,4 +1,4 @@ --- Control.Monad.Except re-exports Control.Monad.Fix. +-- Control.Monad re-exports Control.Monad.Fail. -- This test checks that the subordinate-name test -- for a class operation (when renaming the instance decl) -- works correctly. @@ -6,7 +6,6 @@ module ShouldCompile where import Control.Monad -import Control.Monad.Except data Foo a = Foo a @@ -21,5 +20,5 @@ instance Monad Foo where return = pure (Foo a) >>= k = k a -instance MonadFix Foo where - mfix = undefined +instance MonadFail Foo where + fail = undefined ===================================== testsuite/tests/simplCore/should_compile/T17810a.hs ===================================== @@ -1,6 +1,9 @@ module T17810a where +import Control.Monad +import Control.Monad.IO.Class import Control.Monad.Except +import Control.Monad.Trans class Monad m => ReadTCState m where locallyTCState :: m () ===================================== testsuite/tests/typecheck/should_compile/tc223.hs ===================================== @@ -5,11 +5,8 @@ module Foo where -- This example suggested by Yitzchak Gale import Control.Monad.State -import Control.Monad.Error -class Error e => Game b mv e | b -> mv e where +class Game b mv e | b -> mv e where newBoard :: MonadState b m => m () -- This method is unambiguous, because -- m determines b (via a fundep in MonadState) - - ===================================== testsuite/tests/typecheck/should_run/T4809_XMLGenerator.hs ===================================== @@ -22,7 +22,7 @@ import Control.Applicative import Control.Monad import Control.Monad.Trans import Control.Monad.Cont (MonadCont) -import Control.Monad.Error (MonadError) +import Control.Monad.Except(MonadError) import Control.Monad.Reader(MonadReader) import Control.Monad.Writer(MonadWriter) import Control.Monad.State (MonadState) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -50,9 +50,11 @@ import GHC.Utils.Panic import Language.Haskell.Syntax.Basic (FieldLabelString(..)) -import Control.Monad.Identity +import Control.Monad (forM, when, unless) +import Control.Monad.Identity (Identity(..)) import qualified Control.Monad.Reader as Reader -import Control.Monad.RWS +import Control.Monad.RWS (MonadReader, RWST, evalRWST, tell, modify, get, gets, ask) +import Control.Monad.Trans (lift) import Data.Data ( Data ) import Data.Dynamic import Data.Foldable ===================================== utils/check-exact/Parsers.hs ===================================== @@ -47,7 +47,7 @@ module Parsers ( import Preprocess -import Control.Monad.RWS +import Data.Functor (void) import qualified GHC hiding (parseModule) import qualified Control.Monad.IO.Class as GHC ===================================== utils/check-exact/Utils.hs ===================================== @@ -18,7 +18,8 @@ module Utils -- , isGoodDelta -- ) where where -import Control.Monad.State + +import Control.Monad (when) import Data.Function import Data.Maybe (isJust) import Data.Ord (comparing) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea25088d4edd9f96e48f0a7f9407fd8eb9c2ae9c...ef702a18dbe44d486d7a41c554564ca3e0f236ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ea25088d4edd9f96e48f0a7f9407fd8eb9c2ae9c...ef702a18dbe44d486d7a41c554564ca3e0f236ee You're receiving 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 Dec 9 03:47:42 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:47:42 -0500 Subject: [Git][ghc/ghc][master] Make (^) INLINE (#22324) Message-ID: <6392afde5396f_224fca526d471195b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 2 changed files: - libraries/base/GHC/Real.hs - testsuite/tests/simplCore/should_compile/T12603.stdout Changes: ===================================== libraries/base/GHC/Real.hs ===================================== @@ -671,27 +671,37 @@ odd = not . even ------------------------------------------------------- -- | raise a number to a non-negative integral power -{-# SPECIALISE [1] (^) :: - Integer -> Integer -> Integer, - Integer -> Int -> Integer, - Int -> Int -> Int #-} -{-# INLINABLE [1] (^) #-} -- See Note [Inlining (^)] +{-# INLINE [1] (^) #-} -- See Note [Inlining (^)] (^) :: (Num a, Integral b) => a -> b -> a x0 ^ y0 | y0 < 0 = errorWithoutStackTrace "Negative exponent" | y0 == 0 = 1 - | otherwise = f x0 y0 - where -- f : x0 ^ y0 = x ^ y - f x y | even y = f (x * x) (y `quot` 2) - | y == 1 = x - | otherwise = g (x * x) (y `quot` 2) x -- See Note [Half of y - 1] - -- g : x0 ^ y0 = (x ^ y) * z - g x y z | even y = g (x * x) (y `quot` 2) z - | y == 1 = x * z - | otherwise = g (x * x) (y `quot` 2) (x * z) -- See Note [Half of y - 1] + | otherwise = powImpl x0 y0 + +{-# SPECIALISE powImpl :: + Integer -> Integer -> Integer, + Integer -> Int -> Integer, + Int -> Int -> Int #-} +{-# INLINABLE powImpl #-} -- See Note [Inlining (^)] +powImpl :: (Num a, Integral b) => a -> b -> a +-- powImpl : x0 ^ y0 = (x ^ y) +powImpl x y | even y = powImpl (x * x) (y `quot` 2) + | y == 1 = x + | otherwise = powImplAcc (x * x) (y `quot` 2) x -- See Note [Half of y - 1] + +{-# SPECIALISE powImplAcc :: + Integer -> Integer -> Integer -> Integer, + Integer -> Int -> Integer -> Integer, + Int -> Int -> Int -> Int #-} +{-# INLINABLE powImplAcc #-} -- See Note [Inlining (^)] +powImplAcc :: (Num a, Integral b) => a -> b -> a -> a +-- powImplAcc : x0 ^ y0 = (x ^ y) * z +powImplAcc x y z | even y = powImplAcc (x * x) (y `quot` 2) z + | y == 1 = x * z + | otherwise = powImplAcc (x * x) (y `quot` 2) (x * z) -- See Note [Half of y - 1] -- | raise a number to an integral power (^^) :: (Fractional a, Integral b) => a -> b -> a -{-# INLINABLE [1] (^^) #-} -- See Note [Inlining (^) +{-# INLINE [1] (^^) #-} -- See Note [Inlining (^) x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) {- Note [Half of y - 1] @@ -699,17 +709,40 @@ x ^^ n = if n >= 0 then x^n else recip (x^(negate n)) Since y is guaranteed to be odd and positive here, half of y - 1 can be computed as y `quot` 2, optimising subtraction away. -Note [Inlining (^) -~~~~~~~~~~~~~~~~~~ -The INLINABLE [1] pragma allows (^) to be specialised at its call sites. -If it is called repeatedly at the same type, that can make a huge -difference, because of those constants which can be repeatedly -calculated. +Note [Inlining (^)] +~~~~~~~~~~~~~~~~~~~ +We want to achieve the following: +* Noting that (^) is lazy in its first argument, we'd still like to avoid allocating a box for + the first argument. Example: nofib/imaginary/x2n1, which makes many calls to (^) with + different first arguments each time. + + Solution: split (^) into a small INLINE wrapper that tests the second arg, which then calls the + strict (and recursive) auxiliary function `powImpl`. + +* Don't inline (^) too early because we want rewrite rules to optimise calls to (^) with + small exponents. See Note [Powers with small exponent]. + + Solution: use INLINE[1] to delay inlining to phase 1, giving the rewrite rules time to fire. + +* (^) is overloaded on two different type parameters. We want to specialise. + + Solution: make `powImpl` (and its friend `powImplAcc`) INLINEABLE, so they can be specialised + at call sites. Also give them some common specialisations right here, to avoid duplicating + that specialisation in clients. + +Specialisation can make a huge difference for repeated calls, because of +constants which would otherwise be calculated repeatedly and unboxing of +arguments. -We don't inline until phase 1, to give a chance for the RULES -"^2/Int" etc to fire first. +Why not make (^) strict in `x0` with a bang and make it INLINABLE? Well, because +it is futile: Being strict in the `Complex Double` pair won't be enough to unbox +the `Double`s anyway. Even after deep specisalisation, we will only unbox the +`Double`s when we inline (^), because (^) remains lazy in the `Double` fields. +Given that (^) must always inline to yield good code, we can just as well mark +it as such. -Currently the fromInteger calls are not floated because we get +A small note on perf: Currently the fromInteger calls from the desugaring of +literals are not floated because we get \d1 d2 x y -> blah after the gentle round of simplification. ===================================== testsuite/tests/simplCore/should_compile/T12603.stdout ===================================== @@ -1 +1 @@ -lvl = case GHC.Real.$wf1 2# 8# of v { __DEFAULT -> GHC.Types.I# v } + = case GHC.Real.$w$spowImpl1 2# 8# of v { __DEFAULT -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3144e8ff1bac77f850a6188f6eef20de09915053 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3144e8ff1bac77f850a6188f6eef20de09915053 You're receiving 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 Dec 9 03:48:18 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:48:18 -0500 Subject: [Git][ghc/ghc][master] Typeable: Fix module locations of some definitions in GHC.Types Message-ID: <6392b002e599d_224fca606807172bc@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 4 changed files: - compiler/GHC/Tc/Instance/Typeable.hs - + testsuite/tests/typecheck/should_run/T22510.hs - + testsuite/tests/typecheck/should_run/T22510.stdout - testsuite/tests/typecheck/should_run/all.T Changes: ===================================== compiler/GHC/Tc/Instance/Typeable.hs ===================================== @@ -172,7 +172,7 @@ mkTypeableBinds } } } where needs_typeable_binds tc - | tc `elem` [runtimeRepTyCon, levityTyCon, vecCountTyCon, vecElemTyCon] + | tc `elem` ghcTypesTypeableTyCons = False | otherwise = isAlgTyCon tc @@ -335,7 +335,14 @@ mkPrimTypeableTodos ; todo2 <- todoForTyCons gHC_PRIM ghc_prim_module_id ghcPrimTypeableTyCons - ; return ( gbl_env' , [todo1, todo2]) + ; tcg_env <- getGblEnv + ; let mod_id = case tcg_tr_module tcg_env of -- Should be set by now + Just mod_id -> mod_id + Nothing -> pprPanic "tcMkTypeableBinds" empty + + ; todo3 <- todoForTyCons gHC_TYPES mod_id ghcTypesTypeableTyCons + + ; return ( gbl_env' , [todo1, todo2, todo3]) } else do gbl_env <- getGblEnv return (gbl_env, []) @@ -350,12 +357,18 @@ mkPrimTypeableTodos -- Note [Built-in syntax and the OrigNameCache] in "GHC.Iface.Env" for more. ghcPrimTypeableTyCons :: [TyCon] ghcPrimTypeableTyCons = concat - [ [ runtimeRepTyCon, levityTyCon, vecCountTyCon, vecElemTyCon ] - , map (tupleTyCon Unboxed) [0..mAX_TUPLE_SIZE] + [ map (tupleTyCon Unboxed) [0..mAX_TUPLE_SIZE] , map sumTyCon [2..mAX_SUM_SIZE] , primTyCons ] +-- | These are types which are defined in GHC.Types but are needed in order to +-- typecheck the other generated bindings, therefore to avoid ordering issues we +-- generate them up-front along with the bindings from GHC.Prim. +ghcTypesTypeableTyCons :: [TyCon] +ghcTypesTypeableTyCons = [ runtimeRepTyCon, levityTyCon + , vecCountTyCon, vecElemTyCon ] + data TypeableStuff = Stuff { platform :: Platform -- ^ Target platform , trTyConDataCon :: DataCon -- ^ of @TyCon@ ===================================== testsuite/tests/typecheck/should_run/T22510.hs ===================================== @@ -0,0 +1,36 @@ +{-# LANGUAGE MagicHash, UnboxedTuples, UnboxedSums, ScopedTypeVariables, TypeApplications, AllowAmbiguousTypes #-} +module Main where + +import Type.Reflection +import Data.Proxy +import GHC.Types +import GHC.Prim + +moduleOf :: forall a . Typeable a => String +moduleOf = case someTypeRep (Proxy @a) of + SomeTypeRep tr -> (show tr ++ ": " ++ (tyConModule $ typeRepTyCon tr)) + +main = do + -- These are in GHC.Types + putStrLn $ moduleOf @Levity + putStrLn $ moduleOf @'Lifted + putStrLn $ moduleOf @RuntimeRep + putStrLn $ moduleOf @'IntRep + putStrLn $ moduleOf @'BoxedRep + putStrLn $ moduleOf @'Lifted + putStrLn $ moduleOf @VecCount + putStrLn $ moduleOf @'Vec2 + putStrLn $ moduleOf @VecElem + putStrLn $ moduleOf @'Int8ElemRep + + -- This is from GHC.Tuple + putStrLn $ moduleOf @((),()) + + -- These are in GHC.Prim + putStrLn $ moduleOf @(# () , () #) +-- putStrLn $ moduleOf @(# () | () #) +-- + putStrLn $ moduleOf @(Int64#) + putStrLn $ moduleOf @(Word64#) + putStrLn $ moduleOf @TYPE + putStrLn $ moduleOf @CONSTRAINT ===================================== testsuite/tests/typecheck/should_run/T22510.stdout ===================================== @@ -0,0 +1,16 @@ +Levity: GHC.Types +'Lifted: GHC.Types +RuntimeRep: GHC.Types +'IntRep: GHC.Types +'BoxedRep: GHC.Types +'Lifted: GHC.Types +VecCount: GHC.Types +'Vec2: GHC.Types +VecElem: GHC.Types +'Int8ElemRep: GHC.Types +((),()): GHC.Tuple.Prim +(#,#) ('BoxedRep 'Lifted) ('BoxedRep 'Lifted) () (): GHC.Prim +Int64#: GHC.Prim +Word64#: GHC.Prim +TYPE: GHC.Prim +CONSTRAINT: GHC.Prim ===================================== testsuite/tests/typecheck/should_run/all.T ===================================== @@ -163,3 +163,4 @@ test('T19397M3', extra_files(['T19397S.hs']), compile_and_run, ['-main-is foo']) test('T19397M4', extra_files(['T19397S.hs']), compile_and_run, ['-main-is foo']) test('T19667', normal, compile_and_run, ['-fhpc']) test('T20768', normal, compile_and_run, ['']) +test('T22510', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1d3a8b8ec98e6eedf8943e19780ec374c2491e7f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1d3a8b8ec98e6eedf8943e19780ec374c2491e7f You're receiving 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 Dec 9 03:48:55 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:48:55 -0500 Subject: [Git][ghc/ghc][master] Make `drop` and `dropWhile` fuse (#18964) Message-ID: <6392b027ee7ae_224fca605f4722847@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 4 changed files: - libraries/base/GHC/List.hs - + testsuite/tests/perf/should_run/T18964.hs - + testsuite/tests/perf/should_run/T18964.stdout - testsuite/tests/perf/should_run/all.T Changes: ===================================== libraries/base/GHC/List.hs ===================================== @@ -517,9 +517,9 @@ scanl' = scanlGo' -- See Note [scanl rewrite rules] {-# RULES "scanl'" [~1] forall f a bs . scanl' f a bs = - build (\c n -> a `c` foldr (scanlFB' f c) (flipSeqScanl' n) bs a) + build (\c n -> a `c` foldr (scanlFB' f c) (flipSeq n) bs a) "scanlList'" [1] forall f a bs . - foldr (scanlFB' f (:)) (flipSeqScanl' []) bs a = tail (scanl' f a bs) + foldr (scanlFB' f (:)) (flipSeq []) bs a = tail (scanl' f a bs) #-} {-# INLINE [0] scanlFB' #-} -- See Note [Inline FB functions] @@ -527,10 +527,6 @@ scanlFB' :: (b -> a -> b) -> (b -> c -> c) -> a -> (b -> c) -> b -> c scanlFB' f c = \b g -> oneShot (\x -> let !b' = f x b in b' `c` g b') -- See Note [Left folds via right fold] -{-# INLINE [0] flipSeqScanl' #-} -flipSeqScanl' :: a -> b -> a -flipSeqScanl' a !_b = a - {- Note [scanl rewrite rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -890,12 +886,23 @@ takeWhileFB p c n = \x r -> if p x then x `c` r else n -- [] -- >>> dropWhile (< 0) [1,2,3] -- [1,2,3] +{-# NOINLINE [1] dropWhile #-} dropWhile :: (a -> Bool) -> [a] -> [a] dropWhile _ [] = [] dropWhile p xs@(x:xs') | p x = dropWhile p xs' | otherwise = xs +{-# INLINE [0] dropWhileFB #-} -- See Note [Inline FB functions] +dropWhileFB :: (a -> Bool) -> (a -> b -> b) -> b -> a -> (Bool -> b) -> Bool -> b +dropWhileFB p c _n x xs = \drp -> if drp && p x then xs True else x `c` xs False + +{-# RULES +"dropWhile" [~1] forall p xs. dropWhile p xs = + build (\c n -> foldr (dropWhileFB p c n) (flipSeq n) xs True) +"dropWhileList" [1] forall p xs. foldr (dropWhileFB p (:) []) (flipSeq []) xs True = dropWhile p xs + #-} + -- | 'take' @n@, applied to a list @xs@, returns the prefix of @xs@ -- of length @n@, or @xs@ itself if @n >= 'length' xs at . -- @@ -932,7 +939,7 @@ take n xs | 0 < n = unsafeTake n xs -- A version of take that takes the whole list if it's given an argument less -- than 1. -{-# NOINLINE [1] unsafeTake #-} +{-# NOINLINE [0] unsafeTake #-} -- See Note [Inline FB functions] unsafeTake :: Int -> [a] -> [a] unsafeTake !_ [] = [] unsafeTake 1 (x: _) = [x] @@ -941,20 +948,18 @@ unsafeTake m (x:xs) = x : unsafeTake (m - 1) xs {-# RULES "take" [~1] forall n xs . take n xs = build (\c nil -> if 0 < n - then foldr (takeFB c nil) (flipSeqTake nil) xs n + then foldr (takeFB c nil) (flipSeq nil) xs n else nil) -"unsafeTakeList" [1] forall n xs . foldr (takeFB (:) []) (flipSeqTake []) xs n +"unsafeTakeList" [1] forall n xs . foldr (takeFB (:) []) (flipSeq []) xs n = unsafeTake n xs #-} -{-# INLINE [0] flipSeqTake #-} --- Just flip seq, specialized to Int, but not inlined too early. --- It's important to force the numeric argument here, even though --- it's not used. Otherwise, take n [] doesn't force n. This is --- bad for strictness analysis and unboxing, and leads to increased --- allocation in T7257. -flipSeqTake :: a -> Int -> a -flipSeqTake x !_n = x +{-# INLINE [0] flipSeq #-} +-- Just flip seq, but not inlined too early. +-- It's important to force the argument here, even though it's not used. +-- Otherwise, take n [] can't unbox n, leading to increased allocation in T7257. +flipSeq :: a -> b -> a +flipSeq x !_n = x {-# INLINE [0] takeFB #-} -- See Note [Inline FB functions] takeFB :: (a -> b -> b) -> b -> a -> (Int -> b) -> Int -> b @@ -993,17 +998,31 @@ drop n xs | n <= 0 = xs drop _ [] = [] drop n (_:xs) = drop (n-1) xs #else /* hack away */ -{-# INLINE drop #-} +{-# INLINE[1] drop #-} -- Why [1]? See justification on take! => RULES drop n ls | n <= 0 = ls | otherwise = unsafeDrop n ls - where - -- A version of drop that drops the whole list if given an argument - -- less than 1 - unsafeDrop :: Int -> [a] -> [a] - unsafeDrop !_ [] = [] - unsafeDrop 1 (_:xs) = xs - unsafeDrop m (_:xs) = unsafeDrop (m - 1) xs + +-- A version of drop that drops the whole list if given an argument +-- less than 1 +{-# NOINLINE [0] unsafeDrop #-} -- See Note [Inline FB functions] +unsafeDrop :: Int -> [a] -> [a] +unsafeDrop !_ [] = [] +unsafeDrop 1 (_:xs) = xs +unsafeDrop m (_:xs) = unsafeDrop (m - 1) xs + +{-# RULES +"drop" [~1] forall n xs . drop n xs = + build (\c nil -> if n <= 0 + then foldr c nil xs + else foldr (dropFB c nil) (flipSeq nil) xs n) +"unsafeDropList" [1] forall n xs . foldr (dropFB (:) []) (flipSeq []) xs n + = unsafeDrop n xs + #-} + +{-# INLINE [0] dropFB #-} -- See Note [Inline FB functions] +dropFB :: (a -> b -> b) -> b -> a -> (Int -> b) -> Int -> b +dropFB c _n x xs = \ m -> if m <= 0 then x `c` xs m else xs (m-1) #endif -- | 'splitAt' @n xs@ returns a tuple where first element is @xs@ prefix of ===================================== testsuite/tests/perf/should_run/T18964.hs ===================================== @@ -0,0 +1,15 @@ +import GHC.Exts +import Data.Int + +main :: IO () +main = do + -- drop should fuse away and the program should consume O(1) space + -- If fusion fails, this allocates about 640MB. + print $ sum $ drop 10 [0..10000000::Int64] + -- Here, drop can't fuse. This asserts that we don't regress in allocations in that case either + -- If we don't do a good job here, we'll see more than 6.4MB of allocs. + print $ lazy $ sum $ lazy $ drop 10 $ lazy [0..100000::Int64] + + -- and once more with dropWhile + print $ sum $ dropWhile (< 10) [0..10000000::Int64] + print $ lazy $ sum $ lazy $ dropWhile (< 10) $ lazy [0..100000::Int64] ===================================== testsuite/tests/perf/should_run/T18964.stdout ===================================== @@ -0,0 +1,4 @@ +50000004999955 +5000049955 +50000004999955 +5000049955 ===================================== testsuite/tests/perf/should_run/all.T ===================================== @@ -408,3 +408,5 @@ test('T21839r', only_ways(['normal'])], compile_and_run, ['-O']) + +test('T18964', [collect_stats('bytes allocated', 1), only_ways(['normal'])], compile_and_run, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f7588b5df1fc7a58d8202761bf1501447e48914 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f7588b5df1fc7a58d8202761bf1501447e48914 You're receiving 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 Dec 9 03:49:32 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:49:32 -0500 Subject: [Git][ghc/ghc][master] Do not strictify a DFun's parameter dictionaries (#22549) Message-ID: <6392b04c81e4f_224fca18f7d7547285aa@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/CoreToStg/Prep.hs - + testsuite/tests/stranal/should_run/T22549.hs - + testsuite/tests/stranal/should_run/T22549.stdout - testsuite/tests/stranal/should_run/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -290,8 +290,10 @@ dmdAnalBind dmdAnalBind top_lvl env dmd bind anal_body = case bind of NonRec id rhs | useLetUp top_lvl id - -> dmdAnalBindLetUp top_lvl env id rhs anal_body - _ -> dmdAnalBindLetDown top_lvl env dmd bind anal_body + -> dmdAnalBindLetUp top_lvl env_rhs id rhs anal_body + _ -> dmdAnalBindLetDown top_lvl env_rhs dmd bind anal_body + where + env_rhs = enterDFun bind env -- | Annotates uninteresting top level functions ('isInterestingTopLevelFn') -- with 'topDmd', the rest with the given demand. @@ -1759,6 +1761,10 @@ We never unbox class dictionaries in worker/wrapper. occur without INLINABLE, when we use -fexpose-all-unfoldings and -fspecialise-aggressively to do vigorous cross-module specialisation. +3. #18421 found that unboxing a dictionary can also make the worker less likely + to inline; the inlining heuristics seem to prefer to inline a function + applied to a dictionary over a function applied to a bunch of functions. + TL;DR we /never/ unbox class dictionaries. Unboxing the dictionary, and passing a raft of higher-order functions isn't a huge win anyway -- you really want to specialise the function. @@ -2242,14 +2248,6 @@ addLazyFVs dmd_ty lazy_fvs -- L demand doesn't get both'd with the Bot coming up from the inner -- call to f. So we just get an L demand for x for g. -{- -Note [Do not strictify the argument dictionaries of a dfun] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The typechecker can tie recursive knots involving dfuns, so we do the -conservative thing and refrain from strictifying a dfun's argument -dictionaries. --} - setBndrsDemandInfo :: HasCallStack => [Var] -> [Demand] -> [Var] setBndrsDemandInfo (b:bs) ds | isTyVar b = b : setBndrsDemandInfo bs ds @@ -2388,6 +2386,16 @@ emptyAnalEnv opts fam_envs , ae_rec_dc = memoiseUniqueFun (isRecDataCon fam_envs 3) } +-- | Unset the 'dmd_strict_dicts' flag if any of the given bindings is a DFun +-- binding. Part of the mechanism that detects +-- Note [Do not strictify a DFun's parameter dictionaries]. +enterDFun :: CoreBind -> AnalEnv -> AnalEnv +enterDFun bind env + | any isDFunId (bindersOf bind) + = env { ae_opts = (ae_opts env) { dmd_strict_dicts = False } } + | otherwise + = env + emptySigEnv :: SigEnv emptySigEnv = emptyVarEnv @@ -2439,31 +2447,29 @@ findBndrDmd env dmd_ty id id_ty = idType id strictify dmd - -- See Note [Making dictionaries strict] + -- See Note [Making dictionary parameters strict] + -- and Note [Do not strictify a DFun's parameter dictionaries] | dmd_strict_dicts (ae_opts env) - -- We never want to strictify a recursive let. At the moment - -- findBndrDmd is never called for recursive lets; if that - -- changes, we need a RecFlag parameter and another guard here. = strictifyDictDmd id_ty dmd | otherwise = dmd fam_envs = ae_fam_envs env -{- Note [Making dictionaries strict] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +{- Note [Making dictionary parameters strict] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? * Generally CBV is more efficient. -* Dictionaries are always non-bottom; and never take much work to - compute. E.g. a dfun from an instance decl always returns a dictionary +* A datatype dictionary is always non-bottom and never takes much work to + compute. E.g. a DFun from an instance decl always returns a dictionary record immediately. See DFunUnfolding in CoreSyn. See also Note [Recursive superclasses] in TcInstDcls. -* The strictness analyser will then unbox dictionaries and pass the - methods individually, rather than in a bundle. If there are a lot of - methods that might be bad; but worker/wrapper already does throttling. +See #17758 for more background and perf numbers. + +Wrinkles: * A newtype dictionary is *not* always non-bottom. E.g. class C a where op :: a -> a @@ -2471,26 +2477,44 @@ The Opt_DictsStrict flag makes GHC use call-by-value for dictionaries. Why? Now a value of type (C Int) is just a newtype wrapper (a cast) around the error thunk. Don't strictify these! -See #17758 for more background and perf numbers. +* Strictifying DFuns risks destroying the invariant that DFuns never take much + work to compute, so we don't do it. + See Note [Do not strictify a DFun's parameter dictionaries] for details. + +* Although worker/wrapper *could* unbox strictly used dictionaries, we do not do + so; see Note [Do not unbox class dictionaries]. The implementation is extremely simple: just make the strictness analyser strictify the demand on a dictionary binder in -'findBndrDmd'. - -However there is one case where this can make performance worse. -For the principle consider some function at the core level: - myEq :: Eq a => a -> a -> Bool - myEq eqDict x y = ((==) eqDict) x y -If we make the dictionary strict then WW can fire turning this into: - $wmyEq :: (a -> a -> Bool) -> a -> a -> Bool - $wmyEq eq x y = eq x y -Which *usually* performs better. However if the dictionary is known we -are far more likely to inline a function applied to the dictionary than -to inline one applied to a function. Sometimes this makes just enough -of a difference to stop a function from inlining. This is documented in #18421. - -It's somewhat similar to Note [Do not unbox class dictionaries] although -here our problem is with the inliner, not the specializer. +'findBndrDmd' if the binder does not belong to a DFun. + +Note [Do not strictify a DFun's parameter dictionaries] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The typechecker can tie recursive knots involving (non-recursive) DFuns, so +we must not strictify a DFun's parameter dictionaries (#22549). +T22549 has an example involving undecidable instances that <>s when we +strictify the DFun of, e.g., `$fEqSeqT`: + + Main.$fEqSeqT + = \@m @a ($dEq :: Eq (m (ViewT m a))) ($dMonad :: Monad m) -> + GHC.Classes.C:Eq @(SeqT m a) ($c== @m @a $dEq $dMonad) + ($c/= @m @a $dEq $dMonad) + + Rec { + $dEq_a = Main.$fEqSeqT @Identity @Int $dEq_b Main.$fMonadIdentity + $dEq_b = ... $dEq_a ... + } + +If we make `$fEqSeqT` strict in `$dEq`, we'll collapse the Rec group into a +giant, <>ing thunk. + +To prevent that, we never strictify dictionary params when inside a DFun. +That is implemented by unsetting 'dmd_strict_dicts' when entering a DFun. + +See also Note [Speculative evaluation] in GHC.CoreToStg.Prep which has a rather +similar example in #20836. We may never speculate *arguments* of (recursive) +DFun calls, likewise we should not mark *formal parameters* of recursive DFuns +as strict. Note [Initialising strictness] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1708,6 +1708,10 @@ Fortunately, pce_rec_ids already has all the information we need in that case. The problem is very similar to Note [Eta reduction in recursive RHSs]. Here as well as there it is *unsound* to change the termination properties of the very function whose termination properties we are exploiting. + +It is also similar to Note [Do not strictify a DFun's parameter dictionaries], +where marking recursive DFuns (of undecidable *instances*) strict in dictionary +*parameters* leads to quite the same change in termination as above. -} data FloatingBind ===================================== testsuite/tests/stranal/should_run/T22549.hs ===================================== @@ -0,0 +1,37 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE DeriveFunctor #-} + +import Data.Function (on) + +newtype Identity a = Identity a deriving (Eq, Functor) +instance Applicative Identity where + pure = Identity + Identity f <*> Identity a = Identity $ f a +instance Monad Identity where + Identity a >>= f = f a + +data ViewT m a + = Empty + | a :< SeqT m a +newtype SeqT m a = SeqT [m (ViewT m a)] + +toViewT :: Monad m => SeqT m a -> m (ViewT m a) +toViewT (SeqT []) = pure Empty +toViewT (SeqT (h : t)) = h >>= \case + Empty -> toViewT (SeqT t) + hi :< SeqT ti -> pure (hi :< SeqT (ti ++ t)) + +instance (Eq (m (ViewT m a)), Monad m) => Eq (SeqT m a) where + (==) = (==) `on` toViewT + +deriving instance (Eq a, Eq (SeqT m a)) => Eq (ViewT m a) + +example :: SeqT Identity Int +example = SeqT [] + +main :: IO () +main = print (example == example) ===================================== testsuite/tests/stranal/should_run/T22549.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== testsuite/tests/stranal/should_run/all.T ===================================== @@ -30,3 +30,5 @@ test('T19053', normal, compile_and_run, ['']) test('T21717b', normal, compile_and_run, ['']) test('T22475', normal, compile_and_run, ['']) test('T22475b', normal, compile_and_run, ['']) +# T22549: Do not strictify DFuns, otherwise we will <> +test('T22549', normal, compile_and_run, ['-fdicts-strict -fno-specialise']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/26e71562072f6740d52fcd38298340c287a641b8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/26e71562072f6740d52fcd38298340c287a641b8 You're receiving 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 Dec 9 03:50:05 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:50:05 -0500 Subject: [Git][ghc/ghc][master] Delete `rts/package.conf.in` Message-ID: <6392b06db5c0b_224fca605f47319a6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - 1 changed file: - − rts/package.conf.in Changes: ===================================== rts/package.conf.in deleted ===================================== @@ -1,331 +0,0 @@ -/* The RTS is just another package! */ - -#include "ghcconfig.h" -#include "rts/Config.h" -#include "MachDeps.h" - -name: rts -version: 1.0.2 -id: rts -key: rts -license: BSD-3-Clause -maintainer: glasgow-haskell-users at haskell.org -exposed: True - -exposed-modules: -hidden-modules: - -import-dirs: - -#if defined(INSTALLING) -library-dirs: LIB_DIR FFI_LIB_DIR LIBDW_LIB_DIR -#else /* !INSTALLING */ -library-dirs: TOP"/rts/dist-install/build" FFI_LIB_DIR LIBDW_LIB_DIR -#endif - -hs-libraries: "HSrts" FFI_LIB - -extra-libraries: -#if defined(HAVE_LIBM) - "m" /* for ldexp() */ -#endif -#if defined(HAVE_LIBRT) - , "rt" -#endif -#if defined(HAVE_LIBDL) - , "dl" -#endif -#if defined(HAVE_SYSTEM_LIBFFI) - , "ffi" -#endif -#if HAVE_LIBNUMA - , "numa" -#endif -#if defined(mingw32_HOST_OS) - ,"wsock32" /* for the linker */ - ,"gdi32" /* for the linker */ - ,"winmm" /* for the linker */ - ,"dbghelp" /* for crash dump */ - ,"psapi" /* for process information. */ -#endif -#if NEED_PTHREAD_LIB - , "pthread" /* for pthread_getthreadid_np, pthread_create, etc. */ -#endif -#if defined(DEBUG) && defined(HAVE_LIBBFD) - ,"bfd", "iberty" /* for debugging */ -#endif -#if defined(HAVE_LIBMINGWEX) -# if !defined(INSTALLING) /* Bundled Mingw is behind */ - ,"mingwex" -# endif -#endif -#if USE_LIBDW - , "elf" - , "dw" /* for backtraces */ -#endif -#if NEED_ATOMIC_LIB - , "atomic" -#endif - -#if defined(INSTALLING) -include-dirs: INCLUDE_DIR FFI_INCLUDE_DIR -#else /* !INSTALLING */ -include-dirs: TOP"/rts/include" - TOP"/rts/dist-install/build/include" - FFI_INCLUDE_DIR - LIBDW_INCLUDE_DIR -#endif - -includes: Rts.h -cc-options: - -ld-options: -#if defined(LEADING_UNDERSCORE) - - "-Wl,-u,_base_GHCziTopHandler_runIO_closure" - , "-Wl,-u,_base_GHCziTopHandler_runNonIO_closure" - - , "-Wl,-u,_ghczmprim_GHCziTupleziPrim_Z0T_closure" - , "-Wl,-u,_ghczmprim_GHCziTypes_True_closure" - , "-Wl,-u,_ghczmprim_GHCziTypes_False_closure" - , "-Wl,-u,_base_GHCziPack_unpackCString_closure" - , "-Wl,-u,_base_GHCziWeakziFinalizze_runFinalizzerBatch_closure" - , "-Wl,-u,_base_GHCziIOziException_stackOverflow_closure" - , "-Wl,-u,_base_GHCziIOziException_heapOverflow_closure" - , "-Wl,-u,_base_GHCziIOziException_allocationLimitExceeded_closure" - , "-Wl,-u,_base_GHCziIOziException_blockedIndefinitelyOnMVar_closure" - , "-Wl,-u,_base_GHCziIOziException_blockedIndefinitelyOnSTM_closure" - , "-Wl,-u,_base_GHCziIOziException_cannotCompactFunction_closure" - , "-Wl,-u,_base_GHCziIOziException_cannotCompactPinned_closure" - , "-Wl,-u,_base_GHCziIOziException_cannotCompactMutable_closure" - , "-Wl,-u,_base_GHCziIOPort_doubleReadException_closure" - , "-Wl,-u,_base_ControlziExceptionziBase_nonTermination_closure" - , "-Wl,-u,_base_ControlziExceptionziBase_nestedAtomically_closure" - , "-Wl,-u,_base_GHCziEventziThread_blockedOnBadFD_closure" - , "-Wl,-u,_base_GHCziExceptionziType_divZZeroException_closure" - , "-Wl,-u,_base_GHCziExceptionziType_underflowException_closure" - , "-Wl,-u,_base_GHCziExceptionziType_overflowException_closure" - , "-Wl,-u,_base_GHCziConcziSync_runSparks_closure" - , "-Wl,-u,_base_GHCziConcziIO_ensureIOManagerIsRunning_closure" - , "-Wl,-u,_base_GHCziConcziIO_interruptIOManager_closure" - , "-Wl,-u,_base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure" - , "-Wl,-u,_base_GHCziConcziSignal_runHandlersPtr_closure" -#if defined(mingw32_HOST_OS) - , "-Wl,-u,_base_GHCziEventziWindows_processRemoteCompletion_closure" -#endif - , "-Wl,-u,_base_GHCziTopHandler_flushStdHandles_closure" - , "-Wl,-u,_base_GHCziTopHandler_runMainIO_closure" - , "-Wl,-u,_ghczmprim_GHCziTypes_Czh_con_info" - , "-Wl,-u,_ghczmprim_GHCziTypes_Izh_con_info" - , "-Wl,-u,_ghczmprim_GHCziTypes_Fzh_con_info" - , "-Wl,-u,_ghczmprim_GHCziTypes_Dzh_con_info" - , "-Wl,-u,_ghczmprim_GHCziTypes_Wzh_con_info" - , "-Wl,-u,_base_GHCziPtr_Ptr_con_info" - , "-Wl,-u,_base_GHCziPtr_FunPtr_con_info" - , "-Wl,-u,_base_GHCziInt_I8zh_con_info" - , "-Wl,-u,_base_GHCziInt_I16zh_con_info" - , "-Wl,-u,_base_GHCziInt_I32zh_con_info" - , "-Wl,-u,_base_GHCziInt_I64zh_con_info" - , "-Wl,-u,_base_GHCziWord_W8zh_con_info" - , "-Wl,-u,_base_GHCziWord_W16zh_con_info" - , "-Wl,-u,_base_GHCziWord_W32zh_con_info" - , "-Wl,-u,_base_GHCziWord_W64zh_con_info" - , "-Wl,-u,_base_GHCziStable_StablePtr_con_info" - - , "-Wl,-u,_hs_atomic_add8" - , "-Wl,-u,_hs_atomic_add16" - , "-Wl,-u,_hs_atomic_add32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_add64" -#endif - , "-Wl,-u,_hs_atomic_sub8" - , "-Wl,-u,_hs_atomic_sub16" - , "-Wl,-u,_hs_atomic_sub32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_sub64" -#endif - , "-Wl,-u,_hs_atomic_and8" - , "-Wl,-u,_hs_atomic_and16" - , "-Wl,-u,_hs_atomic_and32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_and64" -#endif - , "-Wl,-u,_hs_atomic_nand8" - , "-Wl,-u,_hs_atomic_nand16" - , "-Wl,-u,_hs_atomic_nand32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_nand64" -#endif - , "-Wl,-u,_hs_atomic_or8" - , "-Wl,-u,_hs_atomic_or16" - , "-Wl,-u,_hs_atomic_or32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_or64" -#endif - , "-Wl,-u,_hs_atomic_xor8" - , "-Wl,-u,_hs_atomic_xor16" - , "-Wl,-u,_hs_atomic_xor32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomic_xor64" -#endif - , "-Wl,-u,_hs_cmpxchg8" - , "-Wl,-u,_hs_cmpxchg16" - , "-Wl,-u,_hs_cmpxchg32" - , "-Wl,-u,_hs_cmpxchg64" - , "-Wl,-u,_hs_xchg8" - , "-Wl,-u,_hs_xchg16" - , "-Wl,-u,_hs_xchg32" - , "-Wl,-u,_hs_xchg64" - , "-Wl,-u,_hs_atomicread8" - , "-Wl,-u,_hs_atomicread16" - , "-Wl,-u,_hs_atomicread32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomicread64" -#endif - , "-Wl,-u,_hs_atomicwrite8" - , "-Wl,-u,_hs_atomicwrite16" - , "-Wl,-u,_hs_atomicwrite32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,_hs_atomicwrite64" -#endif -#if defined(DEBUG) - /* This symbol is useful in gdb, but not referred to anywhere, - * 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" - - , "-Wl,-u,ghczmprim_GHCziTupleziPrim_Z0T_closure" - , "-Wl,-u,ghczmprim_GHCziTypes_True_closure" - , "-Wl,-u,ghczmprim_GHCziTypes_False_closure" - , "-Wl,-u,base_GHCziPack_unpackCString_closure" - , "-Wl,-u,base_GHCziWeakziFinalizze_runFinalizzerBatch_closure" - , "-Wl,-u,base_GHCziIOziException_stackOverflow_closure" - , "-Wl,-u,base_GHCziIOziException_heapOverflow_closure" - , "-Wl,-u,base_GHCziIOziException_allocationLimitExceeded_closure" - , "-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnMVar_closure" - , "-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnSTM_closure" - , "-Wl,-u,base_GHCziIOziException_cannotCompactFunction_closure" - , "-Wl,-u,base_GHCziIOziException_cannotCompactPinned_closure" - , "-Wl,-u,base_GHCziIOziException_cannotCompactMutable_closure" - , "-Wl,-u,base_GHCziIOPort_doubleReadException_closure" - , "-Wl,-u,base_ControlziExceptionziBase_nonTermination_closure" - , "-Wl,-u,base_ControlziExceptionziBase_nestedAtomically_closure" - , "-Wl,-u,base_GHCziEventziThread_blockedOnBadFD_closure" - , "-Wl,-u,base_GHCziExceptionziType_divZZeroException_closure" - , "-Wl,-u,base_GHCziExceptionziType_underflowException_closure" - , "-Wl,-u,base_GHCziExceptionziType_overflowException_closure" - , "-Wl,-u,base_GHCziConcziSync_runSparks_closure" - , "-Wl,-u,base_GHCziConcziIO_ensureIOManagerIsRunning_closure" - , "-Wl,-u,base_GHCziConcziIO_interruptIOManager_closure" - , "-Wl,-u,base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure" - , "-Wl,-u,base_GHCziConcziSignal_runHandlersPtr_closure" -#if defined(mingw32_HOST_OS) - , "-Wl,-u,base_GHCziEventziWindows_processRemoteCompletion_closure" -#endif - , "-Wl,-u,base_GHCziTopHandler_flushStdHandles_closure" - , "-Wl,-u,base_GHCziTopHandler_runMainIO_closure" - , "-Wl,-u,ghczmprim_GHCziTypes_Czh_con_info" - , "-Wl,-u,ghczmprim_GHCziTypes_Izh_con_info" - , "-Wl,-u,ghczmprim_GHCziTypes_Fzh_con_info" - , "-Wl,-u,ghczmprim_GHCziTypes_Dzh_con_info" - , "-Wl,-u,ghczmprim_GHCziTypes_Wzh_con_info" - , "-Wl,-u,base_GHCziPtr_Ptr_con_info" - , "-Wl,-u,base_GHCziPtr_FunPtr_con_info" - , "-Wl,-u,base_GHCziInt_I8zh_con_info" - , "-Wl,-u,base_GHCziInt_I16zh_con_info" - , "-Wl,-u,base_GHCziInt_I32zh_con_info" - , "-Wl,-u,base_GHCziInt_I64zh_con_info" - , "-Wl,-u,base_GHCziWord_W8zh_con_info" - , "-Wl,-u,base_GHCziWord_W16zh_con_info" - , "-Wl,-u,base_GHCziWord_W32zh_con_info" - , "-Wl,-u,base_GHCziWord_W64zh_con_info" - , "-Wl,-u,base_GHCziStable_StablePtr_con_info" - - , "-Wl,-u,hs_atomic_add8" - , "-Wl,-u,hs_atomic_add16" - , "-Wl,-u,hs_atomic_add32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_add64" -#endif - , "-Wl,-u,hs_atomic_sub8" - , "-Wl,-u,hs_atomic_sub16" - , "-Wl,-u,hs_atomic_sub32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_sub64" -#endif - , "-Wl,-u,hs_atomic_and8" - , "-Wl,-u,hs_atomic_and16" - , "-Wl,-u,hs_atomic_and32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_and64" -#endif - , "-Wl,-u,hs_atomic_nand8" - , "-Wl,-u,hs_atomic_nand16" - , "-Wl,-u,hs_atomic_nand32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_nand64" -#endif - , "-Wl,-u,hs_atomic_or8" - , "-Wl,-u,hs_atomic_or16" - , "-Wl,-u,hs_atomic_or32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_or64" -#endif - , "-Wl,-u,hs_atomic_xor8" - , "-Wl,-u,hs_atomic_xor16" - , "-Wl,-u,hs_atomic_xor32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomic_xor64" -#endif - , "-Wl,-u,hs_cmpxchg8" - , "-Wl,-u,hs_cmpxchg16" - , "-Wl,-u,hs_cmpxchg32" - , "-Wl,-u,hs_cmpxchg64" - , "-Wl,-u,hs_xchg8" - , "-Wl,-u,hs_xchg16" - , "-Wl,-u,hs_xchg32" - , "-Wl,-u,hs_xchg64" - , "-Wl,-u,hs_atomicread8" - , "-Wl,-u,hs_atomicread16" - , "-Wl,-u,hs_atomicread32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomicread64" -#endif - , "-Wl,-u,hs_atomicwrite8" - , "-Wl,-u,hs_atomicwrite16" - , "-Wl,-u,hs_atomicwrite32" -#if WORD_SIZE_IN_BITS == 64 - , "-Wl,-u,hs_atomicwrite64" -#endif -#if defined(DEBUG) - /* This symbol is useful in gdb, but not referred to anywhere, - * 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 - * path. This is important to use the static gmp in preference on Mac OS. - * The used option is specific to the Darwin linker. - */ -/* - * See Note [fd_set_overflow] -*/ -#if defined(darwin_HOST_OS) - , "-Wl,-search_paths_first" - , "-Wl,-U,___darwin_check_fd_set_overflow" -#endif - -#if defined(darwin_HOST_OS) && !defined(x86_64_HOST_ARCH) && !defined(aarch64_HOST_ARCH) - , "-read_only_relocs", "warning" -#endif - -framework-dirs: - -haddock-interfaces: -haddock-html: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3609340743c1b25fdfd0e18b1670dac54c8d8623 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3609340743c1b25fdfd0e18b1670dac54c8d8623 You're receiving 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 Dec 9 03:50:39 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:50:39 -0500 Subject: [Git][ghc/ghc][master] Fixes around primitive literals Message-ID: <6392b08f27c9b_224fca6061c735760@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - 7 changed files: - compiler/GHC/Hs/Lit.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Types/SourceText.hs - testsuite/tests/ghc-api/annotations-literals/literals.stdout - testsuite/tests/ghc-api/annotations-literals/parsed.stdout - testsuite/tests/th/T14681.hs - testsuite/tests/th/T14681.stderr Changes: ===================================== compiler/GHC/Hs/Lit.hs ===================================== @@ -117,6 +117,9 @@ hsOverLitNeedsParens _ (XOverLit { }) = False -- | @'hsLitNeedsParens' p l@ returns 'True' if a literal @l@ needs -- to be parenthesized under precedence @p at . +-- +-- See Note [Printing of literals in Core] in GHC.Types.Literal +-- for the reasoning. hsLitNeedsParens :: PprPrec -> HsLit x -> Bool hsLitNeedsParens p = go where @@ -125,14 +128,14 @@ hsLitNeedsParens p = go go (HsString {}) = False go (HsStringPrim {}) = False go (HsInt _ x) = p > topPrec && il_neg x - go (HsIntPrim _ x) = p > topPrec && x < 0 + go (HsIntPrim {}) = False go (HsWordPrim {}) = False - go (HsInt64Prim _ x) = p > topPrec && x < 0 + go (HsInt64Prim {}) = False go (HsWord64Prim {}) = False go (HsInteger _ x _) = p > topPrec && x < 0 go (HsRat _ x _) = p > topPrec && fl_neg x - go (HsFloatPrim _ x) = p > topPrec && fl_neg x - go (HsDoublePrim _ x) = p > topPrec && fl_neg x + go (HsFloatPrim {}) = False + go (HsDoublePrim {}) = False go (XLit _) = False -- | Convert a literal from one index type to another @@ -169,7 +172,7 @@ Equivalently it's True if -- Instance specific to GhcPs, need the SourceText instance Outputable (HsLit (GhcPass p)) where ppr (HsChar st c) = pprWithSourceText st (pprHsChar c) - ppr (HsCharPrim st c) = pp_st_suffix st primCharSuffix (pprPrimChar c) + ppr (HsCharPrim st c) = pprWithSourceText st (pprPrimChar c) ppr (HsString st s) = pprWithSourceText st (pprHsString s) ppr (HsStringPrim st s) = pprWithSourceText st (pprHsBytes s) ppr (HsInt _ i) @@ -180,12 +183,8 @@ instance Outputable (HsLit (GhcPass p)) where ppr (HsDoublePrim _ d) = ppr d <> primDoubleSuffix ppr (HsIntPrim st i) = pprWithSourceText st (pprPrimInt i) ppr (HsWordPrim st w) = pprWithSourceText st (pprPrimWord w) - ppr (HsInt64Prim st i) = pp_st_suffix st primInt64Suffix (pprPrimInt64 i) - ppr (HsWord64Prim st w) = pp_st_suffix st primWord64Suffix (pprPrimWord64 w) - -pp_st_suffix :: SourceText -> SDoc -> SDoc -> SDoc -pp_st_suffix NoSourceText _ doc = doc -pp_st_suffix (SourceText st) suffix _ = text st <> suffix + ppr (HsInt64Prim st i) = pprWithSourceText st (pprPrimInt64 i) + ppr (HsWord64Prim st w) = pprWithSourceText st (pprPrimWord64 w) -- in debug mode, print the expression that it's resolved to, too instance OutputableBndrId p ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -2172,10 +2172,12 @@ finish_char_tok buf loc ch -- We've already seen the closing quote let src = lexemeToString buf (cur bufEnd - cur buf) if magicHash then do case alexGetChar' i of - Just ('#',i@(AI end _)) -> do + Just ('#',i@(AI end bufEnd')) -> do setInput i + -- Include the trailing # in SourceText + let src' = lexemeToString buf (cur bufEnd' - cur buf) return (L (mkPsSpan loc end) - (ITprimchar (SourceText src) ch)) + (ITprimchar (SourceText src') ch)) _other -> return (L (mkPsSpan loc end) (ITchar (SourceText src) ch)) ===================================== compiler/GHC/Types/SourceText.hs ===================================== @@ -76,15 +76,15 @@ text is stored in literals where this can occur. Motivating examples for HsLit - HsChar '\n' == '\x20` - HsCharPrim '\x41`# == `A` + HsChar '\n' == '\x20' + HsCharPrim '\x41'# == 'A'# HsString "\x20\x41" == " A" HsStringPrim "\x20"# == " "# HsInt 001 == 1 HsIntPrim 002# == 2# HsWordPrim 003## == 3## - HsInt64Prim 004## == 4## - HsWord64Prim 005## == 5## + HsInt64Prim 004#Int64 == 4#Int64 + HsWord64Prim 005#Word64 == 5#Word64 HsInteger 006 == 6 For OverLitVal @@ -293,7 +293,7 @@ instance Outputable FractionalLit where -- source to source manipulation tools. data StringLiteral = StringLiteral { sl_st :: SourceText, -- literal raw source. - -- See not [Literal source text] + -- See Note [Literal source text] sl_fs :: FastString, -- literal string value sl_tc :: Maybe RealSrcSpan -- Location of -- possible ===================================== testsuite/tests/ghc-api/annotations-literals/literals.stdout ===================================== @@ -98,7 +98,7 @@ (LiteralsTest.hs:19:11,ITequal,[=]), -(LiteralsTest.hs:19:13-19,ITprimchar (SourceText "'\\x41'") 'A',['\x41'#]), +(LiteralsTest.hs:19:13-19,ITprimchar (SourceText "'\\x41'#") 'A',['\x41'#]), (LiteralsTest.hs:20:5,ITsemi,[]), ===================================== testsuite/tests/ghc-api/annotations-literals/parsed.stdout ===================================== @@ -2,7 +2,7 @@ HsIntegral [0003] 3 HsIntegral [0x04] 4 HsString ["\x20"] " " HsChar ['\x20'] ' ' -HsCharPrim ['\x41'] 'A' +HsCharPrim ['\x41'#] 'A' HsIntPrim [0004#] 4 HsWordPrim [005##] 5 HsIntegral [1] 1 ===================================== testsuite/tests/th/T14681.hs ===================================== @@ -1,9 +1,12 @@ -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TemplateHaskell, MagicHash #-} module T14681 where import Data.Functor.Identity import Language.Haskell.TH +import GHC.Exts $([d| f = \(Identity x) -> x |]) $([d| g = $(pure $ VarE '(+) `AppE` LitE (IntegerL (-1)) `AppE` (LitE (IntegerL (-1)))) |]) +$([d| h _ = $(pure $ VarE '(+#) `AppE` LitE (IntPrimL (-1)) + `AppE` (LitE (IntPrimL (-1)))) |]) ===================================== testsuite/tests/th/T14681.stderr ===================================== @@ -1,6 +1,6 @@ -T14681.hs:7:2-32: Splicing declarations +T14681.hs:8:2-32: Splicing declarations [d| f = \ (Identity x) -> x |] ======> f = \ (Identity x) -> x -T14681.hs:(8,2)-(9,63): Splicing declarations +T14681.hs:(9,2)-(10,63): Splicing declarations [d| g = $(pure $ VarE '(+) `AppE` LitE (IntegerL (- 1)) `AppE` (LitE (IntegerL (- 1)))) |] @@ -9,3 +9,13 @@ T14681.hs:(8,2)-(9,63): Splicing declarations `AppE` (LitE (IntegerL (- 1)))>] ======> g = (+) (-1) (-1) +T14681.hs:(11,2)-(12,66): Splicing declarations + [d| h _ + = $(pure + $ VarE '(+#) `AppE` LitE (IntPrimL (- 1)) + `AppE` (LitE (IntPrimL (- 1)))) |] + pending(rn) [] + ======> + h _ = (+#) -1# -1# View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b0cc2fcfc485da772c5ffef1b625af9e7ae73129 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b0cc2fcfc485da772c5ffef1b625af9e7ae73129 You're receiving 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 Dec 9 03:51:14 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 22:51:14 -0500 Subject: [Git][ghc/ghc][master] testsuite: Mark conc024 fragile on Windows Message-ID: <6392b0b27c2d1_224fca21999640739194@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - 1 changed file: - testsuite/tests/concurrent/should_run/all.T Changes: ===================================== testsuite/tests/concurrent/should_run/all.T ===================================== @@ -149,7 +149,7 @@ test('conc021', compile_and_run, ['']) test('conc022', normal, compile_and_run, ['']) -test('conc024', normal, compile_and_run, ['']) +test('conc024', when(opsys('mingw32'), fragile(17733)), compile_and_run, ['']) test('conc025', normal, compile_and_run, ['']) test('conc026', normal, compile_and_run, ['']) test('conc028', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aacf616df0b4059e6b177ecb64624ae6fb1d1c87 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aacf616df0b4059e6b177ecb64624ae6fb1d1c87 You're receiving 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 Dec 9 03:54:38 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Thu, 08 Dec 2022 22:54:38 -0500 Subject: [Git][ghc/ghc][wip/rts-configure-2] 20 commits: Add test for #22162 Message-ID: <6392b17e38fdf_224fca606807393e0@gitlab.mail> John Ericson pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - e64e7d1c by Ben Gamari at 2022-12-08T22:53:04-05:00 rts configure script - - - - - 2f49496d by John Ericson at 2022-12-08T22:53:10-05:00 Lower min autoconf version for rts configure we're not sure why it was raised. - - - - - 7670902a by John Ericson at 2022-12-08T22:53:10-05:00 Need to use CPP not `if` in rts.buildinfo - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - boot - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Lit.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Platform.hs - + compiler/GHC/Platform/LoongArch64.hs - compiler/GHC/Platform/Regs.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Types/SourceText.hs - compiler/ghc.cabal.in - configure.ac - distrib/configure.ac.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cff1dc328e03d777d391f94003db7e7f5104f8f8...7670902a6af05a84c62c1eb956dbcdf2480628e0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cff1dc328e03d777d391f94003db7e7f5104f8f8...7670902a6af05a84c62c1eb956dbcdf2480628e0 You're receiving 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 Dec 9 04:22:05 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 08 Dec 2022 23:22:05 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 21 commits: Add test for #22162 Message-ID: <6392b7edde932_224fca219996407437d0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - 71f2d3a9 by Ryan Scott at 2022-12-08T23:21:45-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 774a5b8c by Mike Pilgrem at 2022-12-08T23:21:49-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - df1cb15b by Luite Stegeman at 2022-12-08T23:21:58-05:00 Add support for environments that don't have setImmediate - - - - - cd0ba573 by Luite Stegeman at 2022-12-08T23:21:58-05:00 Fix bound thread status - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Lit.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Platform.hs - + compiler/GHC/Platform/LoongArch64.hs - compiler/GHC/Platform/Regs.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Types/SourceText.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/exts/misc.rst - docs/users_guide/exts/template_haskell.rst - + docs/users_guide/exts/whitespace.rst - hadrian/cabal.project - hadrian/hadrian.cabal The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e839c0af64e77995a0faf8cee58ba93a117b0ae2...cd0ba573ad251c7139b13dba9796def4146e687a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e839c0af64e77995a0faf8cee58ba93a117b0ae2...cd0ba573ad251c7139b13dba9796def4146e687a You're receiving 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 Dec 9 07:24:03 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Fri, 09 Dec 2022 02:24:03 -0500 Subject: [Git][ghc/ghc][wip/int-index/tok-at-app-kind] 30 commits: Hadrian: fix ghcDebugAssertions off-by-one error Message-ID: <6392e2939cd6b_224fcafbc67687646e0@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/tok-at-app-kind at Glasgow Haskell Compiler / GHC Commits: cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - 984dc049 by Vladislav Zavialov at 2022-12-09T10:20:48+03:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Graph/Directed.hs - + compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Lit.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - + compiler/GHC/Linker/Config.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aceef2cadc9f828cee3a4cb2dd31991ce7aa0395...984dc049fc155bb44d681f99a0e1ec48ca63f825 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aceef2cadc9f828cee3a4cb2dd31991ce7aa0395...984dc049fc155bb44d681f99a0e1ec48ca63f825 You're receiving 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 Dec 9 07:36:11 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 09 Dec 2022 02:36:11 -0500 Subject: [Git][ghc/ghc][wip/T22272] Improve the UnfoldingCache mechanism Message-ID: <6392e56b6fb9_224fca605f47681cd@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22272 at Glasgow Haskell Compiler / GHC Commits: 60658ec1 by Simon Peyton Jones at 2022-12-09T07:21:39+00:00 Improve the UnfoldingCache mechanism This small patch adds some documentation around the new UnfoldingCache field. But most important it does two things: * In GHC.Core.Unfold.Make.mkCoreUnfolding we we accidentally forcing the wrong values, which led to duplicate work. * In GHC.Core.Unfold.callSiteInline we were forcing UnfoldingCache which caused unnecessary work. - - - - - 6 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -1299,6 +1299,7 @@ data Unfolding -- | Properties of a 'CoreUnfolding' that could be computed on-demand from its template. +-- See Note [UnfoldingCache] data UnfoldingCache = UnfoldingCache { uf_is_value :: !Bool, -- exprIsHNF template (cached); it is ok to discard @@ -1342,7 +1343,23 @@ data UnfoldingGuidance | UnfNever -- The RHS is big, so don't inline it deriving (Eq) -{- +{- Note [UnfoldingCache] +~~~~~~~~~~~~~~~~~~~~~~~~ +The UnfoldingCache field of an Unfolding holds four (strict) booleans, +all derived from the uf_tmpl field of the unfolding. + +* We serialise the UnfoldingCache to and from interface files, for + reasons described in Note [Tying the 'CoreUnfolding' knot] in + GHC.IfaceToCore + +* Because it is a strict data type, we must be careful not to + pattern-match on it until we actually want its values. E.g + GHC.Core.Unfold.callSiteInline/tryUnfolding are careful not to force + it unnecessarily. Just saves a bit of work. + +* When `seq`ing Core to eliminate space leaks, to suffices to `seq` on + the cache, but not its fields, because it is strict in all fields. + Note [Historical note: unfoldings for wrappers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to have a nice clever scheme in interface files for ===================================== compiler/GHC/Core/Seq.hs ===================================== @@ -106,6 +106,9 @@ seqUnfolding :: Unfolding -> () seqUnfolding (CoreUnfolding { uf_tmpl = e, uf_is_top = top, uf_cache = cache, uf_guidance = g}) = seqExpr e `seq` top `seq` cache `seq` seqGuidance g + -- The unf_cache :: UnfoldingCache field is a strict data type, + -- so it is sufficient to use plain `seq` for this field + -- See Note [UnfoldingCache] in GHC.Core seqUnfolding _ = () ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -1036,12 +1036,11 @@ callSiteInline logger opts !case_depth id active_unfolding lone_variable arg_inf -- Things with an INLINE pragma may have an unfolding *and* -- be a loop breaker (maybe the knot is not yet untied) CoreUnfolding { uf_tmpl = unf_template - , uf_cache = UnfoldingCache{ uf_is_work_free = is_wf - , uf_expandable = is_exp } + , uf_cache = unf_cache , uf_guidance = guidance } | active_unfolding -> tryUnfolding logger opts case_depth id lone_variable arg_infos cont_info unf_template - is_wf is_exp guidance + unf_cache guidance | otherwise -> traceInline logger opts id "Inactive unfolding:" (ppr id) Nothing NoUnfolding -> Nothing BootUnfolding -> Nothing @@ -1163,11 +1162,10 @@ needed on a per-module basis. -} tryUnfolding :: Logger -> UnfoldingOpts -> Int -> Id -> Bool -> [ArgSummary] -> CallCtxt - -> CoreExpr -> Bool -> Bool -> UnfoldingGuidance + -> CoreExpr -> UnfoldingCache -> UnfoldingGuidance -> Maybe CoreExpr -tryUnfolding logger opts !case_depth id lone_variable - arg_infos cont_info unf_template - is_wf is_exp guidance +tryUnfolding logger opts !case_depth id lone_variable arg_infos + cont_info unf_template unf_cache guidance = case guidance of UnfNever -> traceInline logger opts id str (text "UnfNever") Nothing @@ -1179,7 +1177,7 @@ tryUnfolding logger opts !case_depth id lone_variable -> traceInline logger opts id str (mk_doc some_benefit empty False) Nothing where some_benefit = calc_some_benefit uf_arity - enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) + enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) UnfIfGoodArgs { ug_args = arg_discounts, ug_res = res_discount, ug_size = size } | unfoldingVeryAggressive opts @@ -1190,9 +1188,6 @@ tryUnfolding logger opts !case_depth id lone_variable -> traceInline logger opts id str (mk_doc some_benefit extra_doc False) Nothing where some_benefit = calc_some_benefit (length arg_discounts) - extra_doc = vcat [ text "case depth =" <+> int case_depth - , text "depth based penalty =" <+> int depth_penalty - , text "discounted size =" <+> int adjusted_size ] -- See Note [Avoid inlining into deeply nested cases] depth_treshold = unfoldingCaseThreshold opts depth_scaling = unfoldingCaseScaling opts @@ -1202,7 +1197,18 @@ tryUnfolding logger opts !case_depth id lone_variable small_enough = adjusted_size <= unfoldingUseThreshold opts discount = computeDiscount arg_discounts res_discount arg_infos cont_info + extra_doc = vcat [ text "case depth =" <+> int case_depth + , text "depth based penalty =" <+> int depth_penalty + , text "discounted size =" <+> int adjusted_size ] + where + -- Unpack the UnfoldingCache lazily because it may not be needed, and all + -- its fields are strict; so evaluating unf_cache at all forces all the + -- isWorkFree etc computations to take place. That risks wasting effort for + -- Ids that are never going to inline anyway. + -- See Note [UnfoldingCache] in GHC.Core + UnfoldingCache{ uf_is_work_free = is_wf, uf_expandable = is_exp } = unf_cache + mk_doc some_benefit extra_doc yes_or_no = vcat [ text "arg infos" <+> ppr arg_infos , text "interesting continuation" <+> ppr cont_info ===================================== compiler/GHC/Core/Unfold/Make.hs ===================================== @@ -336,13 +336,10 @@ mkCoreUnfolding :: UnfoldingSource -> Bool -> CoreExpr -> Maybe UnfoldingCache -> UnfoldingGuidance -> Unfolding -- Occurrence-analyses the expression before capturing it mkCoreUnfolding src top_lvl expr precomputed_cache guidance - = CoreUnfolding { uf_tmpl = is_value `seq` - is_conlike `seq` - is_work_free `seq` - is_expandable `seq` + = CoreUnfolding { uf_tmpl = cache `seq` occurAnalyseExpr expr -- occAnalyseExpr: see Note [Occurrence analysis of unfoldings] - -- See #20905 for what a discussion of these 'seq's + -- See #20905 for what a discussion of this 'seq'. -- We are careful to make sure we only -- have one copy of an unfolding around at once. -- Note [Thoughtful forcing in mkCoreUnfolding] ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -2715,8 +2715,9 @@ instance NFData IfGuidance where instance NFData IfaceUnfolding where rnf = \case - IfCoreUnfold src cache guidance expr -> src `seq` rwhnf cache `seq` rnf guidance `seq` rnf expr - IfDFunUnfold bndrs exprs -> rnf bndrs `seq` rnf exprs + IfCoreUnfold src cache guidance expr -> src `seq` cache `seq` rnf guidance `seq` rnf expr + IfDFunUnfold bndrs exprs -> rnf bndrs `seq` rnf exprs + -- See Note [UnfoldingCache] in GHC.Core for why it suffices to merely `seq` on cache instance NFData IfaceExpr where rnf = \case ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1798,7 +1798,6 @@ tcUnfolding _toplvl name dfun_ty _ (IfDFunUnfold bs ops) {- Note [Tying the 'CoreUnfolding' knot] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - The unfolding of recursive definitions can contain references to the Id being defined. Consider the following example: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60658ec130cf328e937be84f8e4b9a1823cffb18 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60658ec130cf328e937be84f8e4b9a1823cffb18 You're receiving 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 Dec 9 09:16:24 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 09 Dec 2022 04:16:24 -0500 Subject: [Git][ghc/ghc][wip/bump-9.4-ci] hlint: Removed redundant UnboxedSums pragmas Message-ID: <6392fce85096d_224fca21999640784476@gitlab.mail> Matthew Pickering pushed to branch wip/bump-9.4-ci at Glasgow Haskell Compiler / GHC Commits: 4b29dab6 by Matthew Pickering at 2022-12-09T00:01:54+00:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - 3 changed files: - compiler/GHC/Core/Lint.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Data/Unboxed.hs Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -2,7 +2,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE UnboxedSums #-} {- (c) The University of Glasgow 2006 ===================================== compiler/GHC/Data/OrdList.hs ===================================== @@ -8,7 +8,6 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} -- | Provide trees (of instructions), so that lists of instructions can be ===================================== compiler/GHC/Data/Unboxed.hs ===================================== @@ -1,6 +1,5 @@ -- Unboxed counterparts to data structures -{-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE UnliftedNewtypes #-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b29dab6b6b077b993b55008d2ea5c8ab30b7750 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b29dab6b6b077b993b55008d2ea5c8ab30b7750 You're receiving 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 Dec 9 09:37:03 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Fri, 09 Dec 2022 04:37:03 -0500 Subject: [Git][ghc/ghc][wip/bump-9.4-ci] 3 commits: hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. Message-ID: <639301bf235cd_224fcabe792c0789480@gitlab.mail> Matthew Pickering pushed to branch wip/bump-9.4-ci at Glasgow Haskell Compiler / GHC Commits: 602ab6c2 by Matthew Pickering at 2022-12-09T09:36:54+00:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - e84035dc by Matthew Pickering at 2022-12-09T09:36:54+00:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - 57440ae1 by Matthew Pickering at 2022-12-09T09:36:54+00:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - 15 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Lint.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Data/Unboxed.hs - hadrian/bootstrap/generate_bootstrap_plans - hadrian/bootstrap/hadrian-bootstrap-gen.cabal - − hadrian/bootstrap/plan-8_10_1.json - − hadrian/bootstrap/plan-8_10_2.json - − hadrian/bootstrap/plan-8_10_3.json - − hadrian/bootstrap/plan-8_10_4.json - − hadrian/bootstrap/plan-8_10_5.json - − hadrian/bootstrap/plan-8_10_7.json - − hadrian/bootstrap/plan-9_0_1.json - − hadrian/bootstrap/plan-9_0_2.json - + hadrian/bootstrap/plan-9_2_1.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b29dab6b6b077b993b55008d2ea5c8ab30b7750...57440ae1932ca373c9ff1d6c5889bd0c079cf273 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b29dab6b6b077b993b55008d2ea5c8ab30b7750...57440ae1932ca373c9ff1d6c5889bd0c079cf273 You're receiving 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 Dec 9 10:08:08 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 09 Dec 2022 05:08:08 -0500 Subject: [Git][ghc/ghc][wip/T21761] Respect -XStrict in the pattern-match checker (#21761) Message-ID: <63930908d8782_224fca526d47924ae@gitlab.mail> Sebastian Graf pushed to branch wip/T21761 at Glasgow Haskell Compiler / GHC Commits: 61c71e3b by Sebastian Graf at 2022-12-09T11:06:22+01:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 4 changed files: - compiler/GHC/HsToCore/Pmc/Desugar.hs - + testsuite/tests/pmcheck/should_compile/T21761.hs - + testsuite/tests/pmcheck/should_compile/T21761.stderr - testsuite/tests/pmcheck/should_compile/all.T Changes: ===================================== compiler/GHC/HsToCore/Pmc/Desugar.hs ===================================== @@ -38,7 +38,7 @@ import GHC.Core.Coercion import GHC.Tc.Types.Evidence (HsWrapper(..), isIdHsWrapper) import {-# SOURCE #-} GHC.HsToCore.Expr (dsExpr, dsLExpr, dsSyntaxExpr) import {-# SOURCE #-} GHC.HsToCore.Binds (dsHsWrapper) -import GHC.HsToCore.Utils (isTrueLHsExpr, selectMatchVar) +import GHC.HsToCore.Utils (isTrueLHsExpr, selectMatchVar, decideBangHood) import GHC.HsToCore.Match.Literal (dsLit, dsOverLit) import GHC.HsToCore.Monad import GHC.Core.TyCo.Rep @@ -334,7 +334,10 @@ desugarMatches vars matches = -- Desugar a single match desugarMatch :: [Id] -> LMatch GhcTc (LHsExpr GhcTc) -> DsM (PmMatch Pre) desugarMatch vars (L match_loc (Match { m_pats = pats, m_grhss = grhss })) = do - pats' <- concat <$> zipWithM desugarLPat vars pats + dflags <- getDynFlags + -- decideBangHood: See Note [Desugaring -XStrict matches in Pmc] + let banged_pats = map (decideBangHood dflags) pats + pats' <- concat <$> zipWithM desugarLPat vars banged_pats grhss' <- desugarGRHSs (locA match_loc) (sep (map ppr pats)) grhss -- tracePm "desugarMatch" (vcat [ppr pats, ppr pats', ppr grhss']) return PmMatch { pm_pats = GrdVec pats', pm_grhss = grhss' } @@ -533,4 +536,30 @@ the whole point. The place to store the 'PmLet' guards for @where@ clauses (which are per 'GRHSs') is as a field of 'PmGRHSs'. For plain @let@ guards as in the guards of @x@, we can simply add them to the 'pg_grds' field of 'PmGRHS'. + +Note [Desugaring -XStrict matches in Pmc] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (#21761) + + {-# LANGUAGE Strict #-} + idV :: Void -> Void + idV v = v + +Without -XStrict, we would not warn here. But with -XStrict, there is an +implicit bang on `v` and we should give an inaccessible warning for the RHS. +The way we account for that is by calling `decideBangHood` on patterns +in a `Match`, which inserts the implicit bang. + +Making the call here actually seems redundant with the call to `decideBangHood` +in `GHC.HsToCore.Match.matchWrapper`, which does it *after* it calls the +pattern-match checker on the Match's patterns. It would be great if we could expect +`matchWrapper` to pass the bang-adorned `Match` to the pattern-match checker, +but sadly then we get worse warning messages which would print `idV` as if the +user *had* written a bang: + + Pattern match has inaccessible right hand side +- In an equation for ‘idV’: idV v = ... ++ In an equation for ‘idV’: idV !v = ... + +So we live with the duplication. -} ===================================== testsuite/tests/pmcheck/should_compile/T21761.hs ===================================== @@ -0,0 +1,19 @@ +{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE Strict #-} + +module T21761 where + +data Void + +idV :: Void -> Void +idV v = v + +idV' :: Void -> Void +idV' v = case v of w -> w + +bangIdV :: Void -> Void +bangIdV !v = v + +bangIdV' :: Void -> Void +bangIdV' v = case v of !w -> w ===================================== testsuite/tests/pmcheck/should_compile/T21761.stderr ===================================== @@ -0,0 +1,24 @@ + +T21761.hs:10:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘idV’: idV v = ... + +T21761.hs:13:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘idV'’: idV' v = ... + +T21761.hs:13:20: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In a case alternative: w -> ... + +T21761.hs:16:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘bangIdV’: bangIdV !v = ... + +T21761.hs:19:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘bangIdV'’: bangIdV' v = ... + +T21761.hs:19:24: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In a case alternative: !w -> ... ===================================== testsuite/tests/pmcheck/should_compile/all.T ===================================== @@ -157,3 +157,4 @@ test('EmptyCase008', [], compile, [overlapping_incomplete]) test('EmptyCase009', [], compile, [overlapping_incomplete]) test('EmptyCase010', [], compile, [overlapping_incomplete]) test('T19271', [], compile, [overlapping_incomplete]) +test('T21761', [], compile, [overlapping_incomplete]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61c71e3bb2cba12fc77059cc35a2082729be5a27 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61c71e3bb2cba12fc77059cc35a2082729be5a27 You're receiving 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 Dec 9 14:23:29 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Fri, 09 Dec 2022 09:23:29 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22570 Message-ID: <639344e186cac_224fca2595e17c843688@gitlab.mail> Ryan Scott pushed new branch wip/T22570 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22570 You're receiving 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 Dec 9 14:42:29 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 09 Dec 2022 09:42:29 -0500 Subject: [Git][ghc/ghc][master] Document TH splices' interaction with INCOHERENT instances Message-ID: <63934955e5098_224fca1d788774856999@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1 changed file: - docs/users_guide/exts/template_haskell.rst Changes: ===================================== docs/users_guide/exts/template_haskell.rst ===================================== @@ -285,6 +285,14 @@ The :extension:`TemplateHaskellQuotes` extension is considered safe under includes all top-level definitions down to but not including the first top-level declaration splice. + Each group is compiled just like a separately compiled module. That is: + + - Later groups can "see" declarations, and instance declarations, from + earlier groups; + + - But earlier groups cannot "see" declarations, or instance declarations, + from later groups. + Each declaration group is mutually recursive only within the group. Declaration groups can refer to definitions within previous groups, but not later ones. @@ -375,6 +383,70 @@ The :extension:`TemplateHaskellQuotes` extension is considered safe under 3. Since the declaration group containing ``D`` is in the previous declaration group, the splice ``$(th2 ...)`` *can* refer to ``D``. + Note that in some cases, the presence or absence of top-level declaration + splices can affect the *runtime* behavior of the surrounding code, because + the resolution of instances may differ depending on their visiblity. One + case where this arises is with + :ref:`incoherent instances ` :: + + module Main where + + main :: IO () + main = do + let i :: Int + i = 42 + putStrLn (m1 i) + putStrLn (m2 i) + + class C1 a where + m1 :: a -> String + + instance {-# INCOHERENT #-} C1 a where + m1 _ = "C1 incoherent" + + instance C1 Int where + m1 = show + + class C2 a where + m2 :: a -> String + + instance {-# INCOHERENT #-} C2 a where + m2 _ = "C2 incoherent" + + $(return []) + + instance C2 Int where + m2 = show + + Here, ``C1`` and ``C2`` are the same classes with nearly identical + instances. The only significant differences between ``C1`` and ``C2``, aside + from the minor name change, is that all of ``C1``'s instances are defined + within the same declaration group, whereas the ``C2 Int`` instance is put in + a separate declaration group from the incoherent ``C2 a`` instance. This has + an impact on the runtime behavior of the ``main`` function :: + + $ runghc Main.hs + 42 + C2 incoherent + + Note that ``m1 i`` returns ``"42"``, but ``m2 i`` returns + ``"C2 incoherent"``. When each of these expressions are typechecked, GHC + must figure out which ``C1 Int`` and ``C2 Int`` instances to use: + + 1. When resolving the ``C1 Int`` instance, GHC discovers two possible + instances in the same declaration group: the incoherent ``C1 a`` instance + and the non-incoherent ``C1 Int`` instance. According to the instance + search rules described in :ref:`instance-overlap`, because there is + exactly one non-incoherent instance to pick, GHC will choose the + ``C1 Int`` instance. As a result, ``m1 i`` will be equivalent to + ``show i`` (i.e., ``"42"``). + 2. When resolving the ``C2 Int`` instance, GHC only discovers one instance + in the same declaration group: the incoherent ``C2 a`` instance. Note + that GHC does *not* see the ``C2 Int`` instance, as that is in a later + declaration group that is made separate by the intervening declaration + splice. As a result, GHC will choose the ``C2 a`` instance, making + ``m2 i`` equivalent to ``"C2 incoherent"``. + - Expression quotations accept most Haskell language constructs. However, there are some GHC-specific extensions which expression quotations currently do not support, including View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed239a24c71671c15ea59dae8073e4516558e47b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed239a24c71671c15ea59dae8073e4516558e47b You're receiving 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 Dec 9 14:43:13 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 09 Dec 2022 09:43:13 -0500 Subject: [Git][ghc/ghc][master] Fix #22300 Document GHC's extensions to valid whitespace Message-ID: <63934981e42c4_224fca18f7d754864250@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 2 changed files: - docs/users_guide/exts/misc.rst - + docs/users_guide/exts/whitespace.rst Changes: ===================================== docs/users_guide/exts/misc.rst ===================================== @@ -9,3 +9,4 @@ Miscellaneous generics assert callstack + whitespace ===================================== docs/users_guide/exts/whitespace.rst ===================================== @@ -0,0 +1,29 @@ +.. _whitespace: + +Whitespace +========== + +.. index:: + single: Whitespace + +As in the Haskell Language Report, Haskell comments are valid whitespace. In +addition, lines (which must end with a line feed character) that begin as +follows are valid whitespace in source code, except immediately after a +``where``, ``let``, ``do`` or ``of`` keyword: + +- ``#!``. This accommodates 'shebang' interpreter directives in scripts on + Unix-like operating systems. + +- ``#!``, where ```` is an initial space character before the + 'shebang'. + +- ``#pragma``. This accommodates the use of a directive that passes additional + information to a compiler. + +- ``#line ""``, where ```` is a positive integer and + ```` can comprise zero or more characters. This accommodates a compiler + directive that resets the numbering of lines of source code, and the + identification of the source code file name, in compiler messages. + +- ``# ""``, where ```` is a positive integer and ```` + can comprise zero or more characters. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1023b432d0befd9675dcfcfb44c548b06b2fae8c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1023b432d0befd9675dcfcfb44c548b06b2fae8c You're receiving 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 Dec 9 14:43:56 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 09 Dec 2022 09:43:56 -0500 Subject: [Git][ghc/ghc][master] 2 commits: Add support for environments that don't have setImmediate Message-ID: <639349acd3283_224fca605f4867660@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 1 changed file: - rts/js/thread.js Changes: ===================================== rts/js/thread.js ===================================== @@ -153,7 +153,7 @@ function h$forkThread(a, inherit) { function h$threadStatus(t) { // status, capability, locked - RETURN_UBX_TUP3(t.status, 1, 0); + RETURN_UBX_TUP3(t.status, 0, 1); } function h$waitRead(fd) { @@ -599,7 +599,7 @@ function h$scheduleMainLoop() { // node.js 0.10.30 has trouble with non-integral delays h$mainLoopTimeout = setTimeout(h$mainLoop, Math.round(delay)); } else { - h$mainLoopImmediate = setImmediate(h$mainLoop); + h$mainLoopImmediate = h$setImmediate(h$mainLoop); } #ifndef GHCJS_BROWSER } @@ -617,7 +617,7 @@ function h$clearScheduleMainLoop() { h$mainLoopTimeout = null; } if(h$mainLoopImmediate) { - clearImmediate(h$mainLoopImmediate); + h$clearImmediate(h$mainLoopImmediate); h$mainLoopImmediate = null; } if(h$mainLoopFrame) { @@ -626,6 +626,15 @@ function h$clearScheduleMainLoop() { } } +var h$setImmediate, h$clearImmediate; +if(typeof setImmediate !== 'undefined') { + h$setImmediate = function(f) { return setImmediate(f); } + h$clearImmediate = function(h) { clearImmediate(h); } +} else { + h$setImmediate = function(f) { return setTimeout(f, 0); } + h$clearImmediate = function(h) { clearTimeout(h); } +} + function h$startMainLoop() { TRACE_SCHEDULER("start main loop: " + h$running) if(h$running) return; @@ -634,7 +643,7 @@ function h$startMainLoop() { #endif if(!h$mainLoopImmediate) { h$clearScheduleMainLoop(); - h$mainLoopImmediate = setImmediate(h$mainLoop); + h$mainLoopImmediate = h$setImmediate(h$mainLoop); } #ifndef GHCJS_BROWSER } else { @@ -717,7 +726,7 @@ function h$actualMainLoop() { if(h$animationFrameMainLoop) { h$mainLoopFrame = requestAnimationFrame(h$mainLoop); } else { - h$mainLoopImmediate = setImmediate(h$mainLoop); + h$mainLoopImmediate = h$setImmediate(h$mainLoop); } return; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1023b432d0befd9675dcfcfb44c548b06b2fae8c...5b007ec52ba77051fedd2b9a6fb155b248081511 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1023b432d0befd9675dcfcfb44c548b06b2fae8c...5b007ec52ba77051fedd2b9a6fb155b248081511 You're receiving 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 Dec 9 19:40:34 2022 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Fri, 09 Dec 2022 14:40:34 -0500 Subject: [Git][ghc/ghc][wip/decode_cloned_stack] 2 commits: Add Atomically assertion Message-ID: <63938f32d7f94_224fca2595e17c9102e4@gitlab.mail> Sven Tennie pushed to branch wip/decode_cloned_stack at Glasgow Haskell Compiler / GHC Commits: 67a64bae by Sven Tennie at 2022-12-03T16:13:00+00:00 Add Atomically assertion - - - - - a8a4bb66 by Sven Tennie at 2022-12-09T19:39:32+00:00 Make stack frame closure types heap closures types - - - - - 7 changed files: - libraries/base/GHC/Stack/CloneStack.hs - libraries/ghc-heap/GHC/Exts/DecodeStack.hs - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-heap/tests/stack_stm_frames.hs - libraries/ghci/GHCi/Message.hs Changes: ===================================== libraries/base/GHC/Stack/CloneStack.hs ===================================== @@ -26,16 +26,26 @@ import Control.Concurrent.MVar import Data.Maybe (catMaybes) import Foreign import GHC.Conc.Sync -import GHC.Exts (Int (I#), RealWorld, StackSnapshot#, ThreadId#, Array#, sizeofArray#, indexArray#, State#, StablePtr#) +import GHC.Exts (Int (I#), RealWorld, StackSnapshot#, ThreadId#, Array#, sizeofArray#, indexArray#, State#, StablePtr#, Word#, unsafeCoerce#, eqWord#, isTrue#) import GHC.IO (IO (..)) import GHC.Stack.CCS (InfoProv (..), InfoProvEnt, ipeProv, peekInfoProv) import GHC.Stable +import qualified GHC.Generics -- | A frozen snapshot of the state of an execution stack. -- -- @since 2.16.0.0 data StackSnapshot = StackSnapshot !StackSnapshot# + +-- TODO: Cast to Addr representation instead? +instance Eq StackSnapshot where + (StackSnapshot s1#) == (StackSnapshot s2#) = isTrue# (((unsafeCoerce# s1#) :: Word#) `eqWord#` ((unsafeCoerce# s2#) :: Word#)) + +-- TODO: Show and Eq instances are mainly here to fulfill Closure deriving requirements +instance Show StackSnapshot where + show _ = "StackSnapshot" + foreign import prim "stg_decodeStackzh" decodeStack# :: StackSnapshot# -> State# RealWorld -> (# State# RealWorld, Array# (Ptr InfoProvEnt) #) foreign import prim "stg_cloneMyStackzh" cloneMyStack# :: State# RealWorld -> (# State# RealWorld, StackSnapshot# #) ===================================== libraries/ghc-heap/GHC/Exts/DecodeStack.hs ===================================== @@ -16,8 +16,6 @@ -- TODO: Find better place than top level. Re-export from top-level? module GHC.Exts.DecodeStack ( - StackFrame(..), - BitmapPayload(..), decodeStack ) where @@ -28,12 +26,12 @@ import Data.Bits import Foreign import Prelude import GHC.Stack.CloneStack -import GHC.Exts.Heap hiding (bitmap, size) -- TODO: Remove before releasing import Debug.Trace import GHC.Exts -import qualified GHC.Exts.Heap.Closures as CL - +import GHC.Exts.Heap.Closures as CL +import GHC.Exts.Heap.ClosureTypes +import GHC.Exts.DecodeHeap type StackFrameIter# = (# -- | StgStack @@ -48,9 +46,6 @@ data StackFrameIter = StackFrameIter StackFrameIter# instance Show StackFrameIter where show (StackFrameIter (# _, i# #)) = "StackFrameIter " ++ "(StackSnapshot _" ++ " " ++ show (W# i#) -instance Show StackSnapshot where - show _ = "StackSnapshot _" - -- | Get an interator starting with the top-most stack frame stackHead :: StackSnapshot -> StackFrameIter stackHead (StackSnapshot s) = StackFrameIter (# s , 0## #) -- GHC stacks are never empty @@ -106,30 +101,31 @@ toBitmapEntries sfi@(StackFrameIter(# s, i #)) bitmap bSize = BitmapEntry { isPrimitive = (bitmap .&. 1) /= 0 } : toBitmapEntries (StackFrameIter (# s , plusWord# i 1## #)) (bitmap `shiftR` 1) (bSize - 1) -toBitmapPayload :: BitmapEntry -> IO BitmapPayload -toBitmapPayload e | isPrimitive e = pure $ Primitive . toWord . closureFrame $ e +toBitmapPayload :: BitmapEntry -> IO Box +toBitmapPayload e | isPrimitive e = pure $ asBox . CL.UnknownTypeWordSizedPrimitive . toWord . closureFrame $ e where toWord (StackFrameIter (# s#, i# #)) = W# (derefStackWord# s# i#) -toBitmapPayload e = Closure <$> toClosure unpackClosureFromStackFrame# (closureFrame e) +toBitmapPayload e = toClosure unpackClosureFromStackFrame# (closureFrame e) -- TODO: Negative offsets won't work! Consider using Word -getClosure :: StackFrameIter -> Int -> IO CL.Closure +getClosure :: StackFrameIter -> Int -> IO Box getClosure sfi relativeOffset = toClosure (unpackClosureReferencedByFrame# (intToWord# relativeOffset)) sfi -toClosure :: (StackSnapshot# -> Word# -> (# Addr#, ByteArray#, Array# Any #)) -> StackFrameIter -> IO CL.Closure +toClosure :: (StackSnapshot# -> Word# -> (# Addr#, ByteArray#, Array# Any #)) -> StackFrameIter -> IO Box toClosure f# (StackFrameIter (# s#, i# #)) = case f# s# i# of (# infoTableAddr, heapRep, pointersArray #) -> do let infoTablePtr = Ptr infoTableAddr ptrList = [case indexArray# pointersArray i of - (# ptr #) -> Box ptr + (# ptr #) -> CL.Box ptr | I# i <- [0..I# (sizeofArray# pointersArray) - 1] ] - getClosureDataFromHeapRep heapRep infoTablePtr ptrList + c <- (getClosureDataFromHeapRep heapRep infoTablePtr ptrList) + pure $ asBox c -- TODO: Make function more readable: No IO in let bindings -decodeLargeBitmap :: (StackSnapshot# -> Word# -> (# ByteArray#, Word# #)) -> StackFrameIter -> Word# -> IO [BitmapPayload] +decodeLargeBitmap :: (StackSnapshot# -> Word# -> (# ByteArray#, Word# #)) -> StackFrameIter -> Word# -> IO [Box] decodeLargeBitmap getterFun# (StackFrameIter (# stackFrame#, closureOffset# #)) relativePayloadOffset# = let !(# bitmapArray#, size# #) = getterFun# stackFrame# closureOffset# bitmapWords :: [Word] = foldrByteArray (\w acc -> W# w : acc) [] bitmapArray# @@ -139,7 +135,7 @@ decodeLargeBitmap getterFun# (StackFrameIter (# stackFrame#, closureOffset# #)) payloads -- TODO: Make function more readable: No IO in let bindings -decodeSmallBitmap :: (StackSnapshot# -> Word# -> (# Word#, Word# #)) -> StackFrameIter -> Word# -> IO [BitmapPayload] +decodeSmallBitmap :: (StackSnapshot# -> Word# -> (# Word#, Word# #)) -> StackFrameIter -> Word# -> IO [Box] decodeSmallBitmap getterFun# (StackFrameIter (# stackFrame#, closureOffset# #)) relativePayloadOffset# = let !(# bitmap#, size# #) = getterFun# stackFrame# closureOffset# bes = toBitmapEntries (StackFrameIter (# stackFrame#, plusWord# closureOffset# relativePayloadOffset# #))(W# bitmap#) (W# size#) @@ -155,7 +151,7 @@ getHalfWord (StackFrameIter (# s#, i# #)) relativeOffset = W# (getHalfWord# s# i getWord :: StackFrameIter -> Int -> Word getWord (StackFrameIter (# s#, i# #)) relativeOffset = W# (getWord# s# i# (intToWord# relativeOffset)) -unpackStackFrameIter :: StackFrameIter -> IO StackFrame +unpackStackFrameIter :: StackFrameIter -> IO CL.Closure unpackStackFrameIter sfi@(StackFrameIter (# s#, i# #)) = trace ("decoding ... " ++ show @ClosureType ((toEnum . fromIntegral) (W# (getInfoTableType# s# i#))) ++ "\n") $ case (toEnum . fromIntegral) (W# (getInfoTableType# s# i#)) of RET_BCO -> do @@ -165,54 +161,54 @@ unpackStackFrameIter sfi@(StackFrameIter (# s#, i# #)) = trace ("decoding ... " let arity' = getHalfWord sfi offsetStgRetBCOFrameArity size' = getHalfWord sfi offsetStgRetBCOFrameSize payload' <- decodeLargeBitmap getBCOLargeBitmap# sfi 2## - pure $ RetBCO { - instrs = instrs', - literals = literals', - ptrs = ptrs', - arity = arity', - size = size', - payload = payload' + pure $ CL.RetBCO { + bcoInstrs = instrs', + bcoLiterals = literals', + bcoPtrs = ptrs', + bcoArity = arity', + bcoSize = size', + bcoPayload = payload' } RET_SMALL -> do payloads <- decodeSmallBitmap getSmallBitmap# sfi 1## let special# = getRetSmallSpecialType# s# i# special = (toEnum . fromInteger . toInteger) (W# special#) - pure $ RetSmall special payloads - RET_BIG -> RetBig <$> decodeLargeBitmap getLargeBitmap# sfi 1## + pure $ CL.RetSmall special payloads + RET_BIG -> CL.RetBig <$> decodeLargeBitmap getLargeBitmap# sfi 1## RET_FUN -> do let t = (toEnum . fromInteger . toInteger) (W# (getRetFunType# s# i#)) size' = getWord sfi offsetStgRetFunFrameSize fun' <- getClosure sfi offsetStgRetFunFrameFun payload' <- - if t == ARG_GEN_BIG then + if t == CL.ARG_GEN_BIG then decodeLargeBitmap getRetFunLargeBitmap# sfi 2## else decodeSmallBitmap getRetFunSmallBitmap# sfi 2## - pure $ RetFun t size' fun' payload' + pure $ CL.RetFun t size' fun' payload' -- TODO: Decode update frame type UPDATE_FRAME -> let !t = (toEnum . fromInteger . toInteger) (W# (getUpdateFrameType# s# i#)) in - UpdateFrame t <$> getClosure sfi offsetStgUpdateFrameUpdatee + CL.UpdateFrame t <$> getClosure sfi offsetStgUpdateFrameUpdatee CATCH_FRAME -> do -- TODO: Replace with getWord# expression let exceptionsBlocked = W# (getCatchFrameExceptionsBlocked# s# i#) c <- getClosure sfi offsetStgCatchFrameHandler - pure $ CatchFrame exceptionsBlocked c + pure $ CL.CatchFrame exceptionsBlocked c UNDERFLOW_FRAME -> let nextChunk# = getUnderflowFrameNextChunk# s# i# in - pure $ UnderflowFrame (StackSnapshot nextChunk#) - STOP_FRAME -> pure StopFrame - ATOMICALLY_FRAME -> AtomicallyFrame + pure $ CL.UnderflowFrame (StackSnapshot nextChunk#) + STOP_FRAME -> pure CL.StopFrame + ATOMICALLY_FRAME -> CL.AtomicallyFrame <$> getClosure sfi offsetStgAtomicallyFrameCode <*> getClosure sfi offsetStgAtomicallyFrameResult CATCH_RETRY_FRAME -> do let running_alt_code' = getWord sfi offsetStgCatchRetryFrameRunningAltCode first_code' <- getClosure sfi offsetStgCatchRetryFrameRunningFirstCode alt_code' <- getClosure sfi offsetStgCatchRetryFrameRunningAltCode - pure $ CatchRetryFrame running_alt_code' first_code' alt_code' - CATCH_STM_FRAME -> CatchStmFrame + pure $ CL.CatchRetryFrame running_alt_code' first_code' alt_code' + CATCH_STM_FRAME -> CL.CatchStmFrame <$> getClosure sfi offsetStgCatchSTMFrameCode <*> getClosure sfi offsetStgCatchSTMFrameHandler x -> error $ "Unexpected closure type on stack: " ++ show x @@ -262,98 +258,6 @@ foreign import prim "getHalfWordzh" getHalfWord# :: StackSnapshot# -> Word# -> foreign import prim "getRetFunTypezh" getRetFunType# :: StackSnapshot# -> Word# -> Word# -data BitmapPayload = Closure CL.Closure | Primitive Word - -instance Show BitmapPayload where - show (Primitive w) = "Primitive " ++ show w - show (Closure ptr) = "Closure " ++ show ptr -- showAddr# addr# - --- TODO There are likely more. See MiscClosures.h -data SpecialRetSmall = - -- TODO: Shoudn't `None` be better `Maybe ...`? - None | - ApV | - ApF | - ApD | - ApL | - ApN | - ApP | - ApPP | - ApPPP | - ApPPPP | - ApPPPPP | - ApPPPPPP | - RetV | - RetP | - RetN | - RetF | - RetD | - RetL | - RestoreCCCS | - RestoreCCCSEval - deriving (Enum, Eq, Show) - -data UpdateFrameType = - NormalUpdateFrame | - BhUpdateFrame | - MarkedUpdateFrame - deriving (Enum, Eq, Show) - -data StackFrame = - UpdateFrame { knownUpdateFrameType :: UpdateFrameType, updatee :: CL.Closure } | - CatchFrame { exceptions_blocked :: Word, handler :: CL.Closure } | - CatchStmFrame { code :: CL.Closure, handler :: CL.Closure } | - CatchRetryFrame {running_alt_code :: Word, first_code :: CL.Closure, alt_code :: CL.Closure} | - AtomicallyFrame { code :: CL.Closure, result :: CL.Closure} | - -- TODO: nextChunk could be a CL.Closure, too! (StackClosure) - UnderflowFrame { nextChunk:: StackSnapshot } | - StopFrame | - RetSmall { knownRetSmallType :: SpecialRetSmall, payload :: [BitmapPayload]} | - RetBig { payload :: [BitmapPayload] } | - RetFun { retFunType :: RetFunType, size :: Word, fun :: CL.Closure, payload :: [BitmapPayload]} | - RetBCO { - -- TODO: Add pre-defined BCO closures (like knownUpdateFrameType) - instrs :: CL.Closure, - literals :: CL.Closure, - ptrs :: CL.Closure, - arity :: Word, - size :: Word, - payload :: [BitmapPayload] - } - deriving (Show) - -data RetFunType = - ARG_GEN | - ARG_GEN_BIG | - ARG_BCO | - ARG_NONE | - ARG_N | - ARG_P | - ARG_F | - ARG_D | - ARG_L | - ARG_V16 | - ARG_V32 | - ARG_V64 | - ARG_NN | - ARG_NP | - ARG_PN | - ARG_PP | - ARG_NNN | - ARG_NNP | - ARG_NPN | - ARG_NPP | - ARG_PNN | - ARG_PNP | - ARG_PPN | - ARG_PPP | - ARG_PPPP | - ARG_PPPPP | - ARG_PPPPPP | - ARG_PPPPPPP | - ARG_PPPPPPPP - deriving (Show, Eq, Enum) - #if defined(DEBUG) foreign import ccall "belchStack" belchStack# :: StackSnapshot# -> IO () @@ -361,17 +265,17 @@ belchStack :: StackSnapshot -> IO () belchStack (StackSnapshot s#) = belchStack# s# #endif -decodeStack :: StackSnapshot -> IO [StackFrame] +decodeStack :: StackSnapshot -> IO CL.Closure decodeStack s = do #if defined(DEBUG) belchStack s #endif - decodeStack' s + SimpleStack . (map asBox) <$> decodeStack' s -decodeStack' :: StackSnapshot -> IO [StackFrame] +decodeStack' :: StackSnapshot -> IO [CL.Closure] decodeStack' s = unpackStackFrameIter (stackHead s) >>= \frame -> (frame :) <$> go (advanceStackFrameIter (stackHead s)) where - go :: Maybe StackFrameIter -> IO [StackFrame] + go :: Maybe StackFrameIter -> IO [CL.Closure] go Nothing = pure [] go (Just sfi) = (trace "decode\n" (unpackStackFrameIter sfi)) >>= \frame -> (frame :) <$> go (advanceStackFrameIter sfi) ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -27,6 +27,9 @@ module GHC.Exts.Heap ( , PrimType(..) , WhatNext(..) , WhyBlocked(..) + , UpdateFrameType(..) + , SpecialRetSmall(..) + , RetFunType(..) , TsoFlags(..) , HasHeapRep(getClosureData) , getClosureDataFromHeapRep @@ -60,23 +63,22 @@ module GHC.Exts.Heap ( 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 qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI +import GHC.Exts.DecodeHeap -import Control.Monad -import Data.Bits -import Foreign import GHC.Exts import GHC.Int import GHC.Word +#if MIN_VERSION_base(4,17,0) +import GHC.Stack.CloneStack +import GHC.Exts.DecodeStack +#endif + #include "ghcconfig.h" @@ -131,6 +133,11 @@ instance Double# ~ a => HasHeapRep (a :: TYPE 'DoubleRep) where getClosureData x = return $ DoubleClosure { ptipe = PDouble, doubleVal = D# x } +#if MIN_VERSION_base(4,17,0) +instance HasHeapRep StackSnapshot# where + getClosureData s# = decodeStack (StackSnapshot s#) +#endif + -- | 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 @@ -164,235 +171,6 @@ getClosureDataFromHeapObject x = do STACK -> pure $ UnsupportedClosure infoTable _ -> getClosureDataFromHeapRep 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 :: ByteArray# -> Ptr StgInfoTable -> [b] -> IO (GenClosure b) -getClosureDataFromHeapRep heapRep infoTablePtr pts = do - itbl <- peekItbl infoTablePtr - getClosureDataFromHeapRepPrim (dataConNames infoTablePtr) PPI.peekTopCCS itbl heapRep pts - -getClosureDataFromHeapRepPrim - :: IO (String, String, String) - -- ^ A continuation used to decode the constructor description field, - -- in ghc-debug this code can lead to segfaults because dataConNames - -- will dereference a random part of memory. - -> (Ptr a -> IO (Maybe CostCentreStack)) - -- ^ A continuation which is used to decode a cost centre stack - -- In ghc-debug, this code will need to call back into the debuggee to - -- fetch the representation of the CCS before decoding it. Using - -- `peekTopCCS` for this argument can lead to segfaults in ghc-debug as - -- the CCS argument will point outside the copied closure. - -> StgInfoTable - -- ^ The `StgInfoTable` of the closure, extracted from the heap - -- representation. - -> 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. - -> [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. -getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do - 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) <- getConDesc - pure $ ConstrClosure itbl pts npts p m n - - t | t >= THUNK && t <= THUNK_STATIC -> do - pure $ ThunkClosure itbl pts npts - - THUNK_SELECTOR -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to THUNK_SELECTOR" - pure $ SelectorClosure itbl (head pts) - - t | t >= FUN && t <= FUN_STATIC -> do - pure $ FunClosure itbl pts npts - - AP -> 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 payloadWords >= 2) $ - fail "Expected at least 2 raw words to AP" - let splitWord = payloadWords !! 0 - pure $ APClosure itbl -#if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) -#else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) -#endif - (head pts) (tail pts) - - PAP -> 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 payloadWords >= 2) $ - fail "Expected at least 2 raw words to PAP" - let splitWord = payloadWords !! 0 - pure $ PAPClosure itbl -#if defined(WORDS_BIGENDIAN) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) - (fromIntegral splitWord) -#else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) -#endif - (head pts) (tail pts) - - AP_STACK -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to AP_STACK" - pure $ APStackClosure itbl (head pts) (tail pts) - - IND -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND" - pure $ IndClosure itbl (head pts) - - IND_STATIC -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to IND_STATIC" - pure $ IndClosure itbl (head pts) - - BLACKHOLE -> do - unless (length pts >= 1) $ - fail "Expected at least 1 ptr argument to BLACKHOLE" - pure $ BlackholeClosure itbl (head pts) - - BCO -> do - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptr argument to BCO, found " - ++ show (length pts) - unless (length payloadWords >= 4) $ - fail $ "Expected at least 4 words to BCO, found " - ++ 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)) - (fromIntegral splitWord) -#else - (fromIntegral splitWord) - (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) -#endif - (drop 4 payloadWords) - - ARR_WORDS -> do - unless (length payloadWords >= 1) $ - fail $ "Expected at least 1 words to ARR_WORDS, found " - ++ 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 payloadWords >= 2) $ - fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " - ++ "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 payloadWords >= 1) $ - fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " - ++ "found " ++ show (length payloadWords) - pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts - - 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 - unless (length pts >= 3) $ - fail $ "Expected at least 3 ptrs to MVAR, found " - ++ show (length pts) - pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) - - BLOCKING_QUEUE -> - pure $ OtherClosure itbl pts rawHeapWords - -- pure $ BlockingQueueClosure itbl - -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - - -- pure $ OtherClosure itbl pts rawHeapWords - -- - WEAK -> do - pure $ WeakClosure - { info = itbl - , cfinalizers = pts !! 0 - , key = pts !! 1 - , value = pts !! 2 - , finalizer = pts !! 3 - , weakLink = case drop 4 pts of - [] -> Nothing - [p] -> Just p - _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) - } - TSO | [ u_lnk, u_gbl_lnk, tso_stack, u_trec, u_blk_ex, u_bq] <- pts - -> withArray rawHeapWords (\ptr -> do - fields <- FFIClosures.peekTSOFields decodeCCS 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 - -> 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 - }) - | otherwise - -> fail $ "Expected 0 ptr argument to STACK, found " - ++ show (length pts) - - _ -> - pure $ UnsupportedClosure itbl - -- | 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 ===================================== @@ -15,8 +15,12 @@ module GHC.Exts.Heap.Closures ( , WhatNext(..) , WhyBlocked(..) , TsoFlags(..) + , UpdateFrameType(..) + , SpecialRetSmall(..) + , RetFunType(..) , allClosures , closureSize + , RetFunType(..) -- * Boxes , Box(..) @@ -48,6 +52,10 @@ import GHC.Exts import GHC.Generics import Numeric +#if MIN_VERSION_base(4,17,0) +import GHC.Stack.CloneStack (StackSnapshot(..)) +#endif + ------------------------------------------------------------------------ -- Boxes @@ -302,6 +310,70 @@ data GenClosure b #endif } +#if MIN_VERSION_base(4,17,0) + -- TODO: I could model stack chunks here (much better). However, I need the + -- code to typecheck, now. + | SimpleStack { + stackClosures :: ![b] + } + -- TODO: Add `info :: !StgInfoTable` fields + | UpdateFrame + { knownUpdateFrameType :: !UpdateFrameType + , updatee :: !b + } + + | CatchFrame + { exceptions_blocked :: Word + , handler :: !b + } + + | CatchStmFrame + { catchFrameCode :: !b + , handler :: !b + } + + | CatchRetryFrame + { running_alt_code :: !Word + , first_code :: !b + , alt_code :: !b + } + + | AtomicallyFrame + { atomicallyFrameCode :: !b + , result :: !b + } + + -- TODO: nextChunk could be a CL.Closure, too! (StackClosure) + | UnderflowFrame + { nextChunk:: !StackSnapshot } + + | StopFrame + + | RetSmall + { knownRetSmallType :: !SpecialRetSmall + , payload :: ![b] + } + + | RetBig + { payload :: ![b] } + + | RetFun + { retFunType :: RetFunType + , retFunSize :: Word + , retFunFun :: !b + , retFunPayload :: ![b] + } + + | RetBCO + -- TODO: Add pre-defined BCO closures (like knownUpdateFrameType) + { bcoInstrs :: !b + , bcoLiterals :: !b + , bcoPtrs :: !b + , bcoArity :: !Word + , bcoSize :: !Word + , bcoPayload :: ![b] + } +#endif ------------------------------------------------------------ -- Unboxed unlifted closures @@ -353,8 +425,73 @@ data GenClosure b | UnsupportedClosure { info :: !StgInfoTable } + + | UnknownTypeWordSizedPrimitive + { wordVal :: !Word } deriving (Eq, Show, Generic, Functor, Foldable, Traversable) +-- TODO There are likely more. See MiscClosures.h +data SpecialRetSmall = + -- TODO: Shoudn't `None` be better `Maybe ...`? + None | + ApV | + ApF | + ApD | + ApL | + ApN | + ApP | + ApPP | + ApPPP | + ApPPPP | + ApPPPPP | + ApPPPPPP | + RetV | + RetP | + RetN | + RetF | + RetD | + RetL | + RestoreCCCS | + RestoreCCCSEval + deriving (Enum, Eq, Show, Generic) + +data UpdateFrameType = + NormalUpdateFrame | + BhUpdateFrame | + MarkedUpdateFrame + deriving (Enum, Eq, Show, Generic, Ord) + +data RetFunType = + ARG_GEN | + ARG_GEN_BIG | + ARG_BCO | + ARG_NONE | + ARG_N | + ARG_P | + ARG_F | + ARG_D | + ARG_L | + ARG_V16 | + ARG_V32 | + ARG_V64 | + ARG_NN | + ARG_NP | + ARG_PN | + ARG_PP | + ARG_NNN | + ARG_NNP | + ARG_NPN | + ARG_NPP | + ARG_PNN | + ARG_PNP | + ARG_PPN | + ARG_PPP | + ARG_PPPP | + ARG_PPPPP | + ARG_PPPPPP | + ARG_PPPPPPP | + ARG_PPPPPPPP + deriving (Show, Eq, Enum, Generic) data PrimType = PInt ===================================== libraries/ghc-heap/ghc-heap.cabal.in ===================================== @@ -38,6 +38,7 @@ library GHC.Exts.Heap.Closures GHC.Exts.Heap.ClosureTypes GHC.Exts.Heap.Constants + GHC.Exts.DecodeHeap GHC.Exts.DecodeStack GHC.Exts.Heap.InfoTable GHC.Exts.Heap.InfoTable.Types ===================================== libraries/ghc-heap/tests/stack_stm_frames.hs ===================================== @@ -18,6 +18,10 @@ main = do "Stack contains one catch stm frame" (== 1) (length $ filter isCatchStmFrame decodedStack) + assertThat + "Stack contains one atomically frame" + (== 1) + (length $ filter isAtomicallyFrame decodedStack) getDecodedStack :: IO (StackSnapshot, [StackFrame]) getDecodedStack = do @@ -28,3 +32,7 @@ getDecodedStack = do isCatchStmFrame :: StackFrame -> Bool isCatchStmFrame (CatchStmFrame _ _) = True isCatchStmFrame _ = False + +isAtomicallyFrame :: StackFrame -> Bool +isAtomicallyFrame (AtomicallyFrame _ _) = True +isAtomicallyFrame _ = False ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -1,6 +1,6 @@ {-# LANGUAGE GADTs, DeriveGeneric, StandaloneDeriving, ScopedTypeVariables, GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards, - CPP #-} + CPP, MagicHash, TypeApplications #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-orphans #-} -- | @@ -53,7 +53,11 @@ import qualified Language.Haskell.TH.Syntax as TH import System.Exit import System.IO import System.IO.Error - +#if MIN_VERSION_base(4,17,0) +import GHC.Stack.CloneStack +import GHC.Word (Word(W#)) +import GHC.Exts (Word#, unsafeCoerce#, StackSnapshot#) +#endif -- ----------------------------------------------------------------------------- -- The RPC protocol between GHC and the interactive server @@ -471,6 +475,21 @@ instance Binary Heap.WhyBlocked instance Binary Heap.TsoFlags #endif +#if MIN_VERSION_base(4,17,0) +instance Binary Heap.SpecialRetSmall +instance Binary Heap.UpdateFrameType +instance Binary Heap.RetFunType +-- TODO: Revisit this. This instance is pretty hacky (unsafeCoerce# ...) +instance Binary StackSnapshot where + get = do + v <- get @Word + pure $ StackSnapshot (toPrim v) + where + toPrim :: Word -> StackSnapshot# + toPrim (W# w#) = unsafeCoerce# w# + put (StackSnapshot s#) = put (W# ((unsafeCoerce# s#) :: Word#)) +#endif + instance Binary Heap.StgInfoTable instance Binary Heap.ClosureType instance Binary Heap.PrimType View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/989cebf1929949435251e4c22986e6fb512d7f3a...a8a4bb669eecd5ec3d2472a91828174f1f4b8cdb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/989cebf1929949435251e4c22986e6fb512d7f3a...a8a4bb669eecd5ec3d2472a91828174f1f4b8cdb You're receiving 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 Dec 9 20:15:43 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 09 Dec 2022 15:15:43 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 12 commits: Document TH splices' interaction with INCOHERENT instances Message-ID: <6393976f9e4e8_224fca6068091886c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 5449d5b7 by Matthew Pickering at 2022-12-09T15:15:35-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 9384114b by Matthew Pickering at 2022-12-09T15:15:35-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - eef43cea by Matthew Pickering at 2022-12-09T15:15:35-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - fcd9b7d5 by Matthew Pickering at 2022-12-09T15:15:35-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - 762e6d2d by Matthew Pickering at 2022-12-09T15:15:35-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - f1972ad8 by Matthew Pickering at 2022-12-09T15:15:35-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - dbdc6a03 by Matthew Pickering at 2022-12-09T15:15:35-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - 38e42040 by Matthew Pickering at 2022-12-09T15:15:35-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - 19 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Lint.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Make.hs - configure.ac - docs/users_guide/exts/misc.rst - docs/users_guide/exts/template_haskell.rst - + docs/users_guide/exts/whitespace.rst - hadrian/bootstrap/generate_bootstrap_plans - hadrian/bootstrap/hadrian-bootstrap-gen.cabal - − hadrian/bootstrap/plan-8_10_1.json - − hadrian/bootstrap/plan-8_10_2.json - − hadrian/bootstrap/plan-8_10_3.json - − hadrian/bootstrap/plan-8_10_4.json - − hadrian/bootstrap/plan-8_10_5.json - − hadrian/bootstrap/plan-8_10_7.json - − hadrian/bootstrap/plan-9_0_1.json - − hadrian/bootstrap/plan-9_0_2.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd0ba573ad251c7139b13dba9796def4146e687a...38e42040e26983f3ecd80429f54d5e5033030301 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd0ba573ad251c7139b13dba9796def4146e687a...38e42040e26983f3ecd80429f54d5e5033030301 You're receiving 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 Dec 10 01:16:05 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 09 Dec 2022 20:16:05 -0500 Subject: [Git][ghc/ghc][master] 5 commits: Update containers submodule Message-ID: <6393ddd58abe8_224fca219996409415fe@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - 6 changed files: - .gitlab-ci.yml - compiler/GHC/Driver/Make.hs - configure.ac - hadrian/ghci-multi-cabal.in - hadrian/src/Rules/ToolArgs.hs - libraries/containers Changes: ===================================== .gitlab-ci.yml ===================================== @@ -376,6 +376,57 @@ hadrian-ghc-in-ghci: paths: - cabal-cache +############################################################ +# Hadrian Multi-Repl +############################################################ + +hadrian-multi: + stage: testing + needs: + - job: x86_64-linux-fedora33-release + optional: true + - job: nightly-x86_64-linux-fedora33-release + optional: true + - job: release-x86_64-linux-fedora33-release + optional: true + dependencies: null + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora33:$DOCKER_REV" + before_script: + # workaround for docker permissions + - sudo chown ghc:ghc -R . + variables: + GHC_FLAGS: -Werror + CONFIGURE_ARGS: --enable-bootstrap-with-devel-snapshot + tags: + - x86_64-linux + script: + - export BOOT_HC=$GHC + - root=$(pwd)/ghc + - ls + - | + mkdir tmp + tar -xf ghc-x86_64-linux-fedora33-release.tar.xz -C tmp + pushd tmp/ghc-*/ + ./configure --prefix=$root + make install + popd + rm -Rf tmp + - export HC=$root/bin/ghc + # This GHC means, use this GHC to configure with + - export GHC=$root/bin/ghc + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + # Now GHC means, use this GHC for hadrian + - export GHC=$BOOT_HC + # Load hadrian-multi then immediately exit and check the modules loaded + - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok," + after_script: + - .gitlab/ci.sh save_cache + cache: + key: hadrian-ghci-$CACHE_REV + paths: + - cabal-cache + ############################################################ # stack-hadrian-build ############################################################ ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -1161,9 +1161,10 @@ interpretBuildPlan hug mhmi_cache old_hpt plan = do hug_var <- gets hug_var !build_map <- getBuildMap res_var <- liftIO newEmptyMVar - let + let loop_unit :: UnitId + !loop_unit = nodeKeyUnitId (gwib_mod (head deps)) !build_deps = getDependencies (map gwib_mod deps) build_map - let loop_action = do + let loop_action = withCurrentUnit loop_unit $ do (hug, tdeps) <- wait_deps_hug hug_var build_deps hsc_env <- asks hsc_env let new_hsc = setHUG hug hsc_env ===================================== configure.ac ===================================== @@ -1201,6 +1201,7 @@ AC_CONFIG_FILES( [ mk/project.mk hadrian/cfg/system.config hadrian/ghci-cabal + hadrian/ghci-multi-cabal hadrian/ghci-stack docs/users_guide/ghc_config.py distrib/configure.ac ===================================== hadrian/ghci-multi-cabal.in ===================================== @@ -1,7 +1,7 @@ #!/usr/bin/env sh -GHC=@WithGhc@ -if [[ $(printf "9.4.0\n%s\n" $($GHC --numeric-version) | sort -uV | head -n 1) != "9.4.0" ]]; then echo "Multi-repl needs at least GHC-9.4.1"; exit 1; fi +RUN_GHC=@WithGhc@ +if [[ $(printf "9.4.0\n%s\n" $($RUN_GHC --numeric-version) | sort -uV | head -n 1) != "9.4.0" ]]; then echo "Multi-repl needs at least GHC-9.4.1"; exit 1; fi # This file is generated by configure from ghci-multi.in @@ -10,4 +10,4 @@ export TOOL_OUTPUT=.hadrian_ghci_multi/ghci_args # Replace newlines with spaces, as these otherwise break the ghci invocation on windows. CABFLAGS=-v0 "hadrian/build-cabal" multi:ghc --build-root=.hadrian_ghci_multi --flavour=ghc-in-ghci $HADRIAN_ARGS GHC_FLAGS="$GHC_FLAGS $(cat $TOOL_OUTPUT | tr '\n\r' ' ')" -$GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -hidir=.hadrian_ghci_multi/interface -O0 +RTS -A128m +$RUN_GHC --interactive $GHC_FLAGS $@ -fno-code -fwrite-interface -O0 +RTS -A128m ===================================== hadrian/src/Rules/ToolArgs.hs ===================================== @@ -84,9 +84,11 @@ multiSetup pkg_s = do gens <- interpretInContext c generatedDependencies need (srcs ++ gens) let rexp m = ["-reexported-module", m] + let hidir = root "interfaces" pkgPath p writeFile' (resp_file root p) (intercalate "\n" (th_hack arg_list ++ modules cd - ++ concatMap rexp (reexportModules cd) )) + ++ concatMap rexp (reexportModules cd) + ++ ["-outputdir", hidir])) return (resp_file root p) @@ -151,6 +153,7 @@ toolTargets = [ binary , directory , process , exceptions + , filepath -- , ghc -- # depends on ghc library -- , runGhc -- # depends on ghc library , ghcBoot ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 5e338df84454b56d649360a57d2c186785aff2b4 +Subproject commit fbafcf704f0febd9ddac84dbe00ae3787af43550 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5b007ec52ba77051fedd2b9a6fb155b248081511...ab06c0f0ccaeb3277195e4eeac541c00558d4cc2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5b007ec52ba77051fedd2b9a6fb155b248081511...ab06c0f0ccaeb3277195e4eeac541c00558d4cc2 You're receiving 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 Dec 10 01:16:38 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 09 Dec 2022 20:16:38 -0500 Subject: [Git][ghc/ghc][master] 3 commits: hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. Message-ID: <6393ddf6c4c6a_224fca2199964094527c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - 15 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Lint.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Data/Unboxed.hs - hadrian/bootstrap/generate_bootstrap_plans - hadrian/bootstrap/hadrian-bootstrap-gen.cabal - − hadrian/bootstrap/plan-8_10_1.json - − hadrian/bootstrap/plan-8_10_2.json - − hadrian/bootstrap/plan-8_10_3.json - − hadrian/bootstrap/plan-8_10_4.json - − hadrian/bootstrap/plan-8_10_5.json - − hadrian/bootstrap/plan-8_10_7.json - − hadrian/bootstrap/plan-9_0_1.json - − hadrian/bootstrap/plan-9_0_2.json - + hadrian/bootstrap/plan-9_2_1.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab06c0f0ccaeb3277195e4eeac541c00558d4cc2...c658c580863fc23c29f183db3f52a2004756d84c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab06c0f0ccaeb3277195e4eeac541c00558d4cc2...c658c580863fc23c29f183db3f52a2004756d84c You're receiving 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 Dec 10 02:21:15 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Fri, 09 Dec 2022 21:21:15 -0500 Subject: [Git][ghc/ghc][wip/T22570] checkValidInst: Don't expand synonyms when splitting sigma types Message-ID: <6393ed1bac708_224fca2595e17c945454@gitlab.mail> Ryan Scott pushed to branch wip/T22570 at Glasgow Haskell Compiler / GHC Commits: 260b79d9 by Ryan Scott at 2022-12-09T21:04:06-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `tcSplitSigmaTyNoView`, a version of `tcSplitSigmaTy` that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 5 changed files: - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Validity.hs - + testsuite/tests/typecheck/should_fail/T22570.hs - + testsuite/tests/typecheck/should_fail/T22570.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -63,16 +63,19 @@ module GHC.Tc.Utils.TcType ( -- Splitters getTyVar, getTyVar_maybe, getCastedTyVar_maybe, tcSplitForAllTyVarBinder_maybe, - tcSplitForAllTyVars, tcSplitForAllInvisTyVars, tcSplitSomeForAllTyVars, + tcSplitForAllTyVars, + tcSplitForAllInvisTyVars, tcSplitForAllInvisTyVarsNoView, + tcSplitSomeForAllTyVars, tcSplitSomeForAllTyVarsNoView, tcSplitForAllReqTVBinders, tcSplitForAllInvisTVBinders, tcSplitPiTys, tcSplitPiTy_maybe, tcSplitForAllTyVarBinders, - tcSplitPhiTy, tcSplitPredFunTy_maybe, + tcSplitPhiTy, tcSplitPhiTyNoView, + tcSplitPredFunTy_maybe, tcSplitPredFunTyNoView_maybe, tcSplitFunTy_maybe, tcSplitFunTys, tcFunArgTy, tcFunResultTy, tcFunResultTyN, tcSplitFunTysN, tcSplitTyConApp, tcSplitTyConApp_maybe, tcTyConAppTyCon, tcTyConAppTyCon_maybe, tcTyConAppArgs, tcSplitAppTy_maybe, tcSplitAppTy, tcSplitAppTys, tcSplitAppTyNoView_maybe, - tcSplitSigmaTy, tcSplitNestedSigmaTys, + tcSplitSigmaTy, tcSplitSigmaTyNoView, tcSplitNestedSigmaTys, --------------------------------- -- Predicates. @@ -1373,6 +1376,10 @@ tcSplitForAllTyVars ty tcSplitForAllInvisTyVars :: Type -> ([TyVar], Type) tcSplitForAllInvisTyVars ty = tcSplitSomeForAllTyVars isInvisibleForAllTyFlag ty +-- | Same as 'tcSplitForAllInvisTyVars' but without looking through synonyms. +tcSplitForAllInvisTyVarsNoView :: Type -> ([TyVar], Type) +tcSplitForAllInvisTyVarsNoView ty = tcSplitSomeForAllTyVarsNoView isInvisibleForAllTyFlag ty + -- | Like 'tcSplitForAllTyVars', but only splits a 'ForAllTy' if @argf_pred argf@ -- is 'True', where @argf@ is the visibility of the @ForAllTy@'s binder and -- @argf_pred@ is a predicate over visibilities provided as an argument to this @@ -1386,6 +1393,15 @@ tcSplitSomeForAllTyVars argf_pred ty split orig_ty ty tvs | Just ty' <- coreView ty = split orig_ty ty' tvs split orig_ty _ tvs = (reverse tvs, orig_ty) +-- | Same as 'tcSplitSomeForAllTyVars' but without looking through synonyms. +tcSplitSomeForAllTyVarsNoView :: (ForAllTyFlag -> Bool) -> Type -> ([TyVar], Type) +tcSplitSomeForAllTyVarsNoView argf_pred ty + = split ty ty [] + where + split _ (ForAllTy (Bndr tv argf) ty) tvs + | argf_pred argf = split ty ty (tv:tvs) + split orig_ty _ tvs = (reverse tvs, orig_ty) + -- | Like 'tcSplitForAllTyVars', but only splits 'ForAllTy's with 'Required' type -- variable binders. All split tyvars are annotated with '()'. tcSplitForAllReqTVBinders :: Type -> ([TcReqTVBinder], Type) @@ -1413,6 +1429,14 @@ tcSplitPredFunTy_maybe (FunTy { ft_af = af, ft_arg = arg, ft_res = res }) tcSplitPredFunTy_maybe _ = Nothing +-- | Same as 'tcSplitPredFunTy_maybe' but without looking through synonyms. +tcSplitPredFunTyNoView_maybe :: Type -> Maybe (PredType, Type) +tcSplitPredFunTyNoView_maybe (FunTy { ft_af = af, ft_arg = arg, ft_res = res }) + | isInvisibleFunArg af + = Just (arg, res) +tcSplitPredFunTyNoView_maybe _ + = Nothing + tcSplitPhiTy :: Type -> (ThetaType, Type) tcSplitPhiTy ty = split ty [] @@ -1422,6 +1446,16 @@ tcSplitPhiTy ty Just (pred, ty) -> split ty (pred:ts) Nothing -> (reverse ts, ty) +-- | Same as 'tcSplitPhiTy' but without looking through synonyms. +tcSplitPhiTyNoView :: Type -> (ThetaType, Type) +tcSplitPhiTyNoView ty + = split ty [] + where + split ty ts + = case tcSplitPredFunTyNoView_maybe ty of + Just (pred, ty) -> split ty (pred:ts) + Nothing -> (reverse ts, ty) + -- | Split a sigma type into its parts. This only splits /invisible/ type -- variable binders, as these are the only forms of binder that the typechecker -- will implicitly instantiate. @@ -1430,6 +1464,14 @@ tcSplitSigmaTy ty = case tcSplitForAllInvisTyVars ty of (tvs, rho) -> case tcSplitPhiTy rho of (theta, tau) -> (tvs, theta, tau) +-- | Same as 'tcSplitSigmaTy' but without looking through synonyms. +tcSplitSigmaTyNoView :: Type -> ([TyVar], ThetaType, Type) +tcSplitSigmaTyNoView ty = + case tcSplitForAllInvisTyVarsNoView ty of + (tvs, rho) -> + case tcSplitPhiTyNoView rho of + (theta, tau) -> (tvs, theta, tau) + -- | Split a sigma type into its parts, going underneath as many arrows -- and foralls as possible. See Note [tcSplitNestedSigmaTys] tcSplitNestedSigmaTys :: Type -> ([TyVar], ThetaType, Type) ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -1731,6 +1731,12 @@ the instance head, we'll expand the synonym on fly, and it'll look like instance (%,%) (Show Int, Show Int) and we /really/ don't want that. So we carefully do /not/ expand synonyms, by matching on TyConApp directly. + +For similar reasons, we use tcSplitSigmaTyNoView rather than tcSplitSigmaTy +when decomposing the type variable binders and instance context, as the latter +looks through type synonyms. If we used the latter, then it could be possible +to write an instance for a type synonym involving a quantified constraint +(see #22570). -} checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM () @@ -1774,7 +1780,7 @@ checkValidInstance ctxt hs_type ty = case tau of ; return () } _ -> failWithTc (TcRnNoClassInstHead tau) where - (_tvs, theta, tau) = tcSplitSigmaTy ty + (_tvs, theta, tau) = tcSplitSigmaTyNoView ty -- The location of the "head" of the instance head_loc = getLoc (getLHsInstDeclHead hs_type) ===================================== testsuite/tests/typecheck/should_fail/T22570.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module T22570 where + +import Data.Kind + +class SomeClass a +class OtherClass + +type SomeClassUnit = OtherClass => SomeClass () :: Constraint + +instance SomeClassUnit + +type SomeClassSyn a = OtherClass => SomeClass a :: Constraint + +instance SomeClassSyn () ===================================== testsuite/tests/typecheck/should_fail/T22570.stderr ===================================== @@ -0,0 +1,10 @@ + +T22570.hs:11:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassUnit’ + +T22570.hs:15:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassSyn ()’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -665,3 +665,4 @@ test('MissingDefaultMethodBinding', normal, compile_fail, ['']) test('T21447', normal, compile_fail, ['']) test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) +test('T22570', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/260b79d9768628ea14bc98caa5017fb49fca435a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/260b79d9768628ea14bc98caa5017fb49fca435a You're receiving 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 Dec 10 12:35:26 2022 From: gitlab at gitlab.haskell.org (sheaf (@sheaf)) Date: Sat, 10 Dec 2022 07:35:26 -0500 Subject: [Git][ghc/ghc][wip/int-index/tok-at-app-kind] HsToken in TypeArg (#19623) Message-ID: <63947d0ec4795_224fca6061c972392@gitlab.mail> sheaf pushed to branch wip/int-index/tok-at-app-kind at Glasgow Haskell Compiler / GHC Commits: 4c9bc4fd by Vladislav Zavialov at 2022-12-10T13:35:01+01:00 HsToken in TypeArg (#19623) Updates the haddock submodule. - - - - - 18 changed files: - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - compiler/Language/Haskell/Syntax/Type.hs - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - utils/check-exact/ExactPrint.hs - utils/haddock Changes: ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -510,10 +510,10 @@ deriving instance Data thing => Data (HsScaled GhcPs thing) deriving instance Data thing => Data (HsScaled GhcRn thing) deriving instance Data thing => Data (HsScaled GhcTc thing) -deriving instance (Data a, Data b) => Data (HsArg a b) --- deriving instance Data (HsArg (Located (HsType GhcPs)) (Located (HsKind GhcPs))) --- deriving instance Data (HsArg (Located (HsType GhcRn)) (Located (HsKind GhcRn))) --- deriving instance Data (HsArg (Located (HsType GhcTc)) (Located (HsKind GhcTc))) +-- deriving instance (Data a, Data b) => Data (HsArg p a b) +deriving instance (Data a, Data b) => Data (HsArg GhcPs a b) +deriving instance (Data a, Data b) => Data (HsArg GhcRn a b) +deriving instance (Data a, Data b) => Data (HsArg GhcTc a b) -- deriving instance (DataIdLR p p) => Data (ConDeclField p) deriving instance Data (ConDeclField GhcPs) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE DeriveDataTypeable #-} @@ -94,6 +95,7 @@ import Language.Haskell.Syntax.Type import {-# SOURCE #-} GHC.Hs.Expr ( pprUntypedSplice, HsUntypedSpliceResult(..) ) +import Language.Haskell.Syntax.Concrete import Language.Haskell.Syntax.Extension import GHC.Core.DataCon( SrcStrictness(..), SrcUnpackedness(..), HsImplBang(..) ) import GHC.Hs.Extension @@ -312,7 +314,7 @@ type instance XIParamTy (GhcPass _) = EpAnn [AddEpAnn] type instance XStarTy (GhcPass _) = NoExtField type instance XKindSig (GhcPass _) = EpAnn [AddEpAnn] -type instance XAppKindTy (GhcPass _) = SrcSpan -- Where the `@` lives +type instance XAppKindTy (GhcPass _) = NoExtField type instance XSpliceTy GhcPs = NoExtField type instance XSpliceTy GhcRn = HsUntypedSpliceResult (LHsType GhcRn) @@ -489,10 +491,10 @@ mkHsAppTys :: LHsType (GhcPass p) -> [LHsType (GhcPass p)] -> LHsType (GhcPass p) mkHsAppTys = foldl' mkHsAppTy -mkHsAppKindTy :: XAppKindTy (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) +mkHsAppKindTy :: LHsType (GhcPass p) -> LHsToken "@" (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -mkHsAppKindTy ext ty k - = addCLocAA ty k (HsAppKindTy ext ty k) +mkHsAppKindTy ty at k + = addCLocAA ty k (HsAppKindTy noExtField ty at k) {- ************************************************************************ @@ -541,7 +543,7 @@ hsTyGetAppHead_maybe = go where go (L _ (HsTyVar _ _ ln)) = Just ln go (L _ (HsAppTy _ l _)) = go l - go (L _ (HsAppKindTy _ t _)) = go t + go (L _ (HsAppKindTy _ t _ _)) = go t go (L _ (HsOpTy _ _ _ ln _)) = Just ln go (L _ (HsParTy _ t)) = go t go (L _ (HsKindSig _ t _)) = go t @@ -553,12 +555,12 @@ hsTyGetAppHead_maybe = go lhsTypeArgSrcSpan :: LHsTypeArg (GhcPass pass) -> SrcSpan lhsTypeArgSrcSpan arg = case arg of HsValArg tm -> getLocA tm - HsTypeArg at ty -> at `combineSrcSpans` getLocA ty + HsTypeArg at ty -> getTokenSrcSpan (getLoc at) `combineSrcSpans` getLocA ty HsArgPar sp -> sp -------------------------------- -numVisibleArgs :: [HsArg tm ty] -> Arity +numVisibleArgs :: [HsArg p tm ty] -> Arity numVisibleArgs = count is_vis where is_vis (HsValArg _) = True is_vis _ = False @@ -576,7 +578,7 @@ numVisibleArgs = count is_vis -- pprHsArgsApp (++) Infix [HsValArg Char, HsValArg Double, HsVarArg Ordering] = (Char ++ Double) Ordering -- @ pprHsArgsApp :: (OutputableBndr id, Outputable tm, Outputable ty) - => id -> LexicalFixity -> [HsArg tm ty] -> SDoc + => id -> LexicalFixity -> [HsArg p tm ty] -> SDoc pprHsArgsApp thing fixity (argl:argr:args) | Infix <- fixity = let pp_op_app = hsep [ ppr_single_hs_arg argl @@ -591,7 +593,7 @@ pprHsArgsApp thing _fixity args -- | Pretty-print a prefix identifier to a list of 'HsArg's. ppr_hs_args_prefix_app :: (Outputable tm, Outputable ty) - => SDoc -> [HsArg tm ty] -> SDoc + => SDoc -> [HsArg p tm ty] -> SDoc ppr_hs_args_prefix_app acc [] = acc ppr_hs_args_prefix_app acc (arg:args) = case arg of @@ -601,7 +603,7 @@ ppr_hs_args_prefix_app acc (arg:args) = -- | Pretty-print an 'HsArg' in isolation. ppr_single_hs_arg :: (Outputable tm, Outputable ty) - => HsArg tm ty -> SDoc + => HsArg p tm ty -> SDoc ppr_single_hs_arg (HsValArg tm) = ppr tm ppr_single_hs_arg (HsTypeArg _ ty) = char '@' <> ppr ty -- GHC shouldn't be constructing ASTs such that this case is ever reached. @@ -611,9 +613,9 @@ ppr_single_hs_arg (HsArgPar{}) = empty -- | This instance is meant for debug-printing purposes. If you wish to -- pretty-print an application of 'HsArg's, use 'pprHsArgsApp' instead. -instance (Outputable tm, Outputable ty) => Outputable (HsArg tm ty) where +instance (Outputable tm, Outputable ty) => Outputable (HsArg (GhcPass p) tm ty) where ppr (HsValArg tm) = text "HsValArg" <+> ppr tm - ppr (HsTypeArg sp ty) = text "HsTypeArg" <+> ppr sp <+> ppr ty + ppr (HsTypeArg at ty) = text "HsTypeArg" <+> ppr at <+> ppr ty ppr (HsArgPar sp) = text "HsArgPar" <+> ppr sp -------------------------------- @@ -1180,7 +1182,7 @@ ppr_mono_ty (HsStarTy _ isUni) = char (if isUni then '★' else '*') ppr_mono_ty (HsAppTy _ fun_ty arg_ty) = hsep [ppr_mono_lty fun_ty, ppr_mono_lty arg_ty] -ppr_mono_ty (HsAppKindTy _ ty k) +ppr_mono_ty (HsAppKindTy _ ty _ k) = ppr_mono_lty ty <+> char '@' <> ppr_mono_lty k ppr_mono_ty (HsOpTy _ prom ty1 (L _ op) ty2) = sep [ ppr_mono_lty ty1 @@ -1295,7 +1297,7 @@ lhsTypeHasLeadingPromotionQuote ty go (HsWildCardTy{}) = False go (HsStarTy{}) = False go (HsAppTy _ t _) = goL t - go (HsAppKindTy _ t _) = goL t + go (HsAppKindTy _ t _ _) = goL t go (HsParTy{}) = False go (HsDocTy _ t _) = goL t go (XHsType{}) = False ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -628,13 +628,13 @@ nlHsTyConApp prom fixity tycon tys mk_app fun@(L _ (HsOpTy {})) arg = mk_app (noLocA $ HsParTy noAnn fun) arg -- parenthesize things like `(A + B) C` mk_app fun (HsValArg ty) = noLocA (HsAppTy noExtField fun (parenthesizeHsType appPrec ty)) - mk_app fun (HsTypeArg _ ki) = noLocA (HsAppKindTy noSrcSpan fun (parenthesizeHsType appPrec ki)) + mk_app fun (HsTypeArg at ki) = noLocA (HsAppKindTy noExtField fun at (parenthesizeHsType appPrec ki)) mk_app fun (HsArgPar _) = noLocA (HsParTy noAnn fun) nlHsAppKindTy :: LHsType (GhcPass p) -> LHsKind (GhcPass p) -> LHsType (GhcPass p) nlHsAppKindTy f k - = noLocA (HsAppKindTy noSrcSpan f (parenthesizeHsType appPrec k)) + = noLocA (HsAppKindTy noExtField f noHsTok (parenthesizeHsType appPrec k)) {- Tuples. All these functions are *pre-typechecker* because they lack ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -1388,7 +1388,7 @@ repTy (HsAppTy _ f a) = do f1 <- repLTy f a1 <- repLTy a repTapp f1 a1 -repTy (HsAppKindTy _ ty ki) = do +repTy (HsAppKindTy _ ty _ ki) = do ty1 <- repLTy ty ki1 <- repLTy ki repTappKind ty1 ki1 ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -570,7 +570,7 @@ instance (HasLoc a, HiePass p) => HasLoc (FamEqn (GhcPass p) a) where HsOuterExplicit{hso_bndrs = tvs} -> foldl1' combineSrcSpans [loc a, loc tvs, loc b, loc c] -instance (HasLoc tm, HasLoc ty) => HasLoc (HsArg tm ty) where +instance (HasLoc tm, HasLoc ty) => HasLoc (HsArg p tm ty) where loc (HsValArg tm) = loc tm loc (HsTypeArg _ ty) = loc ty loc (HsArgPar sp) = sp @@ -1773,7 +1773,7 @@ instance ToHie (LocatedA (HsType GhcRn)) where [ toHie a , toHie b ] - HsAppKindTy _ ty ki -> + HsAppKindTy _ ty _ ki -> [ toHie ty , toHie ki ] @@ -1831,7 +1831,7 @@ instance ToHie (LocatedA (HsType GhcRn)) where HsStarTy _ _ -> [] XHsType _ -> [] -instance (ToHie tm, ToHie ty) => ToHie (HsArg tm ty) where +instance (ToHie tm, ToHie ty) => ToHie (HsArg p tm ty) where toHie (HsValArg tm) = toHie tm toHie (HsTypeArg _ ty) = toHie ty toHie (HsArgPar sp) = locOnly sp ===================================== compiler/GHC/Parser.y ===================================== @@ -2197,7 +2197,7 @@ ftype :: { forall b. DisambTD b => PV (LocatedA b) } | ftype tyarg { $1 >>= \ $1 -> mkHsAppTyPV $1 $2 } | ftype PREFIX_AT atype { $1 >>= \ $1 -> - mkHsAppKindTyPV $1 (getLoc $2) $3 } + mkHsAppKindTyPV $1 (hsTok $2) $3 } tyarg :: { LHsType GhcPs } : atype { $1 } ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -15,6 +15,7 @@ module GHC.Parser.Annotation ( AddEpAnn(..), EpaLocation(..), epaLocationRealSrcSpan, epaLocationFromSrcAnn, TokenLocation(..), + getTokenSrcSpan, DeltaPos(..), deltaPos, getDeltaLine, EpAnn(..), Anchor(..), AnchorOperation(..), @@ -412,6 +413,11 @@ data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) data TokenLocation = NoTokenLoc | TokenLoc !EpaLocation deriving (Data,Eq) +getTokenSrcSpan :: TokenLocation -> SrcSpan +getTokenSrcSpan NoTokenLoc = noSrcSpan +getTokenSrcSpan (TokenLoc EpaDelta{}) = noSrcSpan +getTokenSrcSpan (TokenLoc (EpaSpan rspan mbufpos)) = RealSrcSpan rspan mbufpos + instance Outputable a => Outputable (GenLocated TokenLocation a) where ppr (L _ x) = ppr x ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -1020,7 +1020,7 @@ checkTyClHdr is_cls ty where (o,c) = mkParensEpAnn (realSrcSpan l) go _ (HsAppTy _ t1 t2) acc ops cps fix = goL t1 (HsValArg t2:acc) ops cps fix - go _ (HsAppKindTy l ty ki) acc ops cps fix = goL ty (HsTypeArg l ki:acc) ops cps fix + go _ (HsAppKindTy _ ty at ki) acc ops cps fix = goL ty (HsTypeArg at ki:acc) ops cps fix go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ops cps fix = return (L (noAnnSrcSpan l) (nameRdrName tup_name) , map HsValArg ts, fix, (reverse ops)++cps) @@ -1957,7 +1957,7 @@ class DisambTD b where -- | Disambiguate @f x@ (function application or prefix data constructor). mkHsAppTyPV :: LocatedA b -> LHsType GhcPs -> PV (LocatedA b) -- | Disambiguate @f \@t@ (visible kind application) - mkHsAppKindTyPV :: LocatedA b -> SrcSpan -> LHsType GhcPs -> PV (LocatedA b) + mkHsAppKindTyPV :: LocatedA b -> LHsToken "@" GhcPs -> LHsType GhcPs -> PV (LocatedA b) -- | Disambiguate @f \# x@ (infix operator) mkHsOpTyPV :: PromotionFlag -> LHsType GhcPs -> LocatedN RdrName -> LHsType GhcPs -> PV (LocatedA b) -- | Disambiguate @{-\# UNPACK \#-} t@ (unpack/nounpack pragma) @@ -1966,7 +1966,7 @@ class DisambTD b where instance DisambTD (HsType GhcPs) where mkHsAppTyHeadPV = return mkHsAppTyPV t1 t2 = return (mkHsAppTy t1 t2) - mkHsAppKindTyPV t l_at ki = return (mkHsAppKindTy l_at t ki) + mkHsAppKindTyPV t at ki = return (mkHsAppKindTy t at ki) mkHsOpTyPV prom t1 op t2 = return (mkLHsOpTy prom t1 op t2) mkUnpackednessPV = addUnpackednessP @@ -2002,8 +2002,8 @@ instance DisambTD DataConBuilder where -- the grammar in Parser.y is written (see infixtype/ftype). panic "mkHsAppTyPV: InfixDataConBuilder" - mkHsAppKindTyPV lhs l_at ki = - addFatalError $ mkPlainErrorMsgEnvelope l_at $ + mkHsAppKindTyPV lhs at ki = + addFatalError $ mkPlainErrorMsgEnvelope (getTokenSrcSpan (getLoc at)) $ (PsErrUnexpectedKindAppInDataCon (unLoc lhs) (unLoc ki)) mkHsOpTyPV prom lhs tc rhs = do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -725,12 +725,12 @@ rnHsTyKi env (HsAppTy _ ty1 ty2) ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; return (HsAppTy noExtField ty1' ty2', fvs1 `plusFV` fvs2) } -rnHsTyKi env (HsAppKindTy l ty k) +rnHsTyKi env (HsAppKindTy _ ty at k) = do { kind_app <- xoptM LangExt.TypeApplications ; unless kind_app (addErr (typeAppErr "kind" k)) ; (ty', fvs1) <- rnLHsTyKi env ty ; (k', fvs2) <- rnLHsTyKi (env {rtke_level = KindLevel }) k - ; return (HsAppKindTy l ty' k', fvs1 `plusFV` fvs2) } + ; return (HsAppKindTy noExtField ty' at k', fvs1 `plusFV` fvs2) } rnHsTyKi env t@(HsIParamTy x n ty) = do { notInKinds env t @@ -1961,7 +1961,7 @@ extract_lty (L _ ty) acc flds HsAppTy _ ty1 ty2 -> extract_lty ty1 $ extract_lty ty2 acc - HsAppKindTy _ ty k -> extract_lty ty $ + HsAppKindTy _ ty _ k -> extract_lty ty $ extract_lty k acc HsListTy _ ty -> extract_lty ty acc HsTupleTy _ _ tys -> extract_ltys tys acc ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1517,11 +1517,11 @@ splitHsAppTys hs_ty is_app _ = False go :: LHsType GhcRn - -> [HsArg (LHsType GhcRn) (LHsKind GhcRn)] + -> [HsArg GhcRn (LHsType GhcRn) (LHsKind GhcRn)] -> (LHsType GhcRn, - [HsArg (LHsType GhcRn) (LHsKind GhcRn)]) -- AZ temp + [HsArg GhcRn (LHsType GhcRn) (LHsKind GhcRn)]) -- AZ temp go (L _ (HsAppTy _ f a)) as = go f (HsValArg a : as) - go (L _ (HsAppKindTy l ty k)) as = go ty (HsTypeArg l k : as) + go (L _ (HsAppKindTy _ ty at k)) as = go ty (HsTypeArg at k : as) go (L sp (HsParTy _ f)) as = go f (HsArgPar (locA sp) : as) go (L _ (HsOpTy _ prom l op@(L sp _) r)) as = ( L (na2la sp) (HsTyVar noAnn prom op) @@ -1699,7 +1699,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args substed_fun_ki = substTy subst fun_ki hs_ty = appTypeToArg orig_hs_ty (take (n-1) orig_hs_args) - n_initial_val_args :: [HsArg tm ty] -> Arity + n_initial_val_args :: [HsArg p tm ty] -> Arity -- Count how many leading HsValArgs we have n_initial_val_args (HsValArg {} : args) = 1 + n_initial_val_args args n_initial_val_args (HsArgPar {} : args) = n_initial_val_args args @@ -1891,10 +1891,10 @@ unsaturated arguments: see #11246. Hence doing this in tcInferApps. appTypeToArg :: LHsType GhcRn -> [LHsTypeArg GhcRn] -> LHsType GhcRn appTypeToArg f [] = f -appTypeToArg f (HsValArg arg : args) = appTypeToArg (mkHsAppTy f arg) args -appTypeToArg f (HsArgPar _ : args) = appTypeToArg f args -appTypeToArg f (HsTypeArg l arg : args) - = appTypeToArg (mkHsAppKindTy l f arg) args +appTypeToArg f (HsValArg arg : args) = appTypeToArg (mkHsAppTy f arg) args +appTypeToArg f (HsArgPar _ : args) = appTypeToArg f args +appTypeToArg f (HsTypeArg at arg : args) + = appTypeToArg (mkHsAppKindTy f at arg) args {- ********************************************************************* ===================================== compiler/GHC/Tc/Gen/Sig.hs ===================================== @@ -299,7 +299,7 @@ no_anon_wc_ty lty = go lty go (L _ ty) = case ty of HsWildCardTy _ -> False HsAppTy _ ty1 ty2 -> go ty1 && go ty2 - HsAppKindTy _ ty ki -> go ty && go ki + HsAppKindTy _ ty _ ki -> go ty && go ki HsFunTy _ w ty1 ty2 -> go ty1 && go ty2 && go (arrowToHsType w) HsListTy _ ty -> go ty HsTupleTy _ _ tys -> gos tys ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3045,7 +3045,7 @@ tcTyFamInstEqn fam_tc mb_clsinfo (map (const Nominal) qtvs) (locA loc)) } -checkTyFamInstEqn :: TcTyCon -> Name -> [HsArg tm ty] -> TcM () +checkTyFamInstEqn :: TcTyCon -> Name -> [HsArg p tm ty] -> TcM () checkTyFamInstEqn tc_fam_tc eqn_tc_name hs_pats = do { -- Ensure that each equation's type constructor is for the right -- type family. E.g. barf on ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1795,8 +1795,9 @@ mk_apps head_ty type_args = do case arg of HsValArg ty -> do p_ty <- add_parens ty mk_apps (HsAppTy noExtField phead_ty p_ty) args - HsTypeArg l ki -> do p_ki <- add_parens ki - mk_apps (HsAppKindTy l phead_ty p_ki) args + HsTypeArg at ki -> + do p_ki <- add_parens ki + mk_apps (HsAppKindTy noExtField phead_ty at p_ki) args HsArgPar _ -> mk_apps (HsParTy noAnn phead_ty) args go type_args @@ -1841,7 +1842,7 @@ split_ty_app ty = go ty [] where go (AppT f a) as' = do { a' <- cvtType a; go f (HsValArg a':as') } go (AppKindT ty ki) as' = do { ki' <- cvtKind ki - ; go ty (HsTypeArg noSrcSpan ki':as') } + ; go ty (HsTypeArg noHsTok ki' : as') } go (ParensT t) as' = do { loc <- getL; go t (HsArgPar loc: as') } go f as = return (f,as) ===================================== compiler/Language/Haskell/Syntax/Type.hs ===================================== @@ -756,6 +756,7 @@ data HsType pass | HsAppKindTy (XAppKindTy pass) -- type level type app (LHsType pass) + !(LHsToken "@" pass) (LHsKind pass) | HsFunTy (XFunTy pass) @@ -1181,14 +1182,13 @@ if they correspond to a visible 'forall'. -} -- | Arguments in an expression/type after splitting -data HsArg tm ty +data HsArg p tm ty = HsValArg tm -- Argument is an ordinary expression (f arg) - | HsTypeArg SrcSpan ty -- Argument is a visible type application (f @ty) - -- SrcSpan is location of the `@` + | HsTypeArg !(LHsToken "@" p) ty -- Argument is a visible type application (f @ty) | HsArgPar SrcSpan -- See Note [HsArgPar] -- type level equivalent -type LHsTypeArg p = HsArg (LHsType p) (LHsKind p) +type LHsTypeArg p = HsArg p (LHsType p) (LHsKind p) {- Note [HsArgPar] ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -658,7 +658,10 @@ (HsOuterImplicit (NoExtField)) [(HsTypeArg - { DumpParsedAst.hs:18:6 } + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:18:6 })) + (HsTok)) (L (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:18:7-11 }) (HsTyVar @@ -718,7 +721,7 @@ (L (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:18:19-26 }) (HsAppKindTy - { DumpParsedAst.hs:18:21 } + (NoExtField) (L (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:18:19 }) (HsTyVar @@ -734,6 +737,10 @@ (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:18:19 }) (Unqual {OccName: T})))) + (L + (TokenLoc + (EpaSpan { DumpParsedAst.hs:18:21 })) + (HsTok)) (L (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAst.hs:18:22-26 }) (HsTyVar ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -868,7 +868,10 @@ [{Name: a} ,{Name: f}]) [(HsTypeArg - { DumpRenamedAst.hs:25:6 } + (L + (TokenLoc + (EpaSpan { DumpRenamedAst.hs:25:6 })) + (HsTok)) (L (SrcSpanAnn (EpAnnNotUsed) { DumpRenamedAst.hs:25:7-11 }) (HsTyVar @@ -907,7 +910,7 @@ (L (SrcSpanAnn (EpAnnNotUsed) { DumpRenamedAst.hs:25:19-26 }) (HsAppKindTy - { DumpRenamedAst.hs:25:21 } + (NoExtField) (L (SrcSpanAnn (EpAnnNotUsed) { DumpRenamedAst.hs:25:19 }) (HsTyVar @@ -916,6 +919,10 @@ (L (SrcSpanAnn (EpAnnNotUsed) { DumpRenamedAst.hs:25:19 }) {Name: DumpRenamedAst.T}))) + (L + (TokenLoc + (EpaSpan { DumpRenamedAst.hs:25:21 })) + (HsTok)) (L (SrcSpanAnn (EpAnnNotUsed) { DumpRenamedAst.hs:25:22-26 }) (HsTyVar ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -1992,12 +1992,12 @@ exactHsFamInstLHS an thing bndrs typats fixity mb_ctxt = do -- --------------------------------------------------------------------- instance (ExactPrint tm, ExactPrint ty, Outputable tm, Outputable ty) - => ExactPrint (HsArg tm ty) where + => ExactPrint (HsArg GhcPs tm ty) where getAnnotationEntry = const NoEntryVal setAnnotationAnchor a _ _ = a exact a@(HsValArg tm) = markAnnotated tm >> return a - exact a@(HsTypeArg ss ty) = printStringAtSs ss "@" >> markAnnotated ty >> return a + exact a@(HsTypeArg at ty) = markToken at >> markAnnotated ty >> return a exact x@(HsArgPar _sp) = withPpr x -- Does not appear in original source -- --------------------------------------------------------------------- @@ -3771,7 +3771,7 @@ instance ExactPrint (HsType GhcPs) where getAnnotationEntry (HsQualTy _ _ _) = NoEntryVal getAnnotationEntry (HsTyVar an _ _) = fromAnn an getAnnotationEntry (HsAppTy _ _ _) = NoEntryVal - getAnnotationEntry (HsAppKindTy _ _ _) = NoEntryVal + getAnnotationEntry (HsAppKindTy _ _ _ _) = NoEntryVal getAnnotationEntry (HsFunTy an _ _ _) = fromAnn an getAnnotationEntry (HsListTy an _) = fromAnn an getAnnotationEntry (HsTupleTy an _ _) = fromAnn an @@ -3795,7 +3795,7 @@ instance ExactPrint (HsType GhcPs) where setAnnotationAnchor a@(HsQualTy _ _ _) _ _s = a setAnnotationAnchor (HsTyVar an a b) anc cs = (HsTyVar (setAnchorEpa an anc cs) a b) setAnnotationAnchor a@(HsAppTy _ _ _) _ _s = a - setAnnotationAnchor a@(HsAppKindTy _ _ _) _ _s = a + setAnnotationAnchor a@(HsAppKindTy _ _ _ _) _ _s = a setAnnotationAnchor (HsFunTy an a b c) anc cs = (HsFunTy (setAnchorEpa an anc cs) a b c) setAnnotationAnchor (HsListTy an a) anc cs = (HsListTy (setAnchorEpa an anc cs) a) setAnnotationAnchor (HsTupleTy an a b) anc cs = (HsTupleTy (setAnchorEpa an anc cs) a b) @@ -3836,11 +3836,11 @@ instance ExactPrint (HsType GhcPs) where t1' <- markAnnotated t1 t2' <- markAnnotated t2 return (HsAppTy an t1' t2') - exact (HsAppKindTy ss ty ki) = do + exact (HsAppKindTy ss ty at ki) = do ty' <- markAnnotated ty - printStringAtSs ss "@" + at' <- markToken at ki' <- markAnnotated ki - return (HsAppKindTy ss ty' ki') + return (HsAppKindTy ss ty' at' ki') exact (HsFunTy an mult ty1 ty2) = do ty1' <- markAnnotated ty1 mult' <- markArrow mult ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit edc72530978d8a9ec92f51d288484986ec0051e3 +Subproject commit f8c154feb01ce8b2e22e5c4d5cd33bb79234d9e5 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c9bc4fdfed32033a2cd2717099cc59ffb193af7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c9bc4fdfed32033a2cd2717099cc59ffb193af7 You're receiving 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 Dec 10 16:40:10 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Sat, 10 Dec 2022 11:40:10 -0500 Subject: [Git][ghc/ghc][wip/clarify-test-coercion] 1099 commits: Document that DuplicateRecordFields doesn't tolerates ambiguous fields Message-ID: <6394b66a4c938_224fca6061c98242c@gitlab.mail> John Ericson pushed to branch wip/clarify-test-coercion at Glasgow Haskell Compiler / GHC Commits: 5440f63e by Hécate Moonlight at 2022-04-12T11:11:06-04:00 Document that DuplicateRecordFields doesn't tolerates ambiguous fields Fix #19891 - - - - - 0090ad7b by Sebastian Graf at 2022-04-12T11:11:42-04:00 Eta reduction based on evaluation context (#21261) I completely rewrote our Notes surrounding eta-reduction. The new entry point is `Note [Eta reduction makes sense]`. Then I went on to extend the Simplifier to maintain an evaluation context in the form of a `SubDemand` inside a `SimplCont`. That `SubDemand` is useful for doing eta reduction according to `Note [Eta reduction based on evaluation context]`, which describes how Demand analysis, Simplifier and `tryEtaReduce` interact to facilitate eta reduction in more scenarios. Thus we fix #21261. ghc/alloc perf marginally improves (-0.0%). A medium-sized win is when compiling T3064 (-3%). It seems that haddock improves by 0.6% to 1.0%, too. Metric Decrease: T3064 - - - - - 4d2ee313 by Sebastian Graf at 2022-04-12T17:54:57+02:00 Specialising through specialised method calls (#19644) In #19644, we discovered that the ClassOp/DFun rules from Note [ClassOp/DFun selection] inhibit transitive specialisation in a scenario like ``` class C a where m :: Show b => a -> b -> ...; n :: ... instance C Int where m = ... -- $cm :: Show b => Int -> b -> ... f :: forall a b. (C a, Show b) => ... f $dC $dShow = ... m @a $dC @b $dShow ... main = ... f @Int @Bool ... ``` After we specialise `f` for `Int`, we'll see `m @a $dC @b $dShow` in the body of `$sf`. But before this patch, Specialise doesn't apply the ClassOp/DFun rule to rewrite to a call of the instance method for `C Int`, e.g., `$cm @Bool $dShow`. As a result, Specialise couldn't further specialise `$cm` for `Bool`. There's a better example in `Note [Specialisation modulo dictionary selectors]`. This patch enables proper Specialisation, as follows: 1. In the App case of `specExpr`, try to apply the CalssOp/DictSel rule on the head of the application 2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and `$dShow` in `bindAuxiliaryDict` NB: Without (2), (1) would be pointless, because `lookupRule` wouldn't be able to look into the RHS of `$dC` to see the DFun. (2) triggered #21332, because the Specialiser floats around dictionaries without accounting for them in the `SpecEnv`'s `InScopeSet`, triggering a panic when rewriting dictionary unfoldings. Fixes #19644 and #21332. - - - - - b06f4f47 by Sebastian Graf at 2022-04-12T17:54:58+02:00 Specialise: Check `typeDeterminesValue` before specialising on an interesting dictionary I extracted the checks from `Note [Type determines value]` into its own function, so that we share the logic properly. Then I made sure that we actually call `typeDeterminesValue` everywhere we check for `interestingDict`. - - - - - a42dbc55 by Matthew Pickering at 2022-04-13T06:24:52-04:00 Refine warning about defining rules in SAFE modules This change makes it clear that it's the definition rather than any usage which is a problem, and that rules defined in other modules will still be used to do rewrites. Fixes #20923 - - - - - df893f66 by Andreas Klebinger at 2022-04-14T08:18:37-04:00 StgLint: Lint constructor applications and strict workers for arity. This will mean T9208 when run with lint will return a lint error instead of resulting in a panic. Fixes #21117 - - - - - 426ec446 by sheaf at 2022-04-14T08:19:16-04:00 Hadrian: use a set to keep track of ways The order in which ways are provided doesn't matter, so we use a data structure with the appropriate semantics to represent ways. Fixes #21378 - - - - - 7c639b9a by Dylan Yudaken at 2022-04-15T13:55:59-04:00 Only enable PROF_SPIN in DEBUG - - - - - 96b9e5ea by Ben Gamari at 2022-04-15T13:56:34-04:00 testsuite: Add test for #21390 - - - - - d8392f6a by Ben Gamari at 2022-04-15T13:56:34-04:00 rts: Ensure that the interpreter doesn't disregard tags Previously the interpreter's handling of `RET_BCO` stack frames would throw away the tag of the returned closure. This resulted in #21390. - - - - - 83c67f76 by Alan Zimmerman at 2022-04-20T11:49:28-04:00 Add -dkeep-comments flag to keep comments in the parser This provides a way to set the Opt_KeepRawTokenStream from the command line, allowing exact print annotation users to see exactly what is produced for a given parsed file, when used in conjunction with -ddump-parsed-ast Discussed in #19706, but this commit does not close the issue. - - - - - a5ea65c9 by Krzysztof Gogolewski at 2022-04-20T11:50:04-04:00 Remove LevityInfo Every Id was storing a boolean whether it could be levity-polymorphic. This information is no longer needed since representation-checking has been moved to the typechecker. - - - - - 49bd7584 by Andreas Klebinger at 2022-04-20T11:50:39-04:00 Fix a shadowing issue in StgUnarise. For I assume performance reasons we don't record no-op replacements during unarise. This lead to problems with code like this: f = \(Eta_B0 :: VoidType) x1 x2 -> ... let foo = \(Eta_B0 :: LiftedType) -> g x y Eta_B0 in ... Here we would record the outer Eta_B0 as void rep, but would not shadow Eta_B0 inside `foo` because this arg is single-rep and so doesn't need to replaced. But this means when looking at occurence sites we would check the env and assume it's void rep based on the entry we made for the (no longer in scope) outer `Eta_B0`. Fixes #21396 and the ticket has a few more details. - - - - - 0c02c919 by Simon Peyton Jones at 2022-04-20T11:51:15-04:00 Fix substitution in bindAuxiliaryDict In GHC.Core.Opt.Specialise.bindAuxiliaryDict we were unnecessarily calling `extendInScope` to bring into scope variables that were /already/ in scope. Worse, GHC.Core.Subst.extendInScope strangely deleted the newly-in-scope variables from the substitution -- and that was fatal in #21391. I removed the redundant calls to extendInScope. More ambitiously, I changed GHC.Core.Subst.extendInScope (and cousins) to stop deleting variables from the substitution. I even changed the names of the function to extendSubstInScope (and cousins) and audited all the calls to check that deleting from the substitution was wrong. In fact there are very few such calls, and they are all about introducing a fresh non-in-scope variable. These are "OutIds"; it is utterly wrong to mess with the "InId" substitution. I have not added a Note, because I'm deleting wrong code, and it'd be distracting to document a bug. - - - - - 0481a6af by Cheng Shao at 2022-04-21T11:06:06+00:00 [ci skip] Drop outdated TODO in RtsAPI.c - - - - - 1e062a8a by Ben Gamari at 2022-04-22T02:12:59-04:00 rts: Introduce ip_STACK_FRAME While debugging it is very useful to be able to determine whether a given info table is a stack frame or not. We have spare bits in the closure flags array anyways, use one for this information. - - - - - 08a6a2ee by Ben Gamari at 2022-04-22T02:12:59-04:00 rts: Mark closureFlags array as const - - - - - 8f9b8282 by Krzysztof Gogolewski at 2022-04-22T02:13:35-04:00 Check for zero-bit types in sizeExpr Fixes #20940 Metric Decrease: T18698a - - - - - fcf22883 by Andreas Klebinger at 2022-04-22T02:14:10-04:00 Include the way string in the file name for dump files. This can be disabled by `-fno-dump-with-ways` if not desired. Finally we will be able to look at both profiled and non-profiled dumps when compiling with dump flags and we compile in both ways. - - - - - 252394ce by Bodigrim at 2022-04-22T02:14:48-04:00 Improve error messages from GHC.IO.Encoding.Failure - - - - - 250f57c1 by Bodigrim at 2022-04-22T02:14:48-04:00 Update test baselines to match new error messages from GHC.IO.Encoding.Failure - - - - - 5ac9b321 by Ben Gamari at 2022-04-22T02:15:25-04:00 get-win32-tarballs: Drop i686 architecture As of #18487 we no longer support 32-bit Windows. Fixes #21372. - - - - - dd5fecb0 by Ben Gamari at 2022-04-22T02:16:00-04:00 hadrian: Don't rely on xxx not being present in installation path Previously Hadrian's installation makefile would assume that the string `xxx` did not appear in the installation path. This would of course break for some users. Fixes #21402. - - - - - 09e98859 by Ben Gamari at 2022-04-22T02:16:35-04:00 testsuite: Ensure that GHC doesn't pick up environment files Here we set GHC_ENVIRONMENT="-" to ensure that GHC invocations of tests don't pick up a user's local package environment. Fixes #21365. Metric Decrease: T10421 T12234 T12425 T13035 T16875 T9198 - - - - - 76bb8cb3 by Ben Gamari at 2022-04-22T02:17:11-04:00 hadrian: Enable -dlint in devel2 flavour Previously only -dcore-lint was enabled. - - - - - f435d55f by Krzysztof Gogolewski at 2022-04-22T08:00:18-04:00 Fixes to rubbish literals * In CoreToStg, the application 'RUBBISH[rep] x' was simplified to 'RUBBISH[rep]'. But it is possible that the result of the function is represented differently than the function. * In Unarise, 'LitRubbish (primRepToType prep)' is incorrect: LitRubbish takes a RuntimeRep such as IntRep, while primRepToType returns a type such as Any @(TYPE IntRep). Use primRepToRuntimeRep instead. This code is never run in the testsuite. * In StgToByteCode, all rubbish literals were assumed to be boxed. This code predates representation-polymorphic RubbishLit and I think it was not updated. I don't have a testcase for any of those issues, but the code looks wrong. - - - - - 93c16b94 by sheaf at 2022-04-22T08:00:57-04:00 Relax "suppressing errors" assert in reportWanteds The assertion in reportWanteds that we aren't suppressing all the Wanted constraints was too strong: it might be the case that we are inside an implication, and have already reported an unsolved Wanted from outside the implication. It is possible that all Wanteds inside the implication have been rewritten by the outer Wanted, so we shouldn't throw an assertion failure in that case. Fixes #21405 - - - - - 78ec692d by Andreas Klebinger at 2022-04-22T08:01:33-04:00 Mention new MutableByteArray# wrapper in base changelog. - - - - - 56d7cb53 by Eric Lindblad at 2022-04-22T14:13:32-04:00 unlist announce - - - - - 1e4dcf23 by sheaf at 2022-04-22T14:14:12-04:00 decideMonoTyVars: account for CoVars in candidates The "candidates" passed to decideMonoTyVars can contain coercion holes. This is because we might well decide to quantify over some unsolved equality constraints, as long as they are not definitely insoluble. In that situation, decideMonoTyVars was passing a set of type variables that was not closed over kinds to closeWrtFunDeps, which was tripping up an assertion failure. Fixes #21404 - - - - - 2c541f99 by Simon Peyton Jones at 2022-04-22T14:14:47-04:00 Improve floated dicts in Specialise Second fix to #21391. It turned out that we missed calling bringFloatedDictsIntoScope when specialising imports, which led to the same bug as before. I refactored to move that call to a single place, in specCalls, so we can't forget it. This meant making `FloatedDictBinds` into its own type, pairing the dictionary bindings themselves with the set of their binders. Nicer this way. - - - - - 0950e2c4 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Ensure that --extra-lib-dirs are used Previously we only took `extraLibDirs` and friends from the package description, ignoring any contribution from the `LocalBuildInfo`. Fix this. Fixes #20566. - - - - - 53cc93ae by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Drop redundant include directories The package-specific include directories in Settings.Builders.Common.cIncludeDirs are now redundant since they now come from Cabal. Closes #20566. - - - - - b2721819 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Clean up handling of libffi dependencies - - - - - 18e5103f by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: More robust library way detection Previously `test.mk` would try to determine whether the dynamic, profiling, and vanilla library ways are available by searching for `PrimOpWrappers.{,dyn_,p_}hi` in directory reported by `ghc-pkg field ghc-prim library-dirs`. However, this is extremely fragile as there is no guarantee that there is only one library directory. To handle the case of multiple `library-dirs` correct we would have to carry out the delicate task of tokenising the directory list (in shell, no less). Since this isn't a task that I am eager to solve, I have rather moved the detection logic into the testsuite driver and instead perform a test compilation in each of the ways. This should be more robust than the previous approach. I stumbled upon this while fixing #20579. - - - - - 6c7a4913 by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: Cabalify ghc-config To ensure that the build benefits from Hadrian's usual logic for building packages, avoiding #21409. Closes #21409. - - - - - 9af091f7 by Ben Gamari at 2022-04-25T10:18:53-04:00 rts: Factor out built-in GC roots - - - - - e7c4719d by Ben Gamari at 2022-04-25T10:18:54-04:00 Ensure that wired-in exception closures aren't GC'd As described in Note [Wired-in exceptions are not CAFfy], a small set of built-in exception closures get special treatment in the code generator, being declared as non-CAFfy despite potentially containing CAF references. The original intent of this treatment for the RTS to then add StablePtrs for each of the closures, ensuring that they are not GC'd. However, this logic was not applied consistently and eventually removed entirely in 951c1fb0. This lead to #21141. Here we fix this bug by reintroducing the StablePtrs and document the status quo. Closes #21141. - - - - - 9587726f by Ben Gamari at 2022-04-25T10:18:54-04:00 testsuite: Add testcase for #21141 - - - - - cb71226f by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop dead code in GHC.Linker.Static.linkBinary' Previously we supported building statically-linked executables using libtool. However, this was dropped in 91262e75dd1d80f8f28a3922934ec7e59290e28c in favor of using ar/ranlib directly. Consequently we can drop this logic. Fixes #18826. - - - - - 9420d26b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop libtool path from settings file GHC no longers uses libtool for linking and therefore this is no longer necessary. - - - - - 41cf758b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop remaining vestiges of libtool Drop libtool logic from gen-dll, allowing us to drop the remaining logic from the `configure` script. Strangely, this appears to reliably reduce compiler allocations of T16875 on Windows. Closes #18826. Metric Decrease: T16875 - - - - - e09afbf2 by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - e76705cf by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Improve documentation of closure types Also drops the unused TREC_COMMITTED transaction state. - - - - - f2c08124 by Bodigrim at 2022-04-25T10:20:44-04:00 Document behaviour of RULES with KnownNat - - - - - 360dc2bc by Li-yao Xia at 2022-04-25T19:13:06+00:00 Fix rendering of liftA haddock - - - - - 16df6058 by Ben Gamari at 2022-04-27T10:02:25-04:00 testsuite: Report minimum and maximum stat changes As suggested in #20733. - - - - - e39cab62 by Fabian Thorand at 2022-04-27T10:03:03-04:00 Defer freeing of mega block groups Solves the quadratic worst case performance of freeing megablocks that was described in issue #19897. During GC runs, we now keep a secondary free list for megablocks that is neither sorted, nor coalesced. That way, free becomes an O(1) operation at the expense of not being able to reuse memory for larger allocations. At the end of a GC run, the secondary free list is sorted and then merged into the actual free list in a single pass. That way, our worst case performance is O(n log(n)) rather than O(n^2). We postulate that temporarily losing coalescense during a single GC run won't have any adverse effects in practice because: - We would need to release enough memory during the GC, and then after that (but within the same GC run) allocate a megablock group of more than one megablock. This seems unlikely, as large objects are not copied during GC, and so we shouldn't need such large allocations during a GC run. - Allocations of megablock groups of more than one megablock are rare. They only happen when a single heap object is large enough to require that amount of space. Any allocation areas that are supposed to hold more than one heap object cannot use megablock groups, because only the first megablock of a megablock group has valid `bdescr`s. Thus, heap object can only start in the first megablock of a group, not in later ones. - - - - - 5de6be0c by Fabian Thorand at 2022-04-27T10:03:03-04:00 Add note about inefficiency in returnMemoryToOS - - - - - 8bef471a by sheaf at 2022-04-27T10:03:43-04:00 Ensure that Any is Boxed in FFI imports/exports We should only accept the type `Any` in foreign import/export declarations when it has type `Type` or `UnliftedType`. This patch adds a kind check, and a special error message triggered by occurrences of `Any` in foreign import/export declarations at other kinds. Fixes #21305 - - - - - ba3d4e1c by Ben Gamari at 2022-04-27T10:04:19-04:00 Basic response file support Here we introduce support into our command-line parsing infrastructure and driver for handling gnu-style response file arguments, typically used to work around platform command-line length limitations. Fixes #16476. - - - - - 3b6061be by Ben Gamari at 2022-04-27T10:04:19-04:00 testsuite: Add test for #16476 - - - - - 75bf1337 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix cabal-reinstall job It's quite nice we can do this by mostly deleting code Fixes #21373 - - - - - 2c00d904 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add test to check that release jobs have profiled libs - - - - - 50d78d3b by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Explicitly handle failures in test_hadrian We also disable the stage1 testing which is broken. Related to #21072 - - - - - 2dcdf091 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix shell command - - - - - 55c84123 by Matthew Pickering at 2022-04-27T10:04:55-04:00 bootstrap: Add bootstrapping files for ghc-9_2_2 Fixes #21373 - - - - - c7ee0be6 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add linting job which checks authors are not GHC CI - - - - - 23aad124 by Adam Sandberg Ericsson at 2022-04-27T10:05:31-04:00 rts: state explicitly what evacuate and scavange mean in the copying gc - - - - - 318e0005 by Ben Gamari at 2022-04-27T10:06:07-04:00 rts/eventlog: Don't attempt to flush if there is no writer If the user has not configured a writer then there is nothing to flush. - - - - - ee11d043 by Ben Gamari at 2022-04-27T10:06:07-04:00 Enable eventlog support in all ways by default Here we deprecate the eventlogging RTS ways and instead enable eventlog support in the remaining ways. This simplifies packaging and reduces GHC compilation times (as we can eliminate two whole compilations of the RTS) while simplifying the end-user story. The trade-off is a small increase in binary sizes in the case that the user does not want eventlogging support, but we think that this is a fine trade-off. This also revealed a latent RTS bug: some files which included `Cmm.h` also assumed that it defined various macros which were in fact defined by `Config.h`, which `Cmm.h` did not include. Fixing this in turn revealed that `StgMiscClosures.cmm` failed to import various spinlock statistics counters, as evidenced by the failed unregisterised build. Closes #18948. - - - - - a2e5ab70 by Andreas Klebinger at 2022-04-27T10:06:43-04:00 Change `-dsuppress-ticks` to only suppress non-code ticks. This means cost centres and coverage ticks will still be present in output. Makes using -dsuppress-all more convenient when looking at profiled builds. - - - - - ec9d7e04 by Ben Gamari at 2022-04-27T10:07:21-04:00 Bump text submodule. This should fix #21352 - - - - - c3105be4 by Bodigrim at 2022-04-27T10:08:01-04:00 Documentation for setLocaleEncoding - - - - - 7f618fd3 by sheaf at 2022-04-27T10:08:40-04:00 Update docs for change to type-checking plugins There was no mention of the changes to type-checking plugins in the 9.4.1 notes, and the extending_ghc documentation contained a reference to an outdated type. - - - - - 4419dd3a by Adam Sandberg Ericsson at 2022-04-27T10:09:18-04:00 rts: add some more documentation to StgWeak closure type - - - - - 5a7f0dee by Matthew Pickering at 2022-04-27T10:09:54-04:00 Give Cmm files fake ModuleNames which include full filepath This fixes the initialisation functions when using -prof or -finfo-table-map. Fixes #21370 - - - - - 81cf52bb by sheaf at 2022-04-27T10:10:33-04:00 Mark GHC.Prim.PtrEq as Unsafe This module exports unsafe pointer equality operations, so we accordingly mark it as Unsafe. Fixes #21433 - - - - - f6a8185d by Ben Gamari at 2022-04-28T09:10:31+00:00 testsuite: Add performance test for #14766 This distills the essence of the Sigs.hs program found in the ticket. - - - - - c7a3dc29 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Add Monoid instance to Way - - - - - 654bafea by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Enrich flavours to build profiled/debugged/threaded ghcs per stage - - - - - 4ad559c8 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: add debug_ghc and debug_stage1_ghc flavour transformers - - - - - f9728fdb by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Don't pass -rtsopts when building libraries - - - - - 769279e6 by Matthew Pickering at 2022-04-28T18:54:44-04:00 testsuite: Fix calculation about whether to pass -dynamic to compiler - - - - - da8ae7f2 by Ben Gamari at 2022-04-28T18:55:20-04:00 hadrian: Clean up flavour transformer definitions Previously the `ipe` and `omit_pragmas` transformers were hackily defined using the textual key-value syntax. Fix this. - - - - - 61305184 by Ben Gamari at 2022-04-28T18:55:56-04:00 Bump process submodule - - - - - a8c99391 by sheaf at 2022-04-28T18:56:37-04:00 Fix unification of ConcreteTvs, removing IsRefl# This patch fixes the unification of concrete type variables. The subtlety was that unifying concrete metavariables is more subtle than other metavariables, as decomposition is possible. See the Note [Unifying concrete metavariables], which explains how we unify a concrete type variable with a type 'ty' by concretising 'ty', using the function 'GHC.Tc.Utils.Concrete.concretise'. This can be used to perform an eager syntactic check for concreteness, allowing us to remove the IsRefl# special predicate. Instead of emitting two constraints `rr ~# concrete_tv` and `IsRefl# rr concrete_tv`, we instead concretise 'rr'. If this succeeds we can fill 'concrete_tv', and otherwise we directly emit an error message to the typechecker environment instead of deferring. We still need the error message to be passed on (instead of directly thrown), as we might benefit from further unification in which case we will need to zonk the stored types. To achieve this, we change the 'wc_holes' field of 'WantedConstraints' to 'wc_errors', which stores general delayed errors. For the moement, a delayed error is either a hole, or a syntactic equality error. hasFixedRuntimeRep_MustBeRefl is now hasFixedRuntimeRep_syntactic, and hasFixedRuntimeRep has been refactored to directly return the most useful coercion for PHASE 2 of FixedRuntimeRep. This patch also adds a field ir_frr to the InferResult datatype, holding a value of type Maybe FRROrigin. When this value is not Nothing, this means that we must fill the ir_ref field with a type which has a fixed RuntimeRep. When it comes time to fill such an ExpType, we ensure that the type has a fixed RuntimeRep by performing a representation-polymorphism check with the given FRROrigin This is similar to what we already do to ensure we fill an Infer ExpType with a type of the correct TcLevel. This allows us to properly perform representation-polymorphism checks on 'Infer' 'ExpTypes'. The fillInferResult function had to be moved to GHC.Tc.Utils.Unify to avoid a cyclic import now that it calls hasFixedRuntimeRep. This patch also changes the code in matchExpectedFunTys to make use of the coercions, which is now possible thanks to the previous change. This implements PHASE 2 of FixedRuntimeRep in some situations. For example, the test cases T13105 and T17536b are now both accepted. Fixes #21239 and #21325 ------------------------- Metric Decrease: T18223 T5631 ------------------------- - - - - - 43bd897d by Simon Peyton Jones at 2022-04-28T18:57:13-04:00 Add INLINE pragmas for Enum helper methods As #21343 showed, we need to be super-certain that the "helper methods" for Enum instances are actually inlined or specialised. I also tripped over this when I discovered that numericEnumFromTo and friends had no pragmas at all, so their performance was very fragile. If they weren't inlined, all bets were off. So I've added INLINE pragmas for them too. See new Note [Inline Enum method helpers] in GHC.Enum. I also expanded Note [Checking for INLINE loop breakers] in GHC.Core.Lint to explain why an INLINE function might temporarily be a loop breaker -- this was the initial bug report in #21343. Strangely we get a 16% runtime allocation decrease in perf/should_run/T15185, but only on i386. Since it moves in the right direction I'm disinclined to investigate, so I'll accept it. Metric Decrease: T15185 - - - - - ca1434e3 by Ben Gamari at 2022-04-28T18:57:49-04:00 configure: Bump GHC version to 9.5 Bumps haddock submodule. - - - - - 292e3971 by Teo Camarasu at 2022-04-28T18:58:28-04:00 add since annotation for GHC.Stack.CCS.whereFrom - - - - - 905206d6 by Tamar Christina at 2022-04-28T22:19:34-04:00 winio: add support to iserv. - - - - - d182897e by Tamar Christina at 2022-04-28T22:19:34-04:00 Remove unused line - - - - - 22cf4698 by Matthew Pickering at 2022-04-28T22:20:10-04:00 Revert "rts: Refactor handling of dead threads' stacks" This reverts commit e09afbf2a998beea7783e3de5dce5dd3c6ff23db. - - - - - 8ed57135 by Matthew Pickering at 2022-04-29T04:11:29-04:00 Provide efficient unionMG function for combining two module graphs. This function is used by API clients (hls). This supercedes !6922 - - - - - 0235ff02 by Ben Gamari at 2022-04-29T04:12:05-04:00 Bump bytestring submodule Update to current `master`. - - - - - 01988418 by Matthew Pickering at 2022-04-29T04:12:05-04:00 testsuite: Normalise package versions in UnusedPackages test - - - - - 724d0dc0 by Matthew Pickering at 2022-04-29T08:59:42+00:00 testsuite: Deduplicate ways correctly This was leading to a bug where we would run a profasm test twice which led to invalid junit.xml which meant the test results database was not being populated for the fedora33-perf job. - - - - - 5630dde6 by Ben Gamari at 2022-04-29T13:06:20-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - 0cdef807 by parsonsmatt at 2022-04-30T16:51:12-04:00 Add a note about instance visibility across component boundaries In principle, the *visible* instances are * all instances defined in a prior top-level declaration group (see docs on `newDeclarationGroup`), or * all instances defined in any module transitively imported by the module being compiled However, actually searching all modules transitively below the one being compiled is unreasonably expensive, so `reifyInstances` will report only the instance for modules that GHC has had some cause to visit during this compilation. This is a shortcoming: `reifyInstances` might fail to report instances for a type that is otherwise unusued, or instances defined in a different component. You can work around this shortcoming by explicitly importing the modules whose instances you want to be visible. GHC issue #20529 has some discussion around this. Fixes #20529 - - - - - e2dd884a by Ryan Scott at 2022-04-30T16:51:47-04:00 Make mkFunCo take AnonArgFlags into account Previously, whenever `mkFunCo` would produce reflexive coercions, it would use `mkVisFunTy` to produce the kind of the coercion. However, `mkFunCo` is also used to produce coercions between types of the form `ty1 => ty2` in certain places. This has the unfortunate side effect of causing the type of the coercion to appear as `ty1 -> ty2` in certain error messages, as spotted in #21328. This patch address this by changing replacing the use of `mkVisFunTy` with `mkFunctionType` in `mkFunCo`. `mkFunctionType` checks the kind of `ty1` and makes the function arrow `=>` instead of `->` if `ty1` has kind `Constraint`, so this should always produce the correct `AnonArgFlag`. As a result, this patch fixes part (2) of #21328. This is not the only possible way to fix #21328, as the discussion on that issue lists some possible alternatives. Ultimately, it was concluded that the alternatives would be difficult to maintain, and since we already use `mkFunctionType` in `coercionLKind` and `coercionRKind`, using `mkFunctionType` in `mkFunCo` is consistent with this choice. Moreover, using `mkFunctionType` does not regress the performance of any test case we have in GHC's test suite. - - - - - 170da54f by Ben Gamari at 2022-04-30T16:52:27-04:00 Convert More Diagnostics (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors. - - - - - 39edc7b4 by Marius Ghita at 2022-04-30T16:53:06-04:00 Update user guide example rewrite rules formatting Change the rewrite rule examples to include a space between the composition of `f` and `g` in the map rewrite rule examples. Without this change, if the user has locally enabled the extension OverloadedRecordDot the copied example will result in a compile time error that `g` is not a field of `f`. ``` • Could not deduce (GHC.Records.HasField "g" (a -> b) (a1 -> b)) arising from selecting the field ‘g’ ``` - - - - - 2e951e48 by Adam Sandberg Ericsson at 2022-04-30T16:53:42-04:00 ghc-boot: export typesynonyms from GHC.Utils.Encoding This makes the Haddocks easier to understand. - - - - - d8cbc77e by Adam Sandberg Ericsson at 2022-04-30T16:54:18-04:00 users guide: add categories to some flags - - - - - d0f14fad by Chris Martin at 2022-04-30T16:54:57-04:00 hacking guide: mention the core libraries committee - - - - - 34b28200 by Matthew Pickering at 2022-04-30T16:55:32-04:00 Revert "Make the specialiser handle polymorphic specialisation" This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8. See ticket #21229 ------------------------- Metric Decrease: T15164 Metric Increase: T13056 ------------------------- - - - - - ee891c1e by Matthew Pickering at 2022-04-30T16:55:32-04:00 Add test for T21229 - - - - - ab677cc8 by Matthew Pickering at 2022-04-30T16:56:08-04:00 Hadrian: Update README about the flavour/testsuite contract There have been a number of tickets about non-tested flavours not passing the testsuite.. this is expected and now noted in the documentation. You use other flavours to run the testsuite at your own risk. Fixes #21418 - - - - - b57b5b92 by Ben Gamari at 2022-04-30T16:56:44-04:00 rts/m32: Fix assertion failure This fixes an assertion failure in the m32 allocator due to the imprecisely specified preconditions of `m32_allocator_push_filled_list`. Specifically, the caller must ensure that the page type is set to filled prior to calling `m32_allocator_push_filled_list`. While this issue did result in an assertion failure in the debug RTS, the issue is in fact benign. - - - - - a7053a6c by sheaf at 2022-04-30T16:57:23-04:00 Testsuite driver: don't crash on empty metrics The testsuite driver crashed when trying to display minimum/maximum performance changes when there are no metrics (i.e. there is no baseline available). This patch fixes that. - - - - - 636f7c62 by Andreas Klebinger at 2022-05-01T22:21:17-04:00 StgLint: Check that functions are applied to compatible runtime reps We use compatibleRep to compare reps, and avoid checking functions with levity polymorphic types because of #21399. - - - - - 60071076 by Hécate Moonlight at 2022-05-01T22:21:55-04:00 Add documentation to the ByteArray# primetype. close #21417 - - - - - 2b2e3020 by Andreas Klebinger at 2022-05-01T22:22:31-04:00 exprIsDeadEnd: Use isDeadEndAppSig to check if a function appliction is bottoming. We used to check the divergence and that the number of arguments > arity. But arity zero represents unknown arity so this was subtly broken for a long time! We would check if the saturated function diverges, and if we applied >=arity arguments. But for unknown arity functions any number of arguments is >=idArity. This fixes #21440. - - - - - 4eaf0f33 by Eric Lindblad at 2022-05-01T22:23:11-04:00 typos - - - - - fc58df90 by Niklas Hambüchen at 2022-05-02T08:59:27+00:00 libraries/base: docs: Explain relationshipt between `finalizeForeignPtr` and `*Conc*` creation Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/21420 - - - - - 3e400f20 by Krzysztof Gogolewski at 2022-05-02T18:29:23-04:00 Remove obsolete code in CoreToStg Note [Nullary unboxed tuple] was removed in e9e61f18a548b70693f4. This codepath is tested by T15696_3. - - - - - 4a780928 by Krzysztof Gogolewski at 2022-05-02T18:29:24-04:00 Fix several note references - - - - - 15ffe2b0 by Sebastian Graf at 2022-05-03T20:11:51+02:00 Assume at least one evaluation for nested SubDemands (#21081, #21133) See the new `Note [SubDemand denotes at least one evaluation]`. A demand `n :* sd` on a let binder `x=e` now means > "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is > evaluated deeply in sub-demand `sd`." The "any time it is evaluated" premise is what this patch adds. As a result, we get better nested strictness. For example (T21081) ```hs f :: (Bool, Bool) -> (Bool, Bool) f pr = (case pr of (a,b) -> a /= b, True) -- before: <MP(L,L)> -- after: <MP(SL,SL)> g :: Int -> (Bool, Bool) g x = let y = let z = odd x in (z,z) in f y ``` The change in demand signature "before" to "after" allows us to case-bind `z` here. Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`, albeit). We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand expansion. In an attempt to fix a regression caused by less inlining due to eta-reduction in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus fixing #21345 on the go. The main point of this patch is that it fixes #21081 and #21133. Annoyingly, I discovered that more precise demand signatures for join points can transform a program into a lazier program if that join point gets floated to the top-level, see #21392. There is no simple fix at the moment, but !5349 might. Thus, we accept a ~5% regression in `MultiLayerModulesTH_OneShot`, where #21392 bites us in `addListToUniqDSet`. T21392 reliably reproduces the issue. Surprisingly, ghc/alloc perf on Windows improves much more than on other jobs, by 0.4% in the geometric mean and by 2% in T16875. Metric Increase: MultiLayerModulesTH_OneShot Metric Decrease: T16875 - - - - - 948c7e40 by Andreas Klebinger at 2022-05-04T09:57:34-04:00 CoreLint - When checking for levity polymorphism look through more ticks. For expressions like `(scc<cc_name> primOp#) arg1` we should also look at arg1 to determine if we call primOp# at a fixed runtime rep. This is what corePrep already does but CoreLint didn't yet. This patch will bring them in sync in this regard. It also uses tickishFloatable in CorePrep instead of CorePrep having it's own slightly differing definition of when a tick is floatable. - - - - - 85bc73bd by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Support Unicode properly - - - - - 063d485e by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Replace LaTeX documentation syntax with Haddock The LaTeX documentation generator does not seem to have been used for quite some time, so the LaTeX-to-Haddock preprocessing step has become a pointless complication that makes documenting the contents of GHC.Prim needlessly difficult. This commit replaces the LaTeX syntax with the Haddock it would have been converted into, anyway, though with an additional distinction: it uses single quotes in places to instruct Haddock to generate hyperlinks to bindings. This improves the quality of the generated output. - - - - - d61f7428 by Ben Gamari at 2022-05-04T09:58:50-04:00 rts/ghc.mk: Only build StgCRunAsm.S when it is needed Previously the make build system unconditionally included StgCRunAsm.S in the link, meaning that the RTS would require an execstack unnecessarily. Fixes #21478. - - - - - 934a90dd by Simon Peyton Jones at 2022-05-04T16:15:34-04:00 Improve error reporting in generated code Our error reporting in generated code (via desugaring before typechecking) only worked when the generated code was just a simple call. This commit makes it work in nested cases. - - - - - 445d3657 by sheaf at 2022-05-04T16:16:12-04:00 Ensure Any is not levity-polymorphic in FFI The previous patch forgot to account for a type such as Any @(TYPE (BoxedRep l)) for a quantified levity variable l. - - - - - ddd2591c by Ben Gamari at 2022-05-04T16:16:48-04:00 Update supported LLVM versions Pull forward minimum version to match 9.2. (cherry picked from commit c26faa54c5fbe902ccb74e79d87e3fa705e270d1) - - - - - f9698d79 by Ben Gamari at 2022-05-04T16:16:48-04:00 testsuite/T7275: Use sed -r Darwin requires the `-r` flag to be compatible with GNU sed. (cherry picked from commit 512338c8feec96c38ef0cf799f3a01b77c967c56) - - - - - 8635323b by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Use ld.lld on ARMv7/Linux Due to #16177. Also cleanup some code style issues. (cherry picked from commit cc1c3861e2372f464bf9e3c9c4d4bd83f275a1a6) - - - - - 4f6370c7 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Always preserve artifacts, even in failed jobs (cherry picked from commit fd08b0c91ea3cab39184f1b1b1aafcd63ce6973f) - - - - - 6f662754 by Ben Gamari at 2022-05-04T16:16:48-04:00 configure: Make sphinx version check more robust It appears that the version of sphinx shipped on CentOS 7 reports a version string of `Sphinx v1...`. Accept the `v`. (cherry picked from commit a9197a292fd4b13308dc6664c01351c7239357ed) - - - - - 0032dc38 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Don't run make job in release pipelines (cherry picked from commit 16d6a8ff011f2194485387dcca1c00f8ddcdbdeb) - - - - - 27f9aab3 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab/ci: Fix name of bootstrap compiler directory Windows binary distributions built with Hadrian have a target platform suffix in the name of their root directory. Teach `ci.sh` about this fact. (cherry picked from commit df5752f39671f6d04d8cd743003469ae5eb67235) - - - - - b528f0f6 by Krzysztof Gogolewski at 2022-05-05T09:05:43-04:00 Fix several note references, part 2 - - - - - 691aacf6 by Adam Sandberg Ericsson at 2022-05-05T09:06:19-04:00 adjustors: align comment about number of integer like arguments with implementation for Amd4+MinGW implementation - - - - - f050557e by Simon Jakobi at 2022-05-05T12:47:32-04:00 Remove two uses of IntMap.size IntMap.size is O(n). The new code should be slightly more efficient. The transformation of GHC.CmmToAsm.CFG.calcFreqs.nodeCount can be described formally as the transformation: (\sum_{0}^{n-1} \sum_{0}^{k-1} i_nk) + n ==> (\sum_{0}^{n-1} 1 + \sum_{0}^{k-1} i_nk) - - - - - 7da90ae3 by Tom Ellis at 2022-05-05T12:48:09-04:00 Explain that 'fail s' should run in the monad itself - - - - - 610d0283 by Matthew Craven at 2022-05-05T12:48:47-04:00 Add a test for the bracketing in rules for (^) - - - - - 016f9ca6 by Matthew Craven at 2022-05-05T12:48:47-04:00 Fix broken rules for (^) with known small powers - - - - - 9372aaab by Matthew Craven at 2022-05-05T12:48:47-04:00 Give the two T19569 tests different names - - - - - 61901b32 by Andreas Klebinger at 2022-05-05T12:49:23-04:00 SpecConstr: Properly create rules for call patterns representing partial applications The main fix is that in addVoidWorkerArg we now add the argument to the front. This fixes #21448. ------------------------- Metric Decrease: T16875 ------------------------- - - - - - 71278dc7 by Teo Camarasu at 2022-05-05T12:50:03-04:00 add since annotations for instances of ByteArray - - - - - 962ff90b by sheaf at 2022-05-05T12:50:42-04:00 Start 9.6.1-notes Updates the documentation notes to start tracking changes for the 9.6.1 release (instead of 9.4). - - - - - aacb15a3 by Matthew Pickering at 2022-05-05T20:24:01-04:00 ci: Add job to check that jobs.yaml is up-to-date There have been quite a few situations where jobs.yaml has been out of date. It's better to add a CI job which checks that it's right. We don't want to use a staged pipeline because it obfuscates the structure of the pipeline. - - - - - be7102e5 by Ben Gamari at 2022-05-05T20:24:37-04:00 rts: Ensure that XMM registers are preserved on Win64 Previously we only preserved the bottom 64-bits of the callee-saved 128-bit XMM registers, in violation of the Win64 calling convention. Fix this. Fixes #21465. - - - - - 73b22ff1 by Ben Gamari at 2022-05-05T20:24:37-04:00 testsuite: Add test for #21465 - - - - - e2ae9518 by Ziyang Liu at 2022-05-06T19:22:22-04:00 Allow `let` just before pure/return in ApplicativeDo The following is currently rejected: ```haskell -- F is an Applicative but not a Monad x :: F (Int, Int) x = do a <- pure 0 let b = 1 pure (a, b) ``` This has bitten me multiple times. This MR contains a simple fix: only allow a "let only" segment to be merged with the next (and not the previous) segment. As a result, when the last one or more statements before pure/return are `LetStmt`s, there will be one more segment containing only those `LetStmt`s. Note that if the `let` statement mentions a name bound previously, then the program is still rejected, for example ```haskell x = do a <- pure 0 let b = a + 1 pure (a, b) ``` or the example in #18559. To support this would require a more complex approach, but this is IME much less common than the previous case. - - - - - 0415449a by Matthew Pickering at 2022-05-06T19:22:58-04:00 template-haskell: Fix representation of OPAQUE pragmas There is a mis-match between the TH representation of OPAQUE pragmas and GHC's internal representation due to how OPAQUE pragmas disallow phase annotations. It seemed most in keeping to just fix the wired in name issue by adding a special case to the desugaring of INLINE pragmas rather than making TH/GHC agree with how the representation should look. Fixes #21463 - - - - - 4de887e2 by Simon Peyton Jones at 2022-05-06T19:23:34-04:00 Comments only: Note [AppCtxt] - - - - - 6e69964d by Matthew Pickering at 2022-05-06T19:24:10-04:00 Fix name of windows release bindist in doc-tarball job - - - - - ced4689e by Matthew Pickering at 2022-05-06T19:24:46-04:00 ci: Generate source-tarball in release jobs We need to distribute the source tarball so we should generate it in the CI pipeline. - - - - - 3c91de21 by Rob at 2022-05-08T13:40:53+02:00 Change Specialise to use OrdList. Fixes #21362 Metric Decrease: T16875 - - - - - 67072c31 by Simon Jakobi at 2022-05-08T12:23:43-04:00 Tweak GHC.CmmToAsm.CFG.delEdge mapAdjust is more efficient than mapAlter. - - - - - 374554bb by Teo Camarasu at 2022-05-09T16:24:37-04:00 Respect -po when heap profiling (#21446) - - - - - 1ea414b6 by Teo Camarasu at 2022-05-09T16:24:37-04:00 add test case for #21446 - - - - - c7902078 by Jens Petersen at 2022-05-09T16:25:17-04:00 avoid hadrian/bindist/Makefile install_docs error when --docs=none When docs are disabled the bindist does not have docs/ and hence docs-utils/ is not generated. Here we just test that docs-utils exists before attempting to install prologue.txt and gen_contents_index to avoid the error: /usr/bin/install: cannot stat 'docs-utils/prologue.txt': No such file or directory make: *** [Makefile:195: install_docs] Error 1 - - - - - 158bd659 by Hécate Moonlight at 2022-05-09T16:25:56-04:00 Correct base's changelog for 4.16.1.0 This commit reaffects the new Ix instances of the foreign integral types from base 4.17 to 4.16.1.0 closes #21529 - - - - - a4fbb589 by Sylvain Henry at 2022-05-09T16:26:36-04:00 STG: only print cost-center if asked to - - - - - 50347ded by Gergo ERDI at 2022-05-10T11:43:33+00:00 Improve "Glomming" note Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order references, and thus needing to glom, is not a cause for concern when its root cause is rewrite rules. - - - - - df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00 update INSTALL - - - - - dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00 driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode It seems like it was just an oversight to use the incorrect DynFlags (global rather than local) when implementing these two options. Using the local flags allows users to request these intermediate files get cleaned up, which works fine in --make mode because 1. Interface files are stored in memory 2. Object files are only cleaned at the end of session (after link) Fixes #21349 - - - - - 35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00 configure: Check for ffi.h As noted in #21485, we checked for ffi.h yet then failed to throw an error if it is missing. Fixes #21485. - - - - - bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00 Check for uninferrable variables in tcInferPatSynDecl This fixes #21479 See Note [Unquantified tyvars in a pattern synonym] While doing this, I found that some error messages pointed at the pattern synonym /name/, rather than the /declaration/ so I widened the SrcSpan to encompass the declaration. - - - - - 142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00 hadrian: Fix split-sections transformer The splitSections transformer has been broken since -dynamic-too support was implemented in hadrian. This is because we actually build the dynamic way when building the dynamic way, so the predicate would always fail. The fix is to just always pass `split-sections` even if it doesn't do anything for a particular way. Fixes #21138 - - - - - 699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. Closes #21135 - - - - - 21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00 Use the wrapper for an unlifted binding We assumed the wrapper for an unlifted binding is the identity, but as #21516 showed, that is no always true. Solution is simple: use it. - - - - - 68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00 docs: Fix path to GHC API docs in index.html In the make bindists we generate documentation in docs/ghc-<VER> but the hadrian bindists generate docs/ghc/ so the path to the GHC API docs was wrong in the index.html file. Rather than make the hadrian and make bindists the same it was easier to assume that if you're using the mkDocs script that you're using hadrian bindists. Fixes #21509 - - - - - 9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00 hadrian: Don't pass -j to haddock This has high potential for oversubcribing as many haddock jobs can be spawned in parralel which will each request the given number of capabilities. Once -jsem is implemented (#19416, !5176) we can expose that haddock via haddock and use that to pass a semaphore. Ticket #21136 - - - - - fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00 hadrian: Only copy and install libffi headers when using in-tree libffi When passed `--use-system-libffi` then we shouldn't copy and install the headers from the system package. Instead the headers are expected to be available as a runtime dependency on the users system. Fixes #21485 #21487 - - - - - 5b791ed3 by mikael at 2022-05-11T08:22:13-04:00 FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10. - - - - - 8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00 Make floating-point abs IEEE 754 compliant The old code used by via-C backend didn't handle the sign bit of NaN. See #21043. - - - - - 4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00 EPA: do statement with leading semicolon has wrong anchor The code do; a <- doAsync; b Generated an incorrect Anchor for the statement list that starts after the first semicolon. This commit fixes it. Closes #20256 - - - - - e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00 Specialiser: saturate DFuns correctly Ticket #21489 showed that the saturation mechanism for DFuns (see Note Specialising DFuns) should use both UnspecType and UnspecArg. We weren't doing that; but this MR fixes that problem. No test case because it's hard to tickle, but it showed up in Gergo's work with GHC-as-a-library. - - - - - fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00 gitlab-ci: Check for dynamic msys2 dependencies Both #20878 and #21196 were caused by unwanted dynamic dependencies being introduced by boot libraries. Ensure that we catch this in CI by attempting to run GHC in an environment with a minimal PATH. - - - - - 3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00 Add back Debian9 CI jobs We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 not being at EOL until April 2023 and they still need tinfo5. Fixes #21469 - - - - - dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00 rts: Drop setExecutable Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been dead code. Drop it. - - - - - 32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00 Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat This missing guard gave rise to #21519. - - - - - 2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00 Add mention of -hi to RTS --help Fixes #21546 - - - - - a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00 Decouple dynflags in Cmm parser (related to #17957) - - - - - 3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00 Remove Module argument from initCmmParserConfig - - - - - 2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00 Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config - - - - - b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00 Decouple dynflags in GHC.Core.Opt.Arity (related to #17957) Metric Decrease: T16875 - - - - - 3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00 Update extending_ghc for TcPlugin changes The documentation still mentioned Derived constraints and an outdated datatype TcPluginResult. - - - - - 668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00 Fix printing of brackets in multiplicities (#20315) Change mulArrow to allow for printing of correct application precedence where necessary and update callers of mulArrow to reflect this. As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type. Fixes #20315 - - - - - 30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00 rts: Add debug output on ocResolve failure This makes it easier to see how resolution failures nest. - - - - - 53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00 rts/PEi386: Fix handling of weak symbols Previously we would flag the symbol as weak but failed to set its address, which must be computed from an "auxiliary" symbol entry the follows the weak symbol. Fixes #21556. - - - - - 5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00 testsuite: Add tests for #21556 - - - - - 49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00 Re-export augment and build from GHC.List Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127 - - - - - aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00 Comments only around HsWrapper - - - - - 27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00 hadrian: Introduce linting flavour transformer (+lint) The linting flavour enables -dlint uniformly across anything build by the stage1 compiler. -dcmm-lint is not currently enabled because it fails on i386 (see #21563) - - - - - 3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00 hadrian: Uniformly enable -dlint with enableLinting transformer This fixes some bugs where * -dcore-lint was being passed when building stage1 libraries with the boot compiler * -dcore-lint was not being passed when building executables. Fixes #20135 - - - - - 3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00 Make closure macros EXTERN_INLINE to make debugging easier Implements #21424. The RTS macros get_itbl and friends are extremely helpful during debugging. However only a select few of those were available in the compiled RTS as actual symbols as the rest were INLINE macros. This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites but allow us to use their compiled counterparts during debugging. This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell since `get_fun_itbl` will now be available as symbol! - - - - - 93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00 packaging: Introduce CI job for generating hackage documentation This adds a CI job (hackage-doc-tarball) which generates the necessary tarballs for uploading libraries and documentation to hackage. The release script knows to download this folder and the upload script will also upload the release to hackage as part of the release. The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs There are two modes, preparation and upload. * The `prepare` mode takes a link to a bindist and creates a folder containing the source and doc tarballs ready to upload to hackage. * The `upload` mode takes the folder created by prepare and performs the upload to hackage. Fixes #21493 Related to #21512 - - - - - 65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00 Add arity to the INLINE pragmas for pattern synonyms The lack of INLNE arity was exposed by #21531. The fix is simple enough, if a bit clumsy. - - - - - 43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00 Misc cleanup - Remove groupWithName (unused) - Use the RuntimeRepType synonym where possible - Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM No functional changes. - - - - - 8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00 TcPlugin: access to irreducible givens + fix passed ev_binds_var - - - - - fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00 driver: Introduce pgmcxx Here we introduce proper support for compilation of C++ objects. This includes: * logic in `configure` to detect the C++ toolchain and propagating this information into the `settings` file * logic in the driver to use the C++ toolchain when compiling C++ sources - - - - - 43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Build T20918 with HC, not CXX - - - - - 0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00 Introduce package to capture dependency on C++ stdlib Here we introduce a new "virtual" package into the initial package database, `system-cxx-std-lib`. This gives users a convenient, platform agnostic way to link against C++ libraries, addressing #20010. Fixes #20010. - - - - - 03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Add tests for system-cxx-std-lib package Test that we can successfully link against C++ code both in GHCi and batch compilation. See #20010 - - - - - 5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00 OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420) - - - - - eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00 Adjust flags for pprTrace We were using defaultSDocContext for pprTrace, which suppresses lots of useful infomation. This small MR adds GHC.Utils.Outputable.traceSDocContext and uses it for pprTrace and pprTraceUserWarning. traceSDocContext is a global, and hence not influenced by flags, but that seems unavoidable. But I made the sdocPprDebug bit controlled by unsafeHasPprDebug, since we have the latter for exactly this purpose. Fixes #21569 - - - - - d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00 Fix bad interaction between withDict and the Specialiser This MR fixes a bad bug, where the withDict was inlined too vigorously, which in turn made the type-class Specialiser generate a bogus specialisation, because it saw the same overloaded function applied to two /different/ dictionaries. Solution: inline `withDict` later. See (WD8) of Note [withDict] in GHC.HsToCore.Expr See #21575, which is fixed by this change. - - - - - 70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00 Bump time submodule to 1.12.2 This bumps the time submodule to the 1.12.2 release. Fixes #21571 - - - - - 2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00 Remove unused test files (#21582) Those files were moved to the perf/ subtree in 11c9a469, and then accidentally reintroduced in 680ef2c8. - - - - - cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00 CafAnal: Improve code clarity Here we implement a few measures to improve the clarity of the CAF analysis implementation. Specifically: * Use CafInfo instead of Bool since the former is more descriptive * Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact CAFs * Add numerous comments - - - - - b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00 codeGen: Ensure that static datacon apps are included in SRTs When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT filters out recursive references, as described in Note [recursive SRTs]. However, doing so for static functions would be unsound, for the reason described in Note [Invalid optimisation: shortcutting]. However, the same argument applies to static data constructor applications, as we discovered in #20959. Fix this by ensuring that static data constructor applications are included in recursive SRTs. The approach here is not entirely satisfactory, but it is a starting point. Fixes #20959. - - - - - 0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00 Add test for #21558 This is now fixed on master and 9.2 branch. Closes #21558 - - - - - ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00 Don't store LlvmConfig into DynFlags LlvmConfig contains information read from llvm-passes and llvm-targets files in GHC's top directory. Reading these files is done only when needed (i.e. when the LLVM backend is used) and cached for the whole compiler session. This patch changes the way this is done: - Split LlvmConfig into LlvmConfig and LlvmConfigCache - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no good reason to store it in DynFlags. As it is fixed per session, we store it in the session state instead (HscEnv). - Initializing LlvmConfigCache required some changes to driver functions such as newHscEnv. I've used the opportunity to untangle initHscEnv from initGhcMonad (in top-level GHC module) and to move it to GHC.Driver.Main, close to newHscEnv. - I've also made `cmmPipeline` independent of HscEnv in order to remove the call to newHscEnv in regalloc_unit_tests. - - - - - 828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00 Give all EXTERN_INLINE closure macros prototypes - - - - - cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Introduce [sg]etFinalizerExceptionHandler This introduces a global hook which is called when an exception is thrown during finalization. - - - - - 372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Throw exceptions raised while closing finalized Handles Fixes #21336. - - - - - 3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00 testsuite: Add tests for #21336 - - - - - 297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00 Add release flavour and use it for the release jobs The release flavour is essentially the same as the perf flavour currently but also enables `-haddock`. I have hopefully updated all the relevant places where the `-perf` flavour was hardcoded. Fixes #21486 - - - - - a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Don't build sphinx documentation on centos The centos docker image lacks the sphinx builder so we disable building sphinx docs for these jobs. Fixes #21580 - - - - - 209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Use correct syntax when args list is empty This seems to fail on the ancient version of bash present on CentOS - - - - - 02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00 hadrian: Don't attempt to build dynamic profiling libraries We only support building static profiling libraries, the transformer was requesting things like a dynamic, threaded, debug, profiling RTS, which we have never produced nor distributed. Fixes #21567 - - - - - 35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00 configure: Check CC_STAGE0 for --target support We previously only checked the stage 1/2 compiler for --target support. We got away with this for quite a while but it eventually caught up with us in #21579, where `bytestring`'s new NEON implementation was unbuildable on Darwin due to Rosetta's seemingly random logic for determining which executable image to execute. This lead to a confusing failure to build `bytestring`'s cbits, when `clang` tried to compile NEON builtins while targetting x86-64. Fix this by checking CC_STAGE0 for --target support. Fixes #21579. - - - - - 0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator analysis of `CmmGraph` This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper around two existing algorithms in GHC: the Lengauer-Tarjan dominator analysis from the X86 back end and the reverse postorder ordering from the Cmm Dataflow framework. Issue #20726 proposes that we evaluate some alternatives for dominator analysis, but for the time being, the best path forward is simply to use the existing analysis on `CmmGraph`s. This commit addresses a bullet in #21200. - - - - - 54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator-tree function - - - - - 05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add HasDebugCallStack; remove unneeded extensions - - - - - 0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00 document fields of `DominatorSet` - - - - - 8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00 nonmoving: Fix documentation of GC statistics fields These were previously incorrect. Fixes #21553. - - - - - c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00 Remove pprTrace from pushCoercionIntoLambda (#21555) This firstly caused spurious output to be emitted (as evidenced by #21555) but even worse caused a massive coercion to be attempted to be printed (> 200k terms) which would invariably eats up all the memory of your computer. The good news is that removing this trace allows the program to compile to completion, the bad news is that the program exhibits a core lint error (on 9.0.2) but not any other releases it seems. Fixes #21577 and #21555 - - - - - a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00 docs: Fix LlvmVersion in manpage (#21280) - - - - - 36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00 validate: Use $make rather than make In the validate script we are careful to use the $make variable as this stores whether we are using gmake, make, quiet mode etc. There was just this one place where we failed to use it. Fixes #21598 - - - - - 4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00 Change `Backend` type and remove direct dependencies With this change, `Backend` becomes an abstract type (there are no more exposed value constructors). Decisions that were formerly made by asking "is the current back end equal to (or different from) this named value constructor?" are now made by interrogating the back end about its properties, which are functions exported by `GHC.Driver.Backend`. There is a description of how to migrate code using `Backend` in the user guide. Clients using the GHC API can find a backdoor to access the Backend datatype in GHC.Driver.Backend.Internal. Bumps haddock submodule. Fixes #20927 - - - - - ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00 Respect DESTDIR in hadrian bindist Makefile, fixes #19646 - - - - - 7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00 Test DESTDIR in test_hadrian() - - - - - ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00 Consider the stage of typeable evidence when checking stage restriction We were considering all Typeable evidence to be "BuiltinInstance"s which meant the stage restriction was going unchecked. In-fact, typeable has evidence and so we need to apply the stage restriction. This is complicated by the fact we don't generate typeable evidence and the corresponding DFunIds until after typechecking is concluded so we introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which records whether the evidence is going to be local or not. Fixes #21547 - - - - - ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00 Modularize GHC.Core.Opt.LiberateCase Progress towards #17957 - - - - - bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00 Improve FloatOut and SpecConstr This patch addresses a relatively obscure situation that arose when chasing perf regressions in !7847, which itself is fixing It does two things: * SpecConstr can specialise on ($df d1 d2) dictionary arguments * FloatOut no longer checks argument strictness See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr. A test case is difficult to construct, but it makes a big difference in nofib/real/eff/VSM, at least when we have the patch for #21286 installed. (The latter stops worker/wrapper for dictionary arguments). There is a spectacular, but slightly illusory, improvement in runtime perf on T15426. I have documented the specifics in T15426 itself. Metric Decrease: T15426 - - - - - 1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00 Make debug a `Bool` not an `Int` in `StgToCmmConfig` We don't need any more resolution than this. Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer conveying any "level" information. - - - - - e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00 EPA : Remove duplicate comments in DataFamInstD The code data instance Method PGMigration = MigrationQuery Query -- ^ Run a query against the database | MigrationCode (Connection -> IO (Either String ())) -- ^ Run any arbitrary IO code Resulted in two instances of the "-- ^ Run a query against the database" comment appearing in the Exact Print Annotations when it was parsed. Ensure only one is kept. Closes #20239 - - - - - e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00 EPA: Comment Order Reversed Make sure comments captured in the exact print annotations are in order of increasing location Closes #20718 - - - - - 4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Add test for T21455 - - - - - e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Allow passing -po outside profiling way Resolves #21455 - - - - - 3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00 Fix haddock_*_perf tests on non-GNU-grep systems Using regexp pattern requires `egrep` and straight up `+`. The haddock_parser_perf and haddock_renamer_perf tests now pass on OpenBSD. They previously incorrectly parsed the files and awk complained about invalid syntax. - - - - - 1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00 hadrian/bindist: Drop redundant include of install.mk `install.mk` is already included by `config.mk`. Moreover, `install.mk` depends upon `config.mk` to set `RelocatableBuild`, making this first include incorrect. - - - - - f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00 Remove -z wxneeded for OpenBSD With all the recent W^X fixes in the loader this workaround is not necessary any longer. I verified that the only tests failing for me on OpenBSD 7.1-current are the same (libc++ related) before and after this commit (with --fast). - - - - - 7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00 Use UnionListsOrd instead of UnionLists in most places. This should get rid of most, if not all "Overlong lists" errors and fix #20016 - - - - - 81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00 Fix #21563 by using Word64 for 64bit shift code. We use the 64bit shifts only on 64bit platforms. But we compile the code always so compiling it on 32bit caused a lint error. So use Word64 instead. - - - - - 2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00 Fix compilation with -haddock on GHC <= 8.10 -haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors when it encounters invalid haddock syntax. This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b enabled -haddock by default on many flavours. Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem managed to slip throught the cracks. - - - - - cfb9faff by sheaf at 2022-05-24T22:15:12-04:00 Hadrian: don't add "lib" for relocatable builds The conditional in hadrian/bindist/Makefile depended on the target OS, but it makes more sense to use whether we are using a relocatable build. (Currently this only gets set to true on Windows, but this ensures that the logic stays correctly coupled.) - - - - - 9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00 Remove HscEnv from GHC.HsToCore.Usage (related to #17957) Metric Decrease: T16875 - - - - - 2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00 SimpleOpt: beta-reduce through casts The simple optimiser would sometimes fail to beta-reduce a lambda when there were casts in between the lambda and its arguments. This can cause problems because we rely on representation-polymorphic lambdas getting beta-reduced away (for example, those that arise from newtype constructors with representation-polymorphic arguments, with UnliftedNewtypes). - - - - - e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00 Desugar RecordUpd in `tcExpr` This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule - - - - - 2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00 update README - - - - - 3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00 Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602) - - - - - ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00 Add Haddocks for `WwOpts` - - - - - da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00 Avoid global compiler state for `GHC.Core.Opt.WorkWrap` Progress towards #17957 - - - - - 3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00 Optimiser: avoid introducing bad rep-poly The functions `pushCoValArg` and `pushCoercionIntoLambda` could introduce bad representation-polymorphism. Example: type RR :: RuntimeRep type family RR where { RR = IntRep } type F :: TYPE RR type family F where { F = Int# } co = GRefl F (TYPE RR[0]) :: (F :: TYPE RR) ~# (F |> TYPE RR[0] :: TYPE IntRep) f :: F -> () `pushCoValArg` would transform the unproblematic application (f |> (co -> <()>)) (arg :: F |> TYPE RR[0]) into an application in which the argument does not have a fixed `RuntimeRep`: f ((arg |> sym co) :: (F :: TYPE RR)) - - - - - b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00 executablePath test: fix file extension treatment The executablePath test strips the file extension (if any) when comparing the query result with the expected value. This is to handle platforms where GHC adds a file extension to the output program file (e.g. .exe on Windows). After the initial check, the file gets deleted (if supported). However, it tries to delete the *stripped* filename, which is incorrect. The test currently passes only because Windows does not allow deleting the program while any process created from it is alive. Make the test program correct in general by deleting the *non-stripped* executable filename. - - - - - afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00 fix executablePath test for NetBSD executablePath support for NetBSD was added in a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not updated. Update the test so that it works for NetBSD. This requires handling some quirks: - The result of getExecutablePath could include "./" segments. Therefore use System.FilePath.equalFilePath to compare paths. - The sysctl(2) call returns the original executable name even after it was deleted. Add `canQueryAfterDelete :: [FilePath]` and adjust expectations for the post-delete query accordingly. Also add a note to the `executablePath` haddock to advise that NetBSD behaves differently from other OSes when the file has been deleted. Also accept a decrease in memory usage for T16875. On Windows, the metric is -2.2% of baseline, just outside the allowed ±2%. I don't see how this commit could have influenced this metric, so I suppose it's something in the CI environment. Metric Decrease: T16875 - - - - - d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00 Factor out `initArityOps` to `GHC.Driver.Config.*` module We want `DynFlags` only mentioned in `GHC.Driver`. - - - - - 44bb7111 by romes at 2022-05-26T16:27:57+00:00 TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs - - - - - 88e58600 by sheaf at 2022-05-26T17:38:43-04:00 Add tests for eta-expansion of data constructors This patch adds several tests relating to the eta-expansion of data constructors, including UnliftedNewtypes and DataTypeContexts. - - - - - d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00 Generalize breakTyVarCycle to work with TyFamLHS The function breakTyVarCycle_maybe has been installed in a dark corner of GHC to catch some gremlins (a.k.a. occurs-check failures) who lurk there. But it previously only caught gremlins of the form (a ~ ... F a ...), where some of our intrepid users have spawned gremlins of the form (G a ~ ... F (G a) ...). This commit improves breakTyVarCycle_maybe (and renames it to breakTyEqCycle_maybe) to catch the new gremlins. Happily, the change is remarkably small. The gory details are in Note [Type equality cycles]. Test cases: typecheck/should_compile/{T21515,T21473}. - - - - - ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00 [base] Fix the links in the Data.Data module fix #21658 fix #21657 fix #21657 - - - - - 3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00 Use a class to check validity of withDict This moves handling of the magic 'withDict' function from the desugarer to the typechecker. Details in Note [withDict]. I've extracted a part of T16646Fail to a separate file T16646Fail2, because the new error in 'reify' hides the errors from 'f' and 'g'. WithDict now works with casts, this fixes #21328. Part of #19915 - - - - - b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00 Fix FreeVars computation for mdo Commit acb188e0 introduced a regression in the computation of free variables in mdo statements, as the logic in GHC.Rename.Expr.segmentRecStmts was slightly different depending on whether the recursive do block corresponded to an mdo statement or a rec statment. This patch restores the previous computation for mdo blocks. Fixes #21654 - - - - - 0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00 T16875: Stabilise (temporarily) by increasing acceptance threshold The theory is that on windows there is some difference in the environment between pipelines on master and merge requests which affects all tests equally but because T16875 barely allocates anything it is the test which is affected the most. See #21557 - - - - - 6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00 make: Fix make maintainer-clean deleting a file tracked by source control Fixes #21659 - - - - - fbf2f254 by Bodigrim at 2022-05-28T21:01:58-04:00 Expand documentation of hIsTerminalDevice - - - - - 0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00 export IsList from GHC.IsList it is still re-exported from GHC.Exts - - - - - 91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00 MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR ARM64_RELOC_SUBTRACTOR relocations are paired with an AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2 The linker was doing it in two steps, basically: *addend <- *addend - sym2 *addend <- *addend + sym1 The first operation was likely to overflow. For example when the relocation target was 32-bit and both sym1/sym2 were 64-bit addresses. With the small memory model, (sym1-sym2) would fit in 32 bits but (*addend-sym2) may not. Now the linker does it in one step: *addend <- *addend + sym1 - sym2 - - - - - acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Some fixes to SRT documentation - reordered the 3 SRT implementation cases from the most general to the most specific one: USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD - added requirements for each - found and documented a confusion about "SRT inlining" not supported with MachO. (It is fixed in the following commit) - - - - - 5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Enable USE_INLINE_SRT_FIELD on ARM64 It was previously disabled because of: - a confusion about "SRT inlining" (see removed comment in this commit) - a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR relocation: fixed by a previous commit. - - - - - 59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00 ci: Make sure to exit promptly if `make install` fails. Due to the vageries of bash, you have to explicitly handle the failure and exit when in a function. This failed to exit promptly when !8247 was failing. See #21358 for the general issue - - - - - 5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00 Split GHC.HsToCore.Foreign.Decl This is preliminary work for JavaScript support. It's better to put the code handling the desugaring of Prim, C and JavaScript declarations into separate modules. - - - - - 6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00 Bump hadrian to LTS-19.8 (GHC 9.0.2) - - - - - f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00 Hadrian: remove unused code - - - - - 2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Eta reduction with casted function We want to be able to eta-reduce \x y. ((f x) |> co) y by pushing 'co' inwards. A very small change accommodates this See Note [Eta reduction with casted function] - - - - - f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Do arity trimming at bindings, rather than in exprArity Sometimes there are very large casts, and coercionRKind can be slow. - - - - - 610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make findRhsArity take RecFlag This avoids a fixpoint iteration for the common case of non-recursive bindings. - - - - - 80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Comments and white space - - - - - 0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make PrimOpId record levity This patch concerns #20155, part (1) The general idea is that since primops have curried bindings (currently in PrimOpWrappers.hs) we don't need to eta-expand them. But we /do/ need to eta-expand the levity-polymorphic ones, because they /don't/ have bindings. This patch makes a start in that direction, by identifying the levity-polymophic primops in the PrimOpId IdDetails constructor. For the moment, I'm still eta-expanding all primops (by saying that hasNoBinding returns True for all primops), because of the bug reported in #20155. But I hope that before long we can tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding. - - - - - 6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: * Move state-hack stuff from GHC.Types.Id (where it never belonged) to GHC.Core.Opt.Arity (which seems much more appropriate). * Add a crucial mkCast in the Cast case of GHC.Core.Opt.Arity.eta_expand; helps with T18223 * Add clarifying notes about eta-reducing to PAPs. See Note [Do not eta reduce PAPs] * I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity, where it properly belongs. See Note [Eta reduce PAPs] * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for when eta-expansion is wanted, to make wantEtaExpansion, and all that same function in GHC.Core.Opt.Simplify.simplStableUnfolding. It was previously inconsistent, but it's doing the same thing. * I did a substantial refactor of ArityType; see Note [ArityType]. This allowed me to do away with the somewhat mysterious takeOneShots; more generally it allows arityType to describe the function, leaving its clients to decide how to use that information. I made ArityType abstract, so that clients have to use functions to access it. * Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called mkLam before) aware of the floats that the simplifier builds up, so that it can still do eta-reduction even if there are some floats. (Previously that would not happen.) That means passing the floats to rebuildLam, and an extra check when eta-reducting (etaFloatOk). * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info in the idDemandInfo of the binder, as well as the CallArity info. The occurrence analyser did this but we were failing to take advantage here. In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity; see Note [Combining arityType with demand info], and functions idDemandOneShots and combineWithDemandOneShots. (These changes partly drove my refactoring of ArityType.) * In GHC.Core.Opt.Arity.findRhsArity * I'm now taking account of the demand on the binder to give extra one-shot info. E.g. if the fn is always called with two args, we can give better one-shot info on the binders than if we just look at the RHS. * Don't do any fixpointing in the non-recursive case -- simple short cut. * Trim arity inside the loop. See Note [Trim arity inside the loop] * Make SimpleOpt respect the eta-reduction flag (Some associated refactoring here.) * I made the CallCtxt which the Simplifier uses distinguish between recursive and non-recursive right-hand sides. data CallCtxt = ... | RhsCtxt RecFlag | ... It affects only one thing: - We call an RHS context interesting only if it is non-recursive see Note [RHS of lets] in GHC.Core.Unfold * Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification. See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep. Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. * Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg Metrics: compile_time/bytes allocated Test Metric Baseline New value Change --------------------------------------------------------------------------------------- MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,743,297,692 2,619,762,992 -4.5% GOOD T18223(normal) ghc/alloc 1,103,161,360 972,415,992 -11.9% GOOD T3064(normal) ghc/alloc 201,222,500 184,085,360 -8.5% GOOD T8095(normal) ghc/alloc 3,216,292,528 3,254,416,960 +1.2% T9630(normal) ghc/alloc 1,514,131,032 1,557,719,312 +2.9% BAD parsing001(normal) ghc/alloc 530,409,812 525,077,696 -1.0% geo. mean -0.1% Nofib: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- banner +0.0% +0.4% -8.9% -8.7% 0.0% exact-reals +0.0% -7.4% -36.3% -37.4% 0.0% fannkuch-redux +0.0% -0.1% -1.0% -1.0% 0.0% fft2 -0.1% -0.2% -17.8% -19.2% 0.0% fluid +0.0% -1.3% -2.1% -2.1% 0.0% gg -0.0% +2.2% -0.2% -0.1% 0.0% spectral-norm +0.1% -0.2% 0.0% 0.0% 0.0% tak +0.0% -0.3% -9.8% -9.8% 0.0% x2n1 +0.0% -0.2% -3.2% -3.2% 0.0% -------------------------------------------------------------------------------- Min -3.5% -7.4% -58.7% -59.9% 0.0% Max +0.1% +2.2% +32.9% +32.9% 0.0% Geometric Mean -0.0% -0.1% -14.2% -14.8% -0.0% Metric Decrease: MultiLayerModulesTH_OneShot T18223 T3064 T15185 T14766 Metric Increase: T9630 - - - - - cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00 hadrian: Fix building from source-dist without alex/happy This fixes two bugs which were adding dependencies on alex/happy when building from a source dist. * When we try to pass `--with-alex` and `--with-happy` to cabal when configuring but the builders are not set. This is fixed by making them optional. * When we configure, cabal requires alex/happy because of the build-tool-depends fields. These are now made optional with a cabal flag (build-tool-depends) for compiler/hpc-bin/genprimopcode. Fixes #21627 - - - - - a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test the bootstrap without ALEX/HAPPY on path - - - - - 0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test bootstrapping in release jobs - - - - - d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label - - - - - 18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00 rts: Remove explicit timescale for deprecating -h flag We originally planned to remove the flag in 9.4 but there's actually no great rush to do so and it's probably less confusing (forever) to keep the message around suggesting an explicit profiling option. Fixes #21545 - - - - - eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00 Enable -dlint in hadrian lint transformer Now #21563 is fixed we can properly enable `-dlint` in CI rather than a subset of the flags. - - - - - 0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00 upload-ghc-libs: Allow candidate-only upload - - - - - 83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00 Avoid using DynFlags in GHC.Linker.Unit (#17957) - - - - - 5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00 hadrian: Introduce new package database for executables needed to build stage0 These executables (such as hsc2hs) are built using the boot compiler and crucially, most libraries from the global package database. We also move other build-time executables to be built in this stage such as linters which also cleans up which libraries end up in the global package database. This allows us to remove hacks where linters-common is removed from the package database when a bindist is created. This fixes issues caused by infinite recursion due to bytestring adding a dependency on template-haskell. Fixes #21634 - - - - - 0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00 Build stage1 with -V as well This helps tracing errors which happen when building stage1 - - - - - 15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00 Revert "packaging: Build perf builds with -split-sections" This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f. Split sections causes segfaults in profiling way with old toolchains (deb9) and on windows (#21670) Fixes #21670 - - - - - d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00 Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard Progress towards #17957 Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other modules as thoroughly as I usually do. This does mean that risk of `DynFlags` "creeping back in" is higher than it usually is. After we do the same process to the other Core passes, and then figure out what we want to do about `CoreM`, we can finish the job started here. That is a good deal more work, however, so it certainly makes sense to land this now. - - - - - a720322f by romes at 2022-06-01T07:44:44-04:00 Restore Note [Quasi-quote overview] - - - - - 392ce3fc by romes at 2022-06-01T07:44:44-04:00 Move UntypedSpliceFlavour from L.H.S to GHC.Hs UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr` but was defined in the client-independent L.H.S.Expr. - - - - - 7975202b by romes at 2022-06-01T07:44:44-04:00 TTG: Rework and improve splices This commit redefines the structure of Splices in the AST. We get rid of `HsSplice` which used to represent typed and untyped splices, quasi quotes, and the result of splicing either an expression, a type or a pattern. Instead we have `HsUntypedSplice` which models an untyped splice or a quasi quoter, which works in practice just like untyped splices. The `HsExpr` constructor `HsSpliceE` which used to be constructed with an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The former is directly constructed with an `HsExpr` and the latter now takes an `HsUntypedSplice`. Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now take an `HsUntypedSplice` instead of a `HsSplice` (remember only /untyped splices/ can be spliced as types or patterns). The result of splicing an expression, type, or pattern is now comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`, `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult (HsExpr GhcRn)` Overall the TTG extension points are now better used to make invalid states unrepresentable and model the progression between stages better. See Note [Lifecycle of an untyped splice, and PendingRnSplice] and Note [Lifecycle of an typed splice, and PendingTcSplice] for more details. Updates haddock submodule Fixes #21263 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - 320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00 Add test for #21619 Fixes #21619 - - - - - ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00 Pure Haskell implementation of GHC.Unicode Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/). Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691. - Remove current Unicode cbits. - Add generator for Unicode property files from Unicode Character Database. - Generate internal modules. - Update GHC.Unicode. - Add unicode003 test for general categories and case mappings. - Add Python scripts to check 'base' Unicode tests outputs and characters properties. Fixes #21375 ------------------------- Metric Decrease: T16875 Metric Increase: T4029 T18304 haddock.base ------------------------- - - - - - 514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00 typos - - - - - 9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00 source-dist: Copy in files created by ./boot Since we started producing source dists with hadrian we stopped copying in the files created by ./boot which adds a dependency on python3 and autoreconf. This adds back in the files which were created by running configure. Fixes #21673 #21672 and #21626 - - - - - a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00 ci: Don't try to run ./boot when testing bootstrap of source dist - - - - - e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00 Language.Haskell.Syntax: Fix docs for PromotedConsT etc. Fixes ghc/ghc#21675. - - - - - 87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump bytestring, process, and text submodules Metric Decrease: T5631 Metric Increase: T18223 (cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af) - - - - - 24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump Cabal submodule To current `master`. (cherry picked from commit fbb59c212415188486aafd970eafef170516356a) - - - - - 5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00 hadrian/tool-args: Write output to intermediate file rather than via stdout This allows us to see the output of hadrian while it is doing the setup. - - - - - 468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00 Make -fcompact-unwind the default This is a follow-up to !7247 (closed) making the inclusion of compact unwinding sections the default. Also a slight refactoring/simplification of the flag handling to add -fno-compact-unwind. - - - - - 819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00 hadrian bootstrap: add plans for 9.0.2 and 9.2.3 - - - - - 9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00 ci: Add matrix for bootstrap sources - - - - - ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00 HsToCore.Coverage: Improve haddocks - - - - - f065804e by John Ericson at 2022-06-02T15:42:59+00:00 Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller No need to inline traversing a maybe for `mkModBreaks`. And better to make each function do one thing and let the caller deside when than scatter the decision making and make the caller seem more imperative. - - - - - d550d907 by John Ericson at 2022-06-02T15:42:59+00:00 Rename `HsToCore.{Coverage -> Ticks}` The old name made it confusing why disabling HPC didn't disable the entire pass. The name makes it clear --- there are other reasons to add ticks in addition. - - - - - 6520da95 by John Ericson at 2022-06-02T15:42:59+00:00 Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq` As proposed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676, `GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and backend-specific (only for the bytecode interpreter), and mix entry writing is just for HPC. With this split we separate out those interpreter- and HPC-specific its, and keep the main `GHC.HsToCore.Ticks` agnostic. Also, instead of passing the reversed list and count around, we use `SizedSeq` which abstracts over the algorithm. This is much nicer to avoid noise and prevents bugs. (The bugs are not just hypothetical! I missed up the reverses on an earlier draft of this commit.) - - - - - 1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00 GHC.HsToCore.Breakpoints: Slightly improve perf We have the length already, so we might as well use that rather than O(n) recomputing it. - - - - - 5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00 HsToCore.Coverage: Purge DynFlags Finishes what !7467 (closed) started. Progress towards #17957 - - - - - 9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00 Deprecate TypeInType extension This commit fixes #20312 It deprecates "TypeInType" extension according to the following proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst It has been already implemented. The migration strategy: 1. Disable TypeInType 2. Enable both DataKinds and PolyKinds extensions Metric Decrease: T16875 - - - - - f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00 Diagnostics conversions, part 6 (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and `GHC.Tc.Gen.Sig`. - - - - - 04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00 Ensure floated dictionaries are in scope (again) In the Specialiser, we missed one more call to bringFloatedDictsIntoScope (see #21391). This omission led to #21689. The problem is that the call to `rewriteClassOps` needs to have in scope any dictionaries floated out of the arguments we have just specialised. Easy fix. - - - - - a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00 Don't print the number of deps in count-deps tests It is redundant information and a source of needless version control conflicts when multiple MRs are changing the deps list. Just printing the list and not also its length is fine. - - - - - a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00 Core.Lint: Reduce `DynFlags` and `HscEnv` Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com> - - - - - 56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00 Fix a CSE shadowing bug. We used to process the rhs of non-recursive bindings and their body using the same env. If we had something like let x = ... x ... this caused trouble because the two xs refer to different binders but we would substitute both for a new binder x2 causing out of scope errors. We now simply use two different envs for the rhs and body in cse_bind. It's all explained in the Note [Separate envs for let rhs and body] Fixes #21685 - - - - - 28880828 by sheaf at 2022-06-09T09:12:19-04:00 Typecheck remaining ValArgs in rebuildHsApps This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it to tcRemainingValArgs. The logic is moved to rebuildHsApps, which ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg. This patch also refactors the treatment of stupid theta for data constructors, changing the place we drop stupid theta arguments from dsConLike to mkDataConRep (now the datacon wrapper drops these arguments). We decided not to implement PHASE 2 of the FixedRuntimeRep plan for these remaining ValArgs. Future directions are outlined on the wiki: https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs Fixes #21544 and #21650 - - - - - 1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00 Add test for T21682 Fixes #21682 - - - - - 8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00 Document dataToTag# primop - - - - - 7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00 Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115 - - - - - 46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00 Fix TcRnPragmaWarning meaning - - - - - 69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00 getProcessCPUTime: Fix the getrusage fallback to account for system CPU time clock_gettime reports the combined total or user AND system time so in order to replicate it with getrusage we need to add both system and user time together. See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime Some sample measurements when building Cabal with this patch t1: rusage t2: clock_gettime t1: 62347518000; t2: 62347520873 t1: 62395687000; t2: 62395690171 t1: 62432435000; t2: 62432437313 t1: 62478489000; t2: 62478492465 t1: 62514990000; t2: 62514992534 t1: 62515479000; t2: 62515480327 t1: 62515485000; t2: 62515486344 Fixes #21656 - - - - - 722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00 Use <br> instead of newline character - - - - - dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00 Use (fixed_lev = True) in mkDataTyConRhs - - - - - ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00 hadrian: Fix testing stage1 compiler There were various issues with testing the stage1 compiler.. 1. The wrapper was not being built 2. The wrapper was picking up the stage0 package database and trying to load prelude from that. 3. The wrappers never worked on windows so just don't support that for now. Fixes #21072 - - - - - ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00 validate: Ensure that $make variable is set Currently the `$make` variable is used without being set in `validate`'s Hadrian path, which uses make to install the binary distribution. Fix this. Fixes #21687. - - - - - 59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00 CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv` The call sites in `Driver.Main` are duplicative, but this is good, because the next step is to remove `InteractiveContext` from `Core.Lint` into `Core.Lint.Interactive`. Also further clean up `Core.Lint` to use a better configuration record than the one we initially added. - - - - - aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00 hadrian: Run xattr -rc . on bindist tarball Fixes #21506. - - - - - cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00 configure: Hide spurious warning from ld Previously the check_for_gold_t22266 configure check could result in spurious warnings coming from the linker being blurted to stderr. Suppress these by piping stderr to /dev/null. - - - - - e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00 cmm: Add surface syntax for MO_MulMayOflo - - - - - bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00 configure: Don't attempt to override linker on Darwin Configure's --enable-ld-override functionality is intended to ensure that we don't rely on ld.bfd, which tends to be slow and buggy, on Linux and Windows. However, on Darwin the lack of sensible package management makes it extremely easy for users to have awkward mixtures of toolchain components from, e.g., XCode, the Apple Command-Line Tools package, and homebrew. This leads to extremely confusing problems like #21712. Here we avoid this by simply giving up on linker selection on Darwin altogether. This isn't so bad since the Apple ld64 linker has decent performance and AFAICT fairly reliable. Closes #21712. - - - - - 25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00 replace quadratic nub to fight byte code gen perf explosion Despite this code having been present in the core-to-bytecode implementation, I have observed it in the wild starting with 9.2, causing enormous slowdown in certain situations. My test case produces the following profiles: Before: ``` total time = 559.77 secs (559766 ticks @ 1000 us, 1 processor) total alloc = 513,985,665,640 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes elem_by Data.OldList libraries/base/Data/OldList.hs:429:1-7 67.6 92.9 378282 477447404296 eqInt GHC.Classes libraries/ghc-prim/GHC/Classes.hs:275:8-14 12.4 0.0 69333 32 $c>>= GHC.Data.IOEnv <no location info> 6.9 0.6 38475 3020371232 ``` After: ``` total time = 89.83 secs (89833 ticks @ 1000 us, 1 processor) total alloc = 39,365,306,360 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes $c>>= GHC.Data.IOEnv <no location info> 43.6 7.7 39156 3020403424 doCase GHC.StgToByteCode compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53) 2.5 7.4 2246 2920777088 ``` - - - - - aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00 hadrian: Don't install `include/` directory in bindist. The install_includes for the RTS package used to be put in the top-level ./include folder but this would lead to confusing things happening if you installed multiple GHC versions side-by-side. We don't need this folder anymore because install-includes is honoured properly by cabal and the relevant header files already copied in by the cabal installation process. If you want to depend on the header files for the RTS in a Haskell project then you just have to depend on the `rts` package and the correct include directories will be provided for you. If you want to depend on the header files in a standard C project then you should query ghc-pkg to get the right paths. ``` ghc-pkg field rts include-dirs --simple-output ``` Fixes #21609 - - - - - 03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00 Enable eventlogs on nightly perf job - - - - - ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00 Repair dead link in TH haddocks Closes #21724 - - - - - 99ff3818 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian: allow configuring Hsc2Hs This patch adds the ability to pass options to Hsc2Hs as Hadrian key/value settings, in the same way as cabal configure options, using the syntax: *.*.hsc2hs.run.opts += ... - - - - - 9c575f24 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian bootstrap: look up hsc2hs Hadrian bootstrapping looks up where to find ghc_pkg, but the same logic was not in place for hsc2hs which meant we could fail to find the appropriate hsc2hs executabe when bootstrapping Hadrian. This patch adds that missing logic. - - - - - 229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Add (broken) test for #21622 - - - - - cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Don't Box NULL pointers Previously we could construct a `Box` of a NULL pointer from the `link` field of `StgWeak`. Now we take care to avoid ever introducing such pointers in `collect_pointers` and ensure that the `link` field is represented as a `Maybe` in the `Closure` type. Fixes #21622 - - - - - 31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00 winio: Add support to console handles to handleToHANDLE - - - - - 711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Add SMUL[LH] instructions These will be needed to fix #21624. - - - - - d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Fix syntax of OpRegShift operands Previously this produced invalid assembly containing a redundant comma. - - - - - a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00 ncg/aarch64: Fix implementation of IntMulMayOflo The code generated for IntMulMayOflo was previously wrong as it depended upon the overflow flag, which the AArch64 MUL instruction does not set. Fix this. Fixes #21624. - - - - - 26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00 testsuite: Add test for #21624 Ensuring that mulIntMayOflo# behaves as expected. - - - - - 94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00 CprAnal: Set signatures of DFuns to top The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal that is observable in a debug build. The CPR signature of a recursive DFunId was never updated and hence the optimistic arity 0 bottom signature triggered a mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any code because WW doesn't exploit bottom CPR signatures. - - - - - b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00 CorePrep: Don't speculatively evaluate recursive calls (#20836) In #20836 we have optimised a terminating program into an endless loop, because we speculated the self-recursive call of a recursive DFun. Now we track the set of enclosing recursive binders in CorePrep to prevent speculation of such self-recursive calls. See the updates to Note [Speculative evaluation] for details. Fixes #20836. - - - - - 49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00 Simplify: Take care with eta reduction in recursive RHSs (#21652) Similar to the fix to #20836 in CorePrep, we now track the set of enclosing recursive binders in the SimplEnv and SimpleOptEnv. See Note [Eta reduction in recursive RHSs] for details. I also updated Note [Arity robustness] with the insights Simon and I had in a call discussing the issue. Fixes #21652. Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation of a large list literal at the top-level that didn't happen before (presumably because it was too interesting to float to the top-level). There's not much we can do about that. Metric Increase: T16577 - - - - - 2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00 Ignore .hie-bios - - - - - e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00 Instantiate top level foralls in partial type signatures The main fix for #21667 is the new call to tcInstTypeBnders in tcHsPartialSigType. It was really a simple omission before. I also moved the decision about whether we need to apply the Monomorphism Restriction, from `decideGeneralisationPlan` to `tcPolyInfer`. That removes a flag from the InferGen constructor, which is good. But more importantly, it allows the new function, checkMonomorphismRestriction called from `tcPolyInfer`, to "see" the `Types` involved rather than the `HsTypes`. And that in turn matters because we invoke the MR for partial signatures if none of the partial signatures in the group have any overloading context; and we can't answer that question for HsTypes. See Note [Partial type signatures and the monomorphism restriction] in GHC.Tc.Gen.Bind. This latter is really a pre-existing bug. - - - - - 262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00 Make Outputable instance for InlineSig print the InlineSpec Fix ghc/ghc#21739 Squash fix ghc/ghc#21739 - - - - - b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00 Add NO_BOOT to hackage_doc_tarball job We were attempting to boot a src-tarball which doesn't work as ./boot is not included in the source tarball. This slipped through as the job is only run on nightly. - - - - - d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00 HsToken for @-patterns and TypeApplications (#19623) One more step towards the new design of EPA. - - - - - 159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00 linker: only keep rtl exception tables if they have been relocated - - - - - da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00 Ticky:Make json info a separate field. - - - - - 1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00 Revert "Ticky:Make json info a separate field." This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862. This was pushed directly without review. - - - - - f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00 Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags These flags affect the behaviour of local let floating. If `-flocal-float-out` is disabled (the default) then we disable all local floating. ``` …(let x = let y = e in (a,b) in body)... ===> …(let y = e; x = (a,b) in body)... ``` Further to this, top-level local floating can be disabled on it's own by passing -fno-local-float-out-top-level. ``` x = let y = e in (a,b) ===> y = e; x = (a,b) ``` Note that this is only about local floating, ie, floating two adjacent lets past each other and doesn't say anything about the global floating pass which is controlled by `-fno-float`. Fixes #13663 - - - - - 4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00 Check for Int overflows in Data.Array.Byte - - - - - 2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00 Add a basic test for ByteArray's Monoid instance - - - - - fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00 Rename `copyByteArray` to `unsafeCopyByteArray` - - - - - ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00 testsuite: Add test for #21719 Happily, this has been fixed since 9.2. - - - - - 19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Use lookupNameCache instead of lookupOrigIO - - - - - 4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Break out thNameToGhcNameIO (ref. #21730) - - - - - eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00 Add laws for 'toInteger' and 'toRational' CLC discussion here: https://github.com/haskell/core-libraries-committee/issues/58 - - - - - c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00 Correct documentation of defaults of the `-V` RTS option - - - - - b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00 Transcribe discussion from #21483 into a Note In #21483 I had a discussion with Simon Marlow about the memory retention behaviour of -Fd. I have just transcribed that conversation here as it elucidates the potentially subtle assumptions which led to the design of the memory retention behaviours of -Fd. Fixes #21483 - - - - - 980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00 eventlog: Don't leave dangling pointers hanging around Previously we failed to reset pointers to various eventlog buffers to NULL after freeing them. In principle we shouldn't look at them after they are freed but nevertheless it is good practice to set them to a well-defined value. - - - - - 575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00 runhaskell - - - - - e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00 re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45 - - - - - 5d45aa97 by Gergo ERDI at 2022-06-22T22:00:46-04:00 When specialising, look through floatable ticks. Fixes #21697. - - - - - 531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00 TagCheck.hs: Properly check if arguments are boxed types. For one by mistake I had been checking against the kind of runtime rep instead of the boxity. This uncovered another bug, namely that we tried to generate the checking code before we had associated the function arguments with a register, so this could never have worked to begin with. This fixes #21729 and both of the above issues. - - - - - c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00 Use correct arch for the FreeBSD triple in gen-data-layout.sh Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798 Relevant upstream issue: #15718 - - - - - 75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00 Bump nofib submodule. Allows the shake runner to build with 9.2.3 among other things. Fixes #21772 - - - - - 0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00 Bump ghc-prim and base versions To 0.9.0 and 4.17.0 respectively. Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm, terminfo, text, unix, haddock, and hsc2hs submodules. (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095) - - - - - 4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00 testsuite: Use normalise_version more consistently Previously several tests' output were unnecessarily dependent on version numbers, particularly of `base`. Fix this. - - - - - d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00 linters: Fix lint-submodule-refs when crashing trying to find plausible branches - - - - - 38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 hadrian: Improve haddocks for ghcDebugAssertions - - - - - ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 Don't mark lambda binders as OtherCon We used to put OtherCon unfoldings on lambda binders of workers and sometimes also join points/specializations with with the assumption that since the wrapper would force these arguments once we execute the RHS they would indeed be in WHNF. This was wrong for reasons detailed in #21472. So now we purge evaluated unfoldings from *all* lambda binders. This fixes #21472, but at the cost of sometimes not using as efficient a calling convention. It can also change inlining behaviour as some occurances will no longer look like value arguments when they did before. As consequence we also change how we compute CBV information for arguments slightly. We now *always* determine the CBV convention for arguments during tidy. Earlier in the pipeline we merely mark functions as candidates for having their arguments treated as CBV. As before the process is described in the relevant notes: Note [CBV Function Ids] Note [Attaching CBV Marks to ids] Note [Never put `OtherCon` unfoldigns on lambda binders] ------------------------- Metric Decrease: T12425 T13035 T18223 T18223 T18923 MultiLayerModulesTH_OneShot Metric Increase: WWRec ------------------------- - - - - - 06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00 Add suggestions for unrecognised pragmas (#21589) In case of a misspelled pragma, offer possible corrections as to what the user could have meant. Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589 - - - - - 3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00 Remove the traces of i386-*-openbsd, long live amd64 OpenBSD will not ship any ghc packages on i386 starting with 7.2 release. This means there will not be a bootstrap compiler easily available. The last available binaries are ghc-8.10.6 which is already not supported as bootstrap for HEAD. See here for more information: https://marc.info/?l=openbsd-ports&m=165060700222580&w=2 - - - - - 58530271 by Bodigrim at 2022-06-27T08:03:34-04:00 Add Foldable1 and Bifoldable1 type classes Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9 Instances roughly follow https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1 but the API of `Foldable1` was expanded in comparison to `semigroupoids`. Compatibility shim is available from https://github.com/phadej/foldable1 (to be released). Closes #13573. - - - - - a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00 add levity polymorphism to addrToAny# - - - - - f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00 add tests for addrToAny# levity - - - - - 07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00 hadrian: Update main README page This README had some quite out-of-date content about the build system so I did a complete pass deleting old material. I also made the section about flavours more prominent and mentioned flavour transformers. - - - - - 79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00 testsuite: Hide output from test compilations with verbosity==2 Previously the output from test compilations used to determine whether, e.g., profiling libraries are available was shown with verbosity levels >= 2. However, the default level is 2, meaning that most users were often spammed with confusing errors. Fix this by bumping the verbosity threshold for this output to >=3. Fixes #21760. - - - - - 995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00 configure: Only probe for LD in FIND_LD Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD rather early in `configure`. However, it turns out that this breaks `configure`'s `ld`-override logic, which assumes that `LD` was set by the user and aborts. Fixes #21778. - - - - - b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00 `.hs-boot` make rules: add missing order-only dependency on target directory Noticed missing target directory dependency as a build failure in `make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100): "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254 make: *** [Makefile:128: all] Error 2 shuffle=1656129254 Note that `cp` complains about inability to create target file. The change adds order-only dependency on a target directory (similar to the rest of rules in that file). The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build system megapatch`.) where upfront directory creation was never added to `.hs-boot` files. - - - - - 57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00 Mark AArch64/Darwin as requiring sign-extension Apple's AArch64 ABI requires that the caller sign-extend small integer arguments. Set platformCConvNeedsExtension to reflect this fact. Fixes #21773. - - - - - df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00 -ddump-llvm shouldn't imply -fllvm Previously -ddump-llvm would change the backend used, which contrasts with all other dump flags. This is quite surprising and cost me quite a bit of time. Dump flags should not change compiler behavior. Fixes #21776. - - - - - 70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Re-format argument handling logic Previously there were very long, hard to parse lines. Fix this. - - - - - 696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Sign-extend narrow C arguments The AArch64/Darwin ABI requires that function arguments narrower than 32-bits must be sign-extended by the caller. We neglected to do this, resulting in #20735. Fixes #20735. - - - - - c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00 testsuite: Add test for #20735 - - - - - 16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00 integer-gmp: Fix cabal file Evidently fields may not come after sections in a cabal file. - - - - - 03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00 ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist) before the change `make install` was failing as: ``` "mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc" make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'. Stop. ``` I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf` is created (somewhat manually), but not the .install varianlt of it. The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere. Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784 - - - - - eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00 Comments only, about join points This MR just adds some documentation about why casts destroy join points, following #21716. - - - - - 251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00 Cleanup BuiltInSyntax vs UserSyntax There was some confusion about whether FUN/TYPE/One/Many should be BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as BuiltInSyntax is for things which are directly constructed by the parser rather than going through normal renaming channels. I fixed all the obviously wrong places I could find and added a test for the original bug which was caused by this (#21752) Fixes #21752 #20695 #18302 - - - - - 0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00 template-haskell: Bump version to 2.19.0.0 Bumps text and exceptions submodules due to bounds. - - - - - bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00 Tiny tweak to `IOPort#` documentation The exclamation mark and bracket don’t seem to make sense here. I’ve looked through the history, and I don’t think they’re deliberate – possibly a copy-and-paste error. - - - - - 70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00 Remove `CoreOccurAnal` constructor of the `CoreToDo` type It was dead code since the last occurence in an expression context got removed in 71916e1c018dded2e68d6769a2dbb8777da12664. - - - - - d0722170 by nineonine at 2022-07-01T08:15:56-04:00 Fix panic with UnliftedFFITypes+CApiFFI (#14624) When declaring foreign import using CAPI calling convention, using unlifted unboxed types would result in compiler panic. There was an attempt to fix the situation in #9274, however it only addressed some of the ByteArray cases. This patch fixes other missed cases for all prims that may be used as basic foreign types. - - - - - eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00 rts: gc stats: account properly for copied bytes in sequential collections We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow] counters during sequential collections. As well, we were double counting for parallel collections. To fix this we add an `else` clause to the `if (is_par_gc())`. The par_* counters do not need to be updated in the sequential case because they must be 0. - - - - - f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00 desugar: Look through ticks when warning about possible literal overflow Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up between the appliation of `neg` to its argument. This defeated the special logic which looks for `NegApp ... (HsOverLit` to warn about possible overflow if a user writes a negative literal (without out NegativeLiterals) in their code. Fixes #21701 - - - - - f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00 ci: Fix definition of slow-validate flavour (so that -dlint) is passed In this embarassing sequence of events we were running slow-validate without -dlint. - - - - - bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00 Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411 - - - - - 9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00 Data.Foldable1: Remove references to Foldable-specific note ...as discussed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455. - - - - - 3a8970ac by romes at 2022-07-03T14:11:31-04:00 TTG: Move HsModule to L.H.S Move the definition of HsModule defined in GHC.Hs to Language.Haskell.Syntax with an added TTG parameter and corresponding extension fields. This is progress towards having the haskell-syntax package, as described in #21592 - - - - - f9f80995 by romes at 2022-07-03T14:11:31-04:00 TTG: Move ImpExp client-independent bits to L.H.S.ImpExp Move the GHC-independent definitions from GHC.Hs.ImpExp to Language.Haskell.Syntax.ImpExp with the required TTG extension fields such as to keep the AST independent from GHC. This is progress towards having the haskell-syntax package, as described in #21592 Bumps haddock submodule - - - - - c43dbac0 by romes at 2022-07-03T14:11:31-04:00 Refactor ModuleName to L.H.S.Module.Name ModuleName used to live in GHC.Unit.Module.Name. In this commit, the definition of ModuleName and its associated functions are moved to Language.Haskell.Syntax.Module.Name according to the current plan towards making the AST GHC-independent. The instances for ModuleName for Outputable, Uniquable and Binary were moved to the module in which the class is defined because these instances depend on GHC. The instance of Eq for ModuleName is slightly changed to no longer depend on unique explicitly and instead uses FastString's instance of Eq. - - - - - 2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00 Expand `Ord` instance for `Down` Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610 - - - - - 36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00 Add applyWhen to Data.Function per CLC prop Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233 - - - - - 3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00 hadrian: Don't read package environments in ghc-stage1 wrapper The stage1 compiler may be on the brink of existence and not have even a working base library. You may have installed packages globally with a similar stage2 compiler which will then lead to arguments such as --show-iface not even working because you are passing too many package flags. The solution is simple, don't read these implicit files. Fixes #21803 - - - - - aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00 Ticky:Make json info a separate field. Fixes #21233 - - - - - 74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00 Add docs:<pkg> command to hadrian to build docs for just one package - - - - - 418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00 upload-docs: propagate publish correctly in upload_sdist - - - - - ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00 docs-upload: Fix upload script when no packages are listed - - - - - d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00 hadrian: Add --haddock-base-url option for specifying base-url when generating docs The motiviation for this flag is to be able to produce documentation which is suitable for uploading for hackage, ie, the cross-package links work correctly. There are basically three values you want to set this to: * off - default, base_url = ../%pkg% which works for local browsing * on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload * on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation. The `%pkg%` string is a template variable which is replaced with the package identifier for the relevant package. This is one step towards fixing #21749 - - - - - 41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00 Add nightly job for generating docs suitable for hackage upload - - - - - 620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00 ghci: Support :set prompt in multi repl This adds supports for various :set commands apart from `:set <FLAG>` in multi repl, this includes `:set prompt` and so-on. Fixes #21796 - - - - - b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00 Vendor filepath inside template-haskell Adding filepath as a dependency of template-haskell means that it can't be reinstalled if any build-plan depends on template-haskell. This is a temporary solution for the 9.4 release. A longer term solution is to split-up the template-haskell package into the wired-in part and a non-wired-in part which can be reinstalled. This was deemed quite risky on the 9.4 release timescale. Fixes #21738 - - - - - c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00 Factor fields of `CoreDoSimplify` into separate data type This avoids some partiality. The work @mmhat is doing cleaning up and modularizing `Core.Opt` will build on this nicely. - - - - - d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00 https urls - - - - - 803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00 options and typos - - - - - 5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00 grammar - - - - - 4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00 sources - - - - - c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00 Fix lint warnings in bootstrap.py - - - - - 86ced2ad by romes at 2022-07-06T01:36:23-04:00 Restore Eq instance of ImportDeclQualifiedStyle Fixes #21819 - - - - - 3547e264 by romes at 2022-07-06T13:50:27-04:00 Prune L.H.S modules of GHC dependencies Move around datatypes, functions and instances that are GHC-specific out of the `Language.Haskell.Syntax.*` modules to reduce the GHC dependencies in them -- progressing towards #21592 Creates a module `Language.Haskell.Syntax.Basic` to hold basic definitions required by the other L.H.S modules (and don't belong in any of them) - - - - - e4eea07b by romes at 2022-07-06T13:50:27-04:00 TTG: Move CoreTickish out of LHS.Binds Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and move them to the extension point instance, according to the plan outlined in #21592 to separate the base AST from the GHC specific bits. - - - - - acc1816b by romes at 2022-07-06T13:50:27-04:00 TTG for ForeignImport/Export Add a TTG parameter to both `ForeignImport` and `ForeignExport` and, according to #21592, move the GHC-specific bits in them and in the other AST data types related to foreign imports and exports to the TTG extension point. - - - - - 371c5ecf by romes at 2022-07-06T13:50:27-04:00 TTG for HsTyLit Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText` fields to the extension point and out of the base AST. Progress towards #21592 - - - - - fd379d1b by romes at 2022-07-06T13:50:27-04:00 Remove many GHC dependencies from L.H.S Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC imports according to the plan in the linked issue. Moves more GHC-specific declarations to `GHC.*` and brings more required GHC-independent declarations to `Language.Haskell.Syntax.*` (extending e.g. `Language.Haskell.Syntax.Basic`). Progress towards #21592 Bump haddock submodule for !8308 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00 Fix exact printing of the HsRule name Prior to this branch, the HsRule name was XRec pass (SourceText,RuleName) and there is an ExactPrint instance for (SourceText, RuleName). The SourceText has moved to a different location, so synthesise the original to trigger the correct instance when printing. We need both the SourceText and RuleName when exact printing, as it is possible to have a NoSourceText variant, in which case we fall back to the FastString. - - - - - 665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00 driver: Fix issue with module loops and multiple home units We were attempting to rehydrate all dependencies of a particular module, but we actually only needed to rehydrate those of the current package (as those are the ones participating in the loop). This fixes loading GHC into a multi-unit session. Fixes #21814 - - - - - bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00 Remove a bogus #define from ClosureMacros.h - - - - - fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00 winio: make consoleReadNonBlocking not wait for any events at all. - - - - - 42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00 rts: allow NULL to be used as an invalid StgStablePtr - - - - - 3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00 RTS: Add stack marker to StgCRunAsm.S Every object file must be properly marked for non-executable stack, even if it contains no code. - - - - - a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00 Bump unix submodule Adds `config.sub` to unix's `.gitignore`, fixing #19574. - - - - - 3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00 ghci: Fix most calls to isLoaded to work in multi-mode The most egrarious thing this fixes is the report about the total number of loaded modules after starting a session. Ticket #20889 - - - - - fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00 Enable :edit command in ghci multi-mode. This works after the last change to isLoaded. Ticket #20888 - - - - - 46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00 Fix a scoping bug in the Specialiser In the call to `specLookupRule` in `already_covered`, in `specCalls`, we need an in-scope set that includes the free vars of the arguments. But we simply were not guaranteeing that: did not include the `rule_bndrs`. Easily fixed. I'm not sure how how this bug has lain for quite so long without biting us. Fixes #21828. - - - - - 6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Edit Note [idArity varies independently of dmdTypeDepth] ...and refer to it in GHC.Core.Lint.lintLetBind. Fixes #21452 - - - - - 89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Tiny documentation wibbles (comments only) - - - - - 61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix readme - - - - - 61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix bootstrap - - - - - 8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00 tarball - - - - - e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Fix scopes for deriving clauses and instance signatures (#18425) - - - - - c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Record location of filled in default method bindings This is useful for hie files to reconstruct the evidence that default methods depend on. - - - - - 9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00 testsuite: Factor out common parts from hiefile tests - - - - - 6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00 Hadrian: update documentation of settings The documentation for key-value settings was a bit out of date. This patch updates it to account for `cabal.configure.opts` and `hsc2hs.run.opts`. The user-settings document was also re-arranged, to make the key-value settings more prominent (as it doesn't involve changing the Hadrian source code, and thus doesn't require any recompilation of Hadrian). - - - - - a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00 Fix potential space leak that arise from ModuleGraphs retaining references to previous ModuleGraphs, in particular the lazy `mg_non_boot` field. This manifests in `extendMG`. Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which is only called in two places in the compiler, and should only be called at most once for every home unit: GHC.Driver.Make: mainModuleSrcPath :: Maybe String mainModuleSrcPath = do ms <- mgLookupModule mod_graph (mainModIs hue) ml_hs_file (ms_location ms) GHCI.UI: listModuleLine modl line = do graph <- GHC.getModuleGraph let this = GHC.mgLookupModule graph modl Instead `mgLookupModule` can be a linear function that looks through the entire list of `ModuleGraphNodes` Fixes #21816 - - - - - dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00 rts: Fix AdjustorPool bitmap manipulation Previously the implementation of bitmap_first_unset assumed that `__builtin_clz` would accept `uint8_t` however it apparently rather extends its argument to `unsigned int`. To fix this we simply revert to a naive implementation since handling the various corner cases with `clz` is quite tricky. This should be fine given that AdjustorPool isn't particularly hot. Ideally we would have a single, optimised bitmap implementation in the RTS but I'll leave this for future work. Fixes #21838. - - - - - ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00 Change GHCi bytecode return convention for unlifted datatypes. This changes the bytecode return convention for unlifted algebraic datatypes to be the same as for lifted types, i.e. ENTER/PUSH_ALTS instead of RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED Fixes #20849 - - - - - 5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00 Compute record-dot-syntax types Ensures type information for record-dot-syntax is included in HieASTs. See #21797 - - - - - 89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00 Add record-dot-syntax test - - - - - 4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00 Document RuntimeRep polymorphism limitations of catch#, et al As noted in #21868, several primops accepting continuations producing RuntimeRep-polymorphic results aren't nearly as polymorphic as their types suggest. Document this limitation and adapt the `UnliftedWeakPtr` test to avoid breaking this limitation in `keepAlive#`. - - - - - 4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00 Make keepAlive# out-of-line This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203 - - - - - 1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00 Suppress extra output from configure check for c++ libraries - - - - - 3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00 rel-notes: Drop mention of #21745 fix Since we have backported the fix to 9.4.1. - - - - - b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00 Align the behaviour of `dopt` and `log_dopt` Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying function `log_dopt`) were different as the latter did not take the verbosity level into account. This led to problems during the refactoring as we cannot simply replace calls to `dopt` with calls to `logHasDumpFlag`. In addition to that a subtle bug in the GHC module was fixed: `setSessionDynFlags` did not update the logger and as a consequence the verbosity value of the logger was not set appropriately. Fixes #21861 - - - - - 28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00 rts: forkOn context switches the target capability Fixes #21824 - - - - - f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Eliminate orphan Outputable instances Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and `OutputableP` instances for the Cmm AST. This makes it significantly easier to use the Cmm pretty-printers in tracing output without incurring module import cycles. - - - - - f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Move toBlockList to GHC.Cmm - - - - - fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00 compiler: Add haddock sections to GHC.Utils.Panic - - - - - 097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00 configure: Don't override Windows CXXFLAGS At some point we used the clang distribution from msys2's `MINGW64` environment for our Windows toolchain. This defaulted to using libgcc and libstdc++ for its runtime library. However, we found for a variety of reasons that compiler-rt, libunwind, and libc++ were more reliable, consequently we explicitly overrode the CXXFLAGS to use these. However, since then we have switched to use the `CLANG64` packaging, which default to these already. Consequently we can drop these arguments, silencing some redundant argument warnings from clang. Fixes #21669. - - - - - e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Check that there are no NULL ctors - - - - - 616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Introduce support for invoking finalizers on unload Addresses #20494. - - - - - cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add T20494 - - - - - 03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Rename finit field to fini fini is short for "finalizer", which does not contain a "t". - - - - - 033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Refactor handling of oc->info Previously we would free oc->info after running initializers. However, we can't do this is we want to also run finalizers. Moreover, freeing oc->info so early was wrong for another reason: we will need it in order to unregister the exception tables (see the call to `RtlDeleteFunctionTable`). In service of #20494. - - - - - f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Add finalization support This implements #20494 for the PEi386 linker. Happily, this also appears to fix `T9405`, resolving #21361. - - - - - 2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00 Loader: Implement gnu-style -l:$path syntax Gnu ld allows `-l` to be passed an absolute file path, signalled by a `:` prefix. Implement this in the GHC's loader search logic. - - - - - 5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00 Statically-link against libc++ on Windows Unfortunately on Windows we have no RPATH-like facility, making dynamic linking extremely fragile. Since we cannot assume that the user will add their GHC installation to `$PATH` (and therefore their DLL search path) we cannot assume that the loader will be able to locate our `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on Windows. Fixes #21435. - - - - - 8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run It turns out that PE objects may have multiple `.ctors`/`.dtors` sections but the RTS linker had assumed that there was only one. Fix this. Fixes #21618. - - - - - fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Respect dtor/ctor priority Previously we would run constructors and destructors in arbitrary order despite explicit priorities. Fixes #21847. - - - - - 1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add test for #21618 and #21847 - - - - - 6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Fix exception unwind unregistration RtlDeleteFunctionTable expects a pointer to the .pdata section yet we passed it the .xdata section. Happily, this fixes #21354. - - - - - d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Drop dead code - - - - - d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Use section flags to identify initializers - - - - - fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Introduce finalizer support - - - - - 5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl - - - - - 6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker/Elf: Work around GCC 6 init/fini behavior It appears that GCC 6t (at least on i386) fails to give init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY section types, instead marking them as SHT_PROGBITS. This caused T20494 to fail on Debian. - - - - - 5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Mark T13366Cxx as unbroken on Darwin - - - - - 1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Fix resolution of __dso_handle on Darwin Darwin expects a leading underscore. - - - - - a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Clean up section kinds - - - - - aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Ensure that __cxa_finalize is called on code unload - - - - - 028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00 testsuite: Fix T11829 on Centos 7 It appears that Centos 7 has a more strict C++ compiler than most distributions since std::runtime_error is defined in <stdexcept> rather than <exception>. In T11829 we mistakenly imported the latter. - - - - - a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00 hadrian: Rename documentation directories for consistency with make * Rename `docs` to `doc` * Place pdf documentation in `doc/` instead of `doc/pdfs/` Fixes #21164. - - - - - b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00 Fix incorrect proof of applyWhen’s properties - - - - - eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00 hadrian: Add multi:<pkg> and multi targets for starting a multi-repl This patch adds support to hadrian for starting a multi-repl containing all the packages which stage0 can build. In particular, there is the new user-facing command: ``` ./hadrian/ghci-multi ``` which when executed will start a multi-repl containing the `ghc` package and all it's dependencies. This is implemented by two new hadrian targets: ``` ./hadrian/build multi:<pkg> ``` Construct the arguments for a multi-repl session where the top-level package is <pkg>. For example, `./hadrian/ghci-multi` is implemented using `multi:ghc` target. There is also the `multi` command which constructs a repl for everything in stage0 which we can build. - - - - - 19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00 changelog typo - - - - - af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00 typos - - - - - 415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00 Refactor SpecConstr to use treat bindings uniformly This patch, provoked by #21457, simplifies SpecConstr by treating top-level and nested bindings uniformly (see the new scBind). * Eliminates the mysterious scTopBindEnv * Refactors scBind to handle top-level and nested definitions uniformly. * But, for now at least, continues the status quo of not doing SpecConstr for top-level non-recursive bindings. (In contrast we do specialise nested non-recursive bindings, although the original paper did not; see Note [Local let bindings].) I tried the effect of specialising top-level non-recursive bindings (which is now dead easy to switch on, unlike before) but found some regressions, so I backed off. See !8135. It's a pure refactoring. I think it'll do a better job in a few cases, but there is no regression test. - - - - - d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00 Rule matching: Don't compute the FVs if we don't look at them. - - - - - 5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 White space only in FamInstEnv - - - - - ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make transferPolyIdInfo work for CPR I don't know why this hasn't bitten us before, but it was plain wrong. - - - - - 9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Inline mapAccumLM This function is called in inner loops in the compiler, and it's overloaded and higher order. Best just to inline it. This popped up when I was looking at something else. I think perhaps GHC is delicately balanced on the cusp of inlining this automatically. - - - - - d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make SetLevels honour floatConsts This fix, in the definition of profitableFloat, is just for consistency. `floatConsts` should do what it says! I don't think it'll affect anything much, though. - - - - - d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Refactor wantToUnboxArg a bit * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg and similarly wantToUnboxResult to canUnboxResult. * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg, avoiding some yukky duplication. I decided it was clearer to give it a new data type for its return type, because I nedeed the FD_RecBox case which was not otherwise readiliy expressible. * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload * Get rid of the Unlift constructor of UnboxingDecision, eliminate two panics, and two arguments to canUnboxArg (new name). Much nicer now. - - - - - 6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00 Allow running memInventory when the concurrent nonmoving gc is enabled If the nonmoving gc is enabled and we are using a threaded RTS, we now try to grab the collector mutex to avoid memInventory and the collection racing. Before memInventory was disabled. - - - - - aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00 gitignore: don't ignore all aclocal.m4 files While GHC's own aclocal.m4 is generated by the aclocal tool, other packages' aclocal.m4 are committed in the repository. Previously `.gitignore` included an entry which covered *any* file named `aclocal.m4`, which lead to quite some confusion (e.g. see #21740). Fix this by modifying GHC's `.gitignore` to only cover GHC's own `aclocal.m4`. - - - - - 4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00 Add mapAccumM, forAccumM to Data.Traversable Approved by Core Libraries Committee in https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433 - - - - - bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00 configure: Use AC_PATH_TOOL to detect tools Previously we used AC_PATH_PROG which, as noted by #21601, does not look for tools with a target prefix, breaking cross-compilation. Fixes #21601. - - - - - e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00 driver: Fix implementation of -S We were failing to stop before running the assembler so the object file was also created. Fixes #21869 - - - - - e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00 rts/ProfHeap: Ensure new Censuses are zeroed When growing the Census array ProfHeap previously neglected to zero the new part of the array. Consequently `freeEra` would attempt to free random words that often looked suspiciously like pointers. Fixes #21880. - - - - - 81d65f7f by sheaf at 2022-07-21T15:37:22+02:00 Make withDict opaque to the specialiser As pointed out in #21575, it is not sufficient to set withDict to inline after the typeclass specialiser, because we might inline withDict in one module and then import it in another, and we run into the same problem. This means we could still end up with incorrect runtime results because the typeclass specialiser would assume that distinct typeclass evidence terms at the same type are equal, when this is not necessarily the case when using withDict. Instead, this patch introduces a new magicId, 'nospec', which is only inlined in CorePrep. We make use of it in the definition of withDict to ensure that the typeclass specialiser does not common up distinct typeclass evidence terms. Fixes #21575 - - - - - 9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00 Refactored Simplify pass * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify namespace and GHC.Core.Opt.Stats. Also removed services from configuration records. * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration. * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm` and moved the Simplify driver to GHC.Core.Opt.Simplify. * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env. * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment in GHC.Core.Opt.Simplify.Monad. * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions for those in a new module GHC.Driver.Config.Core.Opt.Simplify. Also added initialization functions for `SimplMode` to that module. * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types and the counting types and functions (`SimplCount` and `Tick`) to new module GHC.Core.Opt.Stats. * Added getter functions for the fields of `SimplMode`. The pedantic bottoms option and the platform are retrieved from the ArityOpts and RuleOpts and the getter functions allow us to retrieve values from `SpecEnv` without the knowledge where the data is stored exactly. * Moved the coercion optimization options from the top environment to `SimplMode`. This way the values left in the top environment are those dealing with monadic functionality, namely logging, IO related stuff and counting. Added a note "The environments of the Simplify pass". * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead. * Prep work before removing `InteractiveContext` from `HscEnv`. - - - - - 2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00 Make the specialiser deal better with specialised methods This patch fixes #21848, by being more careful to update unfoldings in the type-class specialiser. See the new Note [Update unfolding after specialisation] Now that we are being so much more careful about unfoldings, it turned out that I could dispense with se_interesting, and all its tricky corners. Hooray. This fixes #21368. - - - - - ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00 ghc-boot: Clean up UTF-8 codecs In preparation for moving the UTF-8 codecs into `base`: * Move them to GHC.Utils.Encoding.UTF8 * Make names more consistent * Add some Haddocks - - - - - e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00 base: Introduce GHC.Encoding.UTF8 Here we copy a subset of the UTF-8 implementation living in `ghc-boot` into `base`, with the intent of dropping the former in the future. For this reason, the `ghc-boot` copy is now CPP-guarded on `MIN_VERSION_base(4,18,0)`. Naturally, we can't copy *all* of the functions defined by `ghc-boot` as some depend upon `bytestring`; we rather just copy those which only depend upon `base` and `ghc-prim`. Further consolidation? ---------------------- Currently GHC ships with at least five UTF-8 implementations: * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this can be used at a number of types including `Addr#`, `ByteArray#`, `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this can be removed in GHC 9.6+2, when the copies in `base` will become available to `ghc-boot`. * the copy of the `ghc-boot` definition now exported by `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`, `ByteArray#`, and `ForeignPtr` * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`; this is specialised at `Addr#`. * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`; this is specialised at `Addr#` but, unlike the above, supports recovery in the presence of partial codepoints (since in IO contexts codepoints may be broken across buffers) * the implementation provided by the `text` library This does seem a tad silly. On the other hand, these implementations *do* materially differ from one another (e.g. in the types they support, the detail in errors they can report, and the ability to recover from partial codepoints). Consequently, it's quite unclear that further consolidate would be worthwhile. - - - - - f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00 Add a Note summarising GHC's UTF-8 implementations GHC has a somewhat dizzying array of UTF-8 implementations. This note describes why this is the case. - - - - - 72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00 upload_ghc_libs: Fix path to documentation The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35 but this one occurrence was note updated. Finally closes #21164. - - - - - a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00 Add test for #21871 This adds a test for #21871, which was fixed by the No Skolem Info rework (MR !7105). Fixes #21871 - - - - - 6379f942 by sheaf at 2022-07-22T08:18:46-04:00 Add test for #21360 The way record updates are typechecked/desugared changed in MR !7981. Because we desugar in the typechecker to a simple case expression, the pattern match checker becomes able to spot the long-distance information and avoid emitting an incorrect pattern match warning. Fixes #21360 - - - - - ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00 Hadrian: don't try to build "unix" on Windows - - - - - dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Implement DeepSubsumption This MR adds the language extension -XDeepSubsumption, implementing GHC proposal #511. This change mitigates the impact of GHC proposal The changes are highly localised, by design. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. The main changes are: * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010, but off in Haskell2021. -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change. -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds: it makes type inference more complicated and less predictable, but it may be convenient in practice. * The main changes are in: * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result type. Without deep subsumption, unifyExpectedType would be sufficent. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. * There are no changes to Quick Look at all. * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to GHC.Magic.Dict * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where we'd forgotten to take the free vars of the multiplicity of an Id. * I also had to fix tcSplitNestedSigmaTys When I did the shallow-subsumption patch commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f Date: Sun Feb 2 18:23:11 2020 +0000 Simple subsumption I changed tcSplitNestedSigmaTys to not look through function arrows any more. But that was actually an un-forced change. This function is used only in * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect All to do with validity checking and error messages. Acutally its fine to look under function arrows here, and quite useful a test DeepSubsumption05 (a test motivated by a build failure in the `lens` package) shows. The fix is easy. I added Note [tcSplitNestedSigmaTys]. - - - - - e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption - - - - - 67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add DeepSubsumption08 - - - - - 5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Fix the interaction of operator sections and deep subsumption Fixes DeepSubsumption08 - - - - - 918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00 Add DeepSubsumption09 - - - - - 2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00 Default implementation for mempty/(<>) Approved by: https://github.com/haskell/core-libraries-committee/issues/61 This adds a default implementation for `mempty` and `(<>)` along with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid` instances can be defined in terms of `sconcat` / `mconcat`. The description for each class has also been updated to include the equivalent set of laws for the `sconcat`-only / `mconcat`-only instances. - - - - - 73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00 ci: Disable (broken) perf-nofib See #21859 - - - - - c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00 Docs: clarify ConstraintKinds infelicity GHC doesn't consistently require the ConstraintKinds extension to be enabled, as it allows programs such as type families returning a constraint without this extension. MR !7784 fixes this infelicity, but breaking user programs was deemed to not be worth it, so we document it instead. Fixes #21061. - - - - - 5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00 More improvements to worker/wrapper This patch fixes #21888, and simplifies finaliseArgBoxities by eliminating the (recently introduced) data type FinalDecision. A delicate interaction meant that this patch commit d1c25a48154236861a413e058ea38d1b8320273f Date: Tue Jul 12 16:33:46 2022 +0100 Refactor wantToUnboxArg a bit make worker/wrapper go into an infinite loop. This patch fixes it by narrowing the handling of case (B) of Note [Boxity for bottoming functions], to deal only the arguemnts that are type variables. Only then do we drop the trimBoxity call, which is what caused the bug. I also * Added documentation of case (B), which was previously completely un-mentioned. And a regression test, T21888a, to test it. * Made unboxDeeplyDmd stop at lazy demands. It's rare anyway for a bottoming function to have a lazy argument (mainly when the data type is recursive and then we don't want to unbox deeply). Plus there is Note [No lazy, Unboxed demands in demand signature] * Refactored the Case equation for dmdAnal a bit, to do less redundant pattern matching. - - - - - b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00 Fix a small buglet in tryEtaReduce Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was making an ill-formed cast. It didn't matter, because the subsequent guard discarded it; but still worth fixing. Spurious warnings are distracting. - - - - - 3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00 Fix #21889, GHCi misbehaves with Ctrl-C on Windows On Windows, we create multiple levels of wrappers for GHCi which ultimately execute ghc --interactive. In order to handle console events properly, each of these wrappers must call FreeConsole() in order to hand off event processing to the child process. See #14150. In addition to this, FreeConsole must only be called from interactive processes (#13411). This commit makes two changes to fix this situation: 1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole` if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi. 2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`: Before: ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe After: ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe - - - - - 79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00 docs: Fix documentation of \cases Fixes #21902. - - - - - e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00 ghc-cabal: allow Cabal 3.8 to unbreak make build When bootstrapping GHC 9.4.*, the build will fail when configuring ghc-cabal as part of the make based build system due to this upper bound, as Cabal has been updated to a 3.8 release. Reference #21914, see especially https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699 - - - - - 726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Fix isEvaldUnfolding and isValueUnfolding This fixes (1) in #21831. Easy, obviously correct. - - - - - 5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Switch off eta-expansion in rules and unfoldings I think this change will make little difference except to reduce clutter. But that's it -- if it causes problems we can switch it on again. - - - - - d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Teach SpecConstr about typeDeterminesValue This patch addresses #21831, point 2. See Note [generaliseDictPats] in SpecConstr I took the opportunity to refactor the construction of specialisation rules a bit, so that the rule name says what type we are specialising at. Surprisingly, there's a 20% decrease in compile time for test perf/compiler/T18223. I took a look at it, and the code size seems the same throughout. I did a quick ticky profile which seemed to show a bit less substitution going on. Hmm. Maybe it's the "don't do eta-expansion in stable unfoldings" patch, which is part of the same MR as this patch. Anyway, since it's a move in the right direction, I didn't think it was worth looking into further. Metric Decrease: T18223 - - - - - 65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Add a 'notes' file in testsuite/tests/perf/compiler This file is just a place to accumlate notes about particular benchmarks, so that I don't keep re-inventing the wheel. - - - - - 61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00 Get the in-scope set right in FamInstEnv.injectiveBranches There was an assert error, as Gergo pointed out in #21896. I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs. And also to GHC.Core.Unify.niFixTCvSubst. I also took the opportunity to get a couple more InScopeSets right, and to change some substTyUnchecked into substTy. This MR touches a lot of other files, but only because I also took the opportunity to introduce mkInScopeSetList, and use it. - - - - - 4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00 Add location to cc phase - - - - - 96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00 Avoid as pipeline when compiling c - - - - - 2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00 testsuite: Skip test cases involving -S when testing unregisterised GHC We no longer generate .s files anyway. Metric Decrease: MultiLayerModules T10421 T13035 T13701 T14697 T16875 T18140 T18304 T18923 T9198 - - - - - 82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00 testsuite: introduce nonmoving_thread_sanity way (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae) - - - - - 4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Track segment state It can often be useful during debugging to be able to determine the state of a nonmoving segment. Introduce some state, enabled by DEBUG, to track this. (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f) - - - - - 54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Don't scavenge objects which weren't evacuated This fixes a rather subtle bug in the logic responsible for scavenging objects evacuated to the non-moving generation. In particular, objects can be allocated into the non-moving generation by two ways: a. evacuation out of from-space by the garbage collector b. direct allocation by the mutator Like all evacuation, objects moved by (a) must be scavenged, since they may contain references to other objects located in from-space. To accomplish this we have the following scheme: * each nonmoving segment's block descriptor has a scan pointer which points to the first object which has yet to be scavenged * the GC tracks a set of "todo" segments which have pending scavenging work * to scavenge a segment, we scavenge each of the unmarked blocks between the scan pointer and segment's `next_free` pointer. We skip marked blocks since we know the allocator wouldn't have allocated into marked blocks (since they contain presumably live data). We can stop at `next_free` since, by definition, the GC could not have evacuated any objects to blocks above `next_free` (otherwise `next_free wouldn't be the first free block). However, this neglected to consider objects allocated by path (b). In short, the problem is that objects directly allocated by the mutator may become unreachable (but not swept, since the containing segment is not yet full), at which point they may contain references to swept objects. Specifically, we observed this in #21885 in the following way: 1. the mutator (specifically in #21885, a `lockCAF`) allocates an object (specifically a blackhole, which here we will call `blkh`; see Note [Static objects under the nonmoving collector] for the reason why) on the non-moving heap. The bitmap of the allocated block remains 0 (since allocation doesn't affect the bitmap) and the containing segment's (which we will call `blkh_seg`) `next_free` is advanced. 2. We enter the blackhole, evaluating the blackhole to produce a result (specificaly a cons cell) in the nursery 3. The blackhole gets updated into an indirection pointing to the cons cell; it is pushed to the generational remembered set 4. we perform a GC, the cons cell is evacuated into the nonmoving heap (into segment `cons_seg`) 5. the cons cell is marked 6. the GC concludes 7. the CAF and blackhole become unreachable 8. `cons_seg` is filled 9. we start another GC; the cons cell is swept 10. we start a new GC 11. something is evacuated into `blkh_seg`, adding it to the "todo" list 12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks between `scan` and `next_free`, which includes `blkh`). We attempt to evacuate `blkh`'s indirectee, which is the previously-swept cons cell. This is unsafe, since the indirectee is no longer a valid heap object. The problem here was that the scavenging logic *assumed* that (a) was the only source of allocations into the non-moving heap and therefore *all* unmarked blocks between `scan` and `next_free` were evacuated. However, due to (b) this is not true. The solution is to ensure that that the scanned region only encompasses the region of objects allocated during evacuation. We do this by updating `scan` as we push the segment to the todo-segment list to point to the block which was evacuated into. Doing this required changing the nonmoving scavenging implementation's update of the `scan` pointer to bump it *once*, instead of after scavenging each block as was done previously. This is because we may end up evacuating into the segment being scavenged as we scavenge it. This was quite tricky to discover but the result is quite simple, demonstrating yet again that global mutable state should be used exceedingly sparingly. Fixes #21885 (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060) - - - - - 25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00 testsuite: Skip a few tests as in the nonmoving collector Residency monitoring under the non-moving collector is quite conservative (e.g. the reported value is larger than reality) since otherwise we would need to block on concurrent collection. Skip a few tests that are sensitive to residency. (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70) - - - - - 42147534 by sternenseemann at 2022-07-26T16:26:53-04:00 hadrian: add flag disabling selftest rules which require QuickCheck The hadrian executable depends on QuickCheck for building, meaning this library (and its dependencies) will need to be built for bootstrapping GHC in the future. Building QuickCheck, however, can require TemplateHaskell. When building a statically linking GHC toolchain, TemplateHaskell can be tricky to get to work, and cross-compiling TemplateHaskell doesn't work at all without -fexternal-interpreter, so QuickCheck introduces an element of fragility to GHC's bootstrap. Since the selftest rules are the only part of hadrian that need QuickCheck, we can easily eliminate this bootstrap dependency when required by introducing a `selftest` flag guarding the rules' inclusion. Closes #8699. - - - - - 9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00 Regression test for #21848 - - - - - ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00 driver: Don't create LinkNodes when -no-link is enabled Fixes #21866 - - - - - fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00 Docs: fix mistaken claim about kind signatures This patch fixes #21806 by rectifying an incorrect claim about the usage of kind variables in the header of a data declaration with a standalone kind signature. It also adds some clarifications about the number of parameters expected in GADT declarations and in type family declarations. - - - - - 2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00 testsuite: Correctly set withNativeCodeGen Fixes #21918 - - - - - f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00 Fix since annotations in GHC.Stack.CloneStack Fixes #21894 - - - - - aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00 Add -dsuppress-coercion-types to make coercions even smaller. Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)`` simply print `` `cast` <Co:11> :: ... `` - - - - - 97655ad8 by sheaf at 2022-08-02T19:27:29-04:00 User's guide: fix typo in hasfield.rst Fixes #21950 - - - - - 35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00 Remove TCvSubst and use Subst for both term and type-level subst This patch removes the TCvSubst data type and instead uses Subst as the environment for both term and type level substitution. This change is partially motivated by the existential type proposal, which will introduce types that contain expressions and therefore forces us to carry around an "IdSubstEnv" even when substituting for types. It also reduces the amount of code because "Subst" and "TCvSubst" share a lot of common operations. There isn't any noticeable impact on performance (geo. mean for ghc/alloc is around 0.0% but we have -94 loc and one less data type to worry abount). Currently, the "TCvSubst" data type for substitution on types is identical to the "Subst" data type except the former doesn't store "IdSubstEnv". Using "Subst" for type-level substitution means there will be a redundant field stored in the data type. However, in cases where the substitution starts from the expression, using "Subst" for type-level substitution saves us from having to project "Subst" into a "TCvSubst". This probably explains why the allocation is mostly even despite the redundant field. The patch deletes "TCvSubst" and moves "Subst" and its relevant functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst". Substitution on expressions is still defined in "GHC.Core.Subst" so we don't have to expose the definition of "Expr" in the hs-boot file that "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a distinct function from "isEmptySubst"; the former ignores the emptiness of "IdSubstEnv"). These exceptions mainly exist for performance reasons and will go away when "Expr" and "Type" are mutually recursively defined (we won't be able to take those shortcuts if we can't make the assumption that expressions don't appear in types). - - - - - b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00 Fix TH + defer-type-errors interaction (#21920) Previously, we had to disable defer-type-errors in splices because of #7276. But this fix is no longer necessary, the test T7276 no longer segfaults and is now correctly deferred. - - - - - fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00 Add a note about about W/W for unlifting strict arguments This fixes #21236. - - - - - fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force safeInferred to avoid retaining extra copy of DynFlags This will only have a (very) modest impact on memory but we don't want to retain old copies of DynFlags hanging around so best to force this value. - - - - - 0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force name selectors to ensure no reference to Ids enter the NameCache I observed some unforced thunks in the NameCache which were retaining a whole Id, which ends up retaining a Type.. which ends up retaining old copies of HscEnv containing stale HomeModInfo. - - - - - 0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Fix leaks in --make mode when there are module loops This patch fixes quite a tricky leak where we would end up retaining stale ModDetails due to rehydrating modules against non-finalised interfaces. == Loops with multiple boot files It is possible for a module graph to have a loop (SCC, when ignoring boot files) which requires multiple boot files to break. In this case we must perform the necessary hydration steps before and after compiling modules which have boot files which are described above for corectness but also perform an additional hydration step at the end of the SCC to remove space leaks. Consider the following example: ┌───────┐ ┌───────┐ │ │ │ │ │ A │ │ B │ │ │ │ │ └─────┬─┘ └───┬───┘ │ │ ┌────▼─────────▼──┐ │ │ │ C │ └────┬─────────┬──┘ │ │ ┌────▼──┐ ┌───▼───┐ │ │ │ │ │ A-boot│ │ B-boot│ │ │ │ │ └───────┘ └───────┘ A, B and C live together in a SCC. Say we compile the modules in order A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps (because A has a boot file). Therefore C will be hydrated relative to A, and the ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again, and so B will reference C/A,B, its interface will be hydrated relative to both A and B. Now there is a space leak because say C is a very big module, there are now two different copies of ModDetails kept alive by modules A and B. The way to avoid this space leak is to rehydrate an entire SCC together at the end of compilation so that all the ModDetails point to interfaces for .hs files. In this example, when we hydrate A, B and C together then both A and B will refer to C/A,B. See #21900 for some more discussion. ------------------------------------------------------- In addition to this simple case, there is also the potential for a leak during parallel upsweep which is also fixed by this patch. Transcibed is Note [ModuleNameSet, efficiency and space leaks] Note [ModuleNameSet, efficiency and space leaks] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During unsweep the results of compiling modules are placed into a MVar, to find the environment the module needs to compile itself in the MVar is consulted and the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking module dependencies and recreating the HUG from scratch each time is very expensive. In serial mode (-j1), this all works out fine because a module can only be compiled after its dependencies have finished compiling and not interleaved with compiling module loops. Therefore when we create the finalised or no loop interfaces, the HUG only contains finalised interfaces. In parallel mode, we have to be more careful because the HUG variable can contain non-finalised interfaces which have been started by another thread. In order to avoid a space leak where a finalised interface is compiled against a HPT which contains a non-finalised interface we have to restrict the HUG to only the visible modules. The visible modules is recording in the ModuleNameSet, this is propagated upwards whilst compiling and explains which transitive modules are visible from a certain point. This set is then used to restrict the HUG before the module is compiled to only the visible modules and thus avoiding this tricky space leak. Efficiency of the ModuleNameSet is of utmost importance because a union occurs for each edge in the module graph. Therefore the set is represented directly as an IntSet which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode. See test "jspace" for an example which used to trigger this problem. Fixes #21900 - - - - - 1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Store interfaces in ModIfaceCache more directly I realised hydration was completely irrelavant for this cache because the ModDetails are pruned from the result. So now it simplifies things a lot to just store the ModIface and Linkable, which we can put into the cache straight away rather than wait for the final version of a HomeModInfo to appear. - - - - - 6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00 cmm: Remove unused ReadOnlyData16 We don't actually emit rodata16 sections anywhere. - - - - - 16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00 findExternalRules: Don't needlessly traverse the list of rules. - - - - - 52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00 Remove backported items from 9.6 release notes They have been backported to 9.4 in commits 5423d84bd9a28f, 13c81cb6be95c5, 67ccbd6b2d4b9b. - - - - - 78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00 ci: Fix pages job The job has been failing because we don't bundle haddock docs anymore in the docs dist created by hadrian. Fixes #21789 - - - - - 037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00 codeGen/X86: Don't clobber switch variable in switch generation Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was safe to clobber the switch variable when generating code for a jump table since we were at the end of a block. However, this assumption is wrong; the register could be live in the jump target. Fixes #21968. - - - - - 50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00 Fix equality operator in jspace test - - - - - e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Improve BUILD_PAP comments - - - - - 41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Make dropTail comment a haddock comment - - - - - ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Add one more sanity check in stg_restore_cccs - - - - - 1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00 StgToCmm: Fix isSimpleScrut when profiling is enabled. When profiling is enabled we must enter functions that might represent thunks in order for their sccs to show up in the profile. We might allocate even if the function is already evaluated in this case. So we can't consider any potential function thunk to be a simple scrut when profiling. Not doing so caused profiled binaries to segfault. - - - - - fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Change `-fprof-late` to insert cost centres after unfolding creation. The former behaviour of adding cost centres after optimization but before unfoldings are created is not available via the flag `prof-late-inline` instead. I also reduced the overhead of -fprof-late* by pushing the cost centres into lambdas. This means the cost centres will only account for execution of functions and not their partial application. Further I made LATE_CC cost centres it's own CC flavour so they now won't clash with user defined ones if a user uses the same string for a custom scc. LateCC: Don't put cost centres inside constructor workers. With -fprof-late they are rarely useful as the worker is usually inlined. Even if the worker is not inlined or we use -fprof-late-linline they are generally not helpful but bloat compile and run time significantly. So we just don't add sccs inside constructor workers. ------------------------- Metric Decrease: T13701 ------------------------- - - - - - f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00 gitlab-ci: Fix hadrian bootstrapping of release pipelines Previously we would attempt to test hadrian bootstrapping in the `validate` build flavour. However, `ci.sh` refuses to run validation builds during release pipelines, resulting in job failures. Fix this by testing bootstrapping in the `release` flavour during release pipelines. We also attempted to record perf notes for these builds, which is redundant work and undesirable now since we no longer build in a consistent flavour. - - - - - c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00 compiler: Eliminate two uses of foldr in favor of foldl' These two uses constructed maps, which is a case where foldl' is generally more efficient since we avoid constructing an intermediate O(n)-depth stack. - - - - - d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00 rts: Fix code style - - - - - 57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00 genprimopcode: Drop ArrayArray# references As ArrayArray# no longer exists - - - - - 7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00 base: Organize Haddocks in GHC.Conc.Sync - - - - - aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00 Add primop to list threads A user came to #ghc yesterday wondering how best to check whether they were leaking threads. We ended up using the eventlog but it seems to me like it would be generally useful if Haskell programs could query their own threads. - - - - - 6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00 rts: Move thread labels into TSO This eliminates the thread label HashTable and instead tracks this information in the TSO, allowing us to use proper StgArrBytes arrays for backing the label and greatly simplifying management of object lifetimes when we expose them to the user with the coming `threadLabel#` primop. - - - - - 1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00 Add a primop to query the label of a thread - - - - - 43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00 base: Share finalization thread label For efficiency's sake we float the thread label assigned to the finalization thread to the top-level, ensuring that we only need to encode the label once. - - - - - 1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00 users-guide: Add release notes entry for thread introspection support - - - - - 09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix binary distribution install attributes Previously we would use plain `cp` to install various parts of the binary distribution. However, `cp`'s behavior w.r.t. file attributes is quite unclear; for this reason it is much better to rather use `install`. Fixes #21965. - - - - - 2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix installation of system-cxx-std-lib package conf - - - - - 7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00 gitlab-ci: Bump Docker images To give the ARMv7 job access to lld, fixing #21875. - - - - - afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Don't use mk/config.mk.in Ultimately we want to drop mk/config.mk so here I extract the bits needed by the Hadrian bindist installation logic into a Hadrian-specific file. While doing this I fixed binary distribution installation, #21901. - - - - - b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Fix naming of cross-compiler wrappers - - - - - 78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00 hadrian: Extend xattr Darwin hack to cover /lib As noted in #21506, it is now necessary to remove extended attributes from `/lib` as well as `/bin` to avoid SIP issues on Darwin. Fixes #21506. - - - - - 20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00 NCG(x86): Compile add+shift as lea if possible. - - - - - 742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00 dataToTag#: Skip runtime tag check if argument is infered tagged This addresses one part of #21710. - - - - - 1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00 rts: remove redundant stg_traceCcszh This out-of-line primop has no Haskell wrapper and hasn't been used anywhere in the tree. Furthermore, the code gets in the way of !7632, so it should be garbage collected. - - - - - a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00 Document a divergence from the report in parsing function lhss. GHC is happy to parse `(f) x y = x + y` when it should be a parse error based on the Haskell report. Seems harmless enough so we won't fix it but it's documented now. Fixes #19788 - - - - - 5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00 gitlab-ci: Add release job for aarch64/debian 11 - - - - - 5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Introduce validation job for aarch64 cross-compilation Begins to address #11958. - - - - - e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00 Bump process submodule - - - - - ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Add basic support for cross-compiler testiing Here we add a simple qemu-based test for cross-compilers. - - - - - 50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00 rts: Ensure that Array# card arrays are initialized In #19143 I noticed that newArray# failed to initialize the card table of newly-allocated arrays. However, embarrassingly, I then only fixed the issue in newArrayArray# and, in so doing, introduced the potential for an integer underflow on zero-length arrays (#21962). Here I fix the issue in newArray#, this time ensuring that we do not underflow in pathological cases. Fixes #19143. - - - - - e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00 testsuite: Add test for #21962 - - - - - c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00 gitlab-ci: Don't use coreutils on Darwin In general we want to ensure that the tested environment is as similar as possible to the environment the user will use. In the case of Darwin, this means we want to use the system's BSD command-line utilities, not coreutils. This would have caught #21974. - - - - - 1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00 hadrian: Fix bindist installation on Darwin It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does. - - - - - 681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00 hadrian: Fix access mode of installed package registration files Previously hadrian's bindist Makefile would modify package registrations placed by `install` via a shell pipeline and `mv`. However, the use of `mv` means that if umask is set then the user may otherwise end up with package registrations which are inaccessible. Fix this by ensuring that the mode is 0644. - - - - - e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00 Cleanups around pretty-printing * Remove hack when printing OccNames. No longer needed since e3dcc0d5 * Remove unused `pprCmms` and `instance Outputable Instr` * Simplify `pprCLabel` (no need to pass platform) * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by ImmLit, but that can take just a String instead. * Remove instance `Outputable CLabel` - proper output of labels needs a platform, and is done by the `OutputableP` instance - - - - - 66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00 rts/linker: Resolve iconv_* on FreeBSD FreeBSD's libiconv includes an implementation of the iconv_* functions in libc. Unfortunately these can only be resolved using dlvsym, which is how the RTS linker usually resolves such functions. To fix this we include an ad-hoc special case for iconv_*. Fixes #20354. - - - - - 5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00 system-cxx-std-lib: Add support for FreeBSD libcxxrt - - - - - ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00 gitlab-ci: Bump to use freebsd13 runners - - - - - d71a2051 by sheaf at 2022-08-09T13:47:28-04:00 Fix size_up_alloc to account for UnliftedDatatypes The size_up_alloc function mistakenly considered any type that isn't lifted to not allocate anything, which is wrong. What we want instead is to check the type isn't boxed. This accounts for (BoxedRep Unlifted). Fixes #21939 - - - - - 76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. - - - - - 7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. - - - - - dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00 Updates language extension documentation Adding a 'Status' field with a few values: - Deprecated - Experimental - InternalUseOnly - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98' Those values are pulled from the existing descriptions or elsewhere in the documentation. While at it, include the :implied by: where appropriate, to provide more detail. Fixes #21475 - - - - - 823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00 hadrian RunRest: add type signature for stageNumber avoids warning seen on 9.4.1: src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults] • Defaulting the following constraints to type ‘Integer’ (Show a0) arising from a use of ‘show’ at src/Settings/Builders/RunTest.hs:264:53-84 (Num a0) arising from a use of ‘stageNumber’ at src/Settings/Builders/RunTest.hs:264:59-83 • In the second argument of ‘(++)’, namely ‘show (stageNumber (C.stage ctx))’ In the second argument of ‘($)’, namely ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’ In the expression: arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | 264 | , arg "-e", arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compilation tested locally - - - - - f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00 Add support for external static plugins (#20964) This patch adds a new command-line flag: -fplugin-library=<file-path>;<unit-id>;<module>;<args> used like this: -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"] It allows a plugin to be loaded directly from a shared library. With this approach, GHC doesn't compile anything for the plugin and doesn't load any .hi file for the plugin and its dependencies. As such GHC doesn't need to support two environments (one for plugins, one for target code), which was the more ambitious approach tracked in #14335. Fix #20964 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Fix ARMv7 build It appears that the CI refactoring carried out in 5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some critical configuration: setting the build/host/target platforms and forcing use of a non-broken linker. - - - - - 596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Run ARMv7 jobs when ~ARM label is used - - - - - 7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00 hadrian: Don't attempt to install documentation if doc/ doesn't exist Previously we would attempt to install documentation even if the `doc` directory doesn't exist (e.g. due to `--docs=none`). This would result in the surprising side-effect of the entire contents of the bindist being installed in the destination documentation directory. Fix this. Fixes #21976. - - - - - 67575f20 by normalcoder at 2022-08-10T15:38:34-04:00 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - - - - - 45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00 Note [Trimming auto-rules]: State that this improves compiler perf. - - - - - 5c24b1b3 by Bodigrim at 2022-08-10T22:41:50-04:00 Document that threadDelay / timeout are susceptible to overflows on 32-bit machines - - - - - ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 Updates haddock submodule - - - - - dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00 Revert "gitlab-ci: Add release job for aarch64/debian 11" This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46. The job was not tested before being merged and fails CI (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392) Ticket #22005 - - - - - ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00 typo - - - - - cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00 CmmToLlvm: Don't aliasify builtin LLVM variables Our aliasification logic would previously turn builtin LLVM variables into aliases, which apparently confuses LLVM. This manifested in initializers failing to be emitted, resulting in many profiling failures with the LLVM backend. Fixes #22019. - - - - - dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00 run_ci: remove monoidal-containers Fixes #21492 MonoidalMap is inlined and used to implement Variables, as before. The top-level value "jobs" is reimplemented as a regular Map, since it doesn't use the monoidal union anyway. - - - - - 64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00 CmmToAsm/AArch64: correct a typo - - - - - f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00 Fix #21979 - compact-share failing with -O I don't have good reason to believe the optimization level should affect if sharing works or not here. So limit the test to the normal way. - - - - - 68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix reference to dead llvm-version substitution Fixes #22052. - - - - - 28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix incorrect reference to `:extension: role - - - - - 71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Add :ghc-flag: reference - - - - - 385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00 hadrian: Place manpage in docroot This relocates it from docs/ to doc/ - - - - - 84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00 Bump haddock submodule Includes merge of `main` into `ghc-head` as well as some Haddock users guide fixes. - - - - - 59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00 base: Add changelog entries from ghc-9.2 Closes #21922. - - - - - a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00 relnotes: Add "included libraries" section As noted in #21988, some users rely on this. - - - - - a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Rephrase the rewrite rule documentation Previously the wording was a tad unclear. Fix this. Closes #21114. - - - - - 3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00 Implement Response File support for HPC This is an improvement to HPC authored by Richard Wallace (https://github.com/purefn) and myself. I have received permission from him to attempt to upstream it. This improvement was originally implemented as a patch to HPC via input-output-hk/haskell.nix: https://github.com/input-output-hk/haskell.nix/pull/1464 Paraphrasing Richard, HPC currently requires all inputs as command line arguments. With large projects this can result in an argument list too long error. I have only seen this error in Nix, but I assume it can occur is a plain Unix environment. This MR adds the standard response file syntax support to HPC. For example you can now pass a file to the command line which contains the arguments. ``` hpc @response_file_1 @response_file_2 ... The contents of a Response File must have this format: COMMAND ... example: report my_library.tix --include=ModuleA --include=ModuleB ``` Updates hpc submodule Co-authored-by: Richard Wallace <rwallace at thewallacepack.net> Fixes #22050 - - - - - 436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00 ghc-heap: Fix decoding of TSO closures An extra field was added to the TSO structure in 6d1700b6 but the decoding logic in ghc-heap was not updated for this new field. Fixes #22046 - - - - - a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00 driver: Honour -x option The -x option is used to manually specify which phase a file should be started to be compiled from (even if it lacks the correct extension). I just failed to implement this when refactoring the driver. In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to preprocess source files using GHC. I added a test to exercise this case. Fixes #22044 - - - - - e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00 Be more careful in chooseInferredQuantifiers This fixes #22065. We were failing to retain a quantifier that was mentioned in the kind of another retained quantifier. Easy to fix. - - - - - 714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00 testsuite: Add test for #21583 - - - - - 989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00 compiler: Drop --build-id=none hack Since 2011 the object-joining implementation has had a hack to pass `--build-id=none` to `ld` when supported, seemingly to work around a linker bug. This hack is now unnecessary and may break downstream users who expect objects to have valid build-ids. Remove it. Closes #22060. - - - - - 519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00 Make ru_fn field strict to avoid retaining Ids It's better to perform this projection from Id to Name strictly so we don't retain an old Id (hence IdInfo, hence Unfolding, hence everything etc) - - - - - 7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force `getOccFS bndr` to avoid retaining reference to Bndr. This is another symptom of #19619 - - - - - 4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force unfoldings when they are cleaned-up in Tidy and CorePrep If these thunks are not forced then the entire unfolding for the binding is live throughout the whole of CodeGen despite the fact it should have been discarded. Fixes #22071 - - - - - 2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00 haddock docs: Fix links from identifiers to dependent packages When implementing the base_url changes I made the pretty bad mistake of zipping together two lists which were in different orders. The simpler thing to do is just modify `haddockDependencies` to also return the package identifier so that everything stays in sync. Fixes #22001 - - - - - 9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00 Revert "Refactor SpecConstr to use treat bindings uniformly" This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729. This refactoring introduced quite a severe residency regression (900MB live from 650MB live when compiling mmark), see #21993 for a reproducer and more discussion. Ticket #21993 - - - - - 9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00 tc: warn about lazy annotations on unlifted arguments (fixes #21951) - - - - - e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00 Fix #22048 where we failed to drop rules for -fomit-interface-pragmas. Now we also filter the local rules (again) which fixes the issue. - - - - - 51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00 Print constraints in quotes (#21167) This patch improves the uniformity of error message formatting by printing constraints in quotes, as we do for types. Fix #21167 - - - - - ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00 19217 Implicitly quantify type variables in :kind command - - - - - 9939e95f by MorrowM at 2022-08-21T16:51:38-04:00 Recognize file-header pragmas in GHCi (#21507) - - - - - fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00 hadrian: Fix bootstrapping with ghc-9.4 The error was that we were trying to link together containers from boot package library (which depends template-haskell in boot package library) template-haskell from in-tree package database So the fix is to build containers in stage0 (and link against template-haskell built in stage0). Fixes #21981 - - - - - b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00 Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942. * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence * `ParensT` constructor is now always printed parenthesized * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down * using `>=` instead of former `>` to match the Core type printing logic * some test outputs have changed, losing extraneous parentheses - - - - - fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00 Fix and test for issue #21723 - - - - - 33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00 Test for issue #21942 - - - - - c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00 Updated the changelog - - - - - 80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00 hadrian: Don't duplicate binaries on installation Previously we used `install` on symbolic links, which ended up copying the target file rather than installing a symbolic link. Fixes #22062. - - - - - b929063e by M Farkas-Dyck at 2022-08-24T02:37:01-04:00 Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`. Closes #22092. - - - - - 112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00 driver: don't actually merge objects when ar -L works - - - - - a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00 rts: Consistently use MiB in stats output Previously we would say `MB` even where we meant `MiB`. - - - - - a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694, #21755. It also makes sure that #21948 and fix to #21694. * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * To make "no free join points in arityType" work out I had to avoid trying to use eta-expansion for runRW#. This entailed a few changes in the Simplifier's treatment of runRW#. See GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#] * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * Rewrote Note [Combining case branches: optimistic one-shot-ness] * arityType previously treated join points differently to other let-bindings. This patch makes them unform; arityType analyses the RHS of all bindings to get its ArityType, and extends am_sigs. I realised that, now we have am_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. * And finally, it was the strange treatment of join-point Ids in arityType (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring, which treats them uniformly; but without breaking #18328. In fact, the arity for recursive join bindings is pretty tricky; see the long Note [Arity for recursive join bindings] in GHC.Core.Opt.Simplify.Utils. That led to more refactoring, including deciding that an Id could have an Arity that is bigger than its JoinArity; see Note [Invariants on join points], item 2(b) in GHC.Core * Make sure that the "demand threshold" for join points in DmdAnal is no bigger than the join-arity. In GHC.Core.Opt.DmdAnal see Note [Demand signatures are computed for a threshold arity based on idArity] * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity, where it more properly belongs. * Remove an old, redundant hack in FloatOut. The old Note was Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels. Compile time improves very slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- T18223(normal) ghc/alloc 725,808,720 747,839,216 +3.0% BAD T6048(optasm) ghc/alloc 105,006,104 101,599,472 -3.2% GOOD geo. mean -0.2% minimum -3.2% maximum +3.0% For some reason Windows was better T10421(normal) ghc/alloc 125,888,360 124,129,168 -1.4% GOOD T18140(normal) ghc/alloc 85,974,520 83,884,224 -2.4% GOOD T18698b(normal) ghc/alloc 236,764,568 234,077,288 -1.1% GOOD T18923(normal) ghc/alloc 75,660,528 73,994,512 -2.2% GOOD T6048(optasm) ghc/alloc 112,232,512 108,182,520 -3.6% GOOD geo. mean -0.6% I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3% increase in exchange for goodness elsewhere. Metric Decrease: T10421 T18140 T18698b T18923 T6048 Metric Increase: T18223 - - - - - 909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00 upload_ghc_libs: Add means of passing Hackage credentials - - - - - 28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00 Scrub some partiality in `CommonBlockElim`. - - - - - 54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00 hadrian: Fix whitespace Previously this region of Settings.Packages was incorrectly indented. - - - - - c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00 validate: Drop --legacy flag In preparation for removal of the legacy `make`-based build system. - - - - - 822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00 gitlab-ci: Drop make build validation jobs In preparation for removal of the `make`-based build system - - - - - 6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop make build system Here we at long last remove the `make`-based build system, it having been replaced with the Shake-based Hadrian build system. Users are encouraged to refer to the documentation in `hadrian/doc` and this [1] blog post for details on using Hadrian. Closes #17527. [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html - - - - - dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00 Remove testsuite/tests/perf/haddock/.gitignore As noted in #16802, this is no longer needed. Closes #16802. - - - - - fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop hc-build script This has not worked for many, many years and relied on the now-removed `make`-based build system. - - - - - 659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mkdirhier This is only used by nofib's dead `dist` target - - - - - 4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mk/{build,install,config}.mk.in - - - - - 46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00 compiler: Drop comment references to make - - - - - d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add inits1 and tails1 to Data.List.NonEmpty See https://github.com/haskell/core-libraries-committee/issues/67 - - - - - 8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add since annotations and changelog entries - - - - - 6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00 Fix redundant import This fixes a build error on x86_64-linux-alpine3_12-validate. See the function 'loadExternalPlugins' defined in this file. - - - - - 4786acf7 by sheaf at 2022-08-26T15:05:23-04:00 Pmc: consider any 2 dicts of the same type equal This patch massages the keys used in the `TmOracle` `CoreMap` to ensure that dictionaries of coherent classes give the same key. That is, whenever we have an expression we want to insert or lookup in the `TmOracle` `CoreMap`, we first replace any dictionary `$dict_abcd :: ct` with a value of the form `error @ct`. This allows us to common-up view pattern functions with required constraints whose arguments differed only in the uniques of the dictionaries they were provided, thus fixing #21662. This is a rather ad-hoc change to the keys used in the `TmOracle` `CoreMap`. In the long run, we would probably want to use a different representation for the keys instead of simply using `CoreExpr` as-is. This more ambitious plan is outlined in #19272. Fixes #21662 Updates unix submodule - - - - - f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00 Remove label style from printing context Previously, the SDocContext used for code generation contained information whether the labels should use Asm or C style. However, at every individual call site, this is known statically. This removes the parameter to 'PprCode' and replaces every 'pdoc' used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'. The OutputableP instance is now used only for dumps. The output of T15155 changes, it now uses the Asm style (which is faithful to what actually happens). - - - - - 1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00 boot: cleanup legacy args Cleanup legacy boot script args, following removal of the legacy make build system. - - - - - 95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00 Improve SpecConstr for evals As #21763 showed, we were over-specialising in some cases, when the function involved was doing a simple 'eval', but not taking the value apart, or branching on it. This MR fixes the problem. See Note [Do not specialise evals]. Nofib barely budges, except that spectral/cichelli allocates about 3% less. Compiler bytes-allocated improves a bit geo. mean -0.1% minimum -0.5% maximum +0.0% The -0.5% is on T11303b, for what it's worth. - - - - - 565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Revert "Revert "Refactor SpecConstr to use treat bindings uniformly"" This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8. This commit was originally reverted due to an increase in space usage. This was diagnosed as because the SCE increased in size and that was being retained by another leak. See #22102 - - - - - 82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Avoid retaining bindings via ModGuts held on the stack It's better to overwrite the bindings fields of the ModGuts before starting an iteration as then all the old bindings can be collected as soon as the simplifier has processed them. Otherwise we end up with the old bindings being alive until right at the end of the simplifier pass as the mg_binds field is only modified right at the end. - - - - - 64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00 Force imposs_deflt_cons in filterAlts This fixes a pretty serious space leak as the forced thunk would retain `Alt b` values which would then contain reference to a lot of old bindings and other simplifier gunk. The OtherCon unfolding was not forced on subsequent simplifier runs so more and more old stuff would be retained until the end of simplification. Fixing this has a drastic effect on maximum residency for the mmark package which goes from ``` 45,005,401,056 bytes allocated in the heap 17,227,721,856 bytes copied during GC 818,281,720 bytes maximum residency (33 sample(s)) 9,659,144 bytes maximum slop 2245 MiB total memory in use (0 MB lost due to fragmentation) ``` to ``` 45,039,453,304 bytes allocated in the heap 13,128,181,400 bytes copied during GC 331,546,608 bytes maximum residency (40 sample(s)) 7,471,120 bytes maximum slop 916 MiB total memory in use (0 MB lost due to fragmentation) ``` See #21993 for some more discussion. - - - - - a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Use Solo to avoid retaining the SCE but to avoid performing the substitution The use of Solo here allows us to force the selection into the SCE to obtain the Subst but without forcing the substitution to be applied. The resulting thunk is placed into a lazy field which is rarely forced, so forcing it regresses peformance. - - - - - 161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00 Fix a nasty loop in Tidy As the remarkably-simple #22112 showed, we were making a black hole in the unfolding of a self-recursive binding. Boo! It's a bit tricky. Documented in GHC.Iface.Tidy, Note [tidyTopUnfolding: avoiding black holes] - - - - - 68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnIllegalHsigDefaultMethods TcRnBadGenericMethod TcRnWarningMinimalDefIncomplete TcRnDefaultMethodForPragmaLacksBinding TcRnIgnoreSpecialisePragmaOnDefMethod TcRnBadMethodErr TcRnNoExplicitAssocTypeOrDefaultDeclaration - - - - - cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00 Fix a bug in anyInRnEnvR This bug was a subtle error in anyInRnEnvR, introduced by commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06 Author: Andreas Klebinger <klebinger.andreas at gmx.at> Date: Sat Jul 9 01:19:52 2022 +0200 Rule matching: Don't compute the FVs if we don't look at them. The net result was #22028, where a rewrite rule would wrongly match on a lambda. The fix to that function is easy. - - - - - 0154bc80 by sheaf at 2022-08-30T06:05:41-04:00 Various Hadrian bootstrapping fixes - Don't always produce a distribution archive (#21629) - Use correct executable names for ghc-pkg and hsc2hs on windows (we were missing the .exe file extension) - Fix a bug where we weren't using the right archive format on Windows when unpacking the bootstrap sources. Fixes #21629 - - - - - 451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00 ci: Attempt using normal submodule cloning strategy We do not use any recursively cloned submodules, and this protects us from flaky upstream remotes. Fixes #22121 - - - - - 9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: stray "--" - - - - - 3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: syntatic -> syntactic - - - - - 7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00 Add a missing trimArityType This buglet was exposed by #22114, a consequence of my earlier refactoring of arity for join points. - - - - - e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump binary submodule to 0.8.9.1 - - - - - 4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump stm submodule to 2.5.1.0 - - - - - 837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00 users-guide: Document system-cxx-std-lib - - - - - f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00 Update submodule containers to 0.6.6 - - - - - 4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00 Update submodule process to 1.6.15.0 - - - - - 1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00 Bump directory submodule to 1.3.7.1 - - - - - 7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00 Bump text submodule to 2.0.1 - - - - - fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00 Bump deepseq submodule to 1.4.8.0 - - - - - a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00 Add dates to base, ghc-prim changelogs - - - - - 2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00 Update autoconf scripts Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983 - - - - - e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00 Bump bytestring submodule to 0.11.3.1 - - - - - f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00 Update submodule Cabal to tag Cabal-v3.8.1.0 closes #21931 - - - - - e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00 Refine in-tree compiler args for --test-compiler=stage1 Some of the logic to calculate in-tree arguments was not correct for the stage1 compiler. Namely we were not correctly reporting whether we were building static or dynamic executables and whether debug assertions were enabled. Fixes #22096 - - - - - 6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00 Make ghcDebugAssertions into a Stage predicate (Stage -> Bool) We also care whether we have debug assertions enabled for a stage one compiler, but the way which we turned on the assertions was quite different from the stage2 compiler. This makes the logic for turning on consistent across both and has the advantage of being able to correct determine in in-tree args whether a flavour enables assertions or not. Ticket #22096 - - - - - 15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00 Add regression test for #21550 This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5 "Use local instances with least superclass depth" - - - - - 7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00 Minor cleanup - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused), isCoVar_maybe (duplicated by getCoVar_maybe) - Replace a few occurrences of voidPrimId with (# #). void# is a deprecated synonym for the unboxed tuple. - Use showSDoc in :show linker. This makes it consistent with the other :show commands - - - - - 31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - 7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00 Fix bootstrap with ghc-9.0 It turns out Solo is a very recent addition to base, so for older GHC versions we just defined it inline here the one place we use it in the compiler. - - - - - d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00 DmdAnal: Don't panic in addCaseBndrDmd (#22039) Rather conservatively return Top. See Note [Untyped demand on case-alternative binders]. I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and `fieldBndrDmds`. Fixes #22039. - - - - - 25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00 gitlab-ci: Ensure that ghc derivation is in scope Previously the lint-ci job attempted to use cabal-install (specifically `cabal update`) without a GHC in PATH. However, cabal-install-3.8 appears to want GHC, even for `cabal update`. - - - - - f37b621f by sheaf at 2022-09-06T11:51:53+00:00 Update instances.rst, clarifying InstanceSigs Fixes #22103 - - - - - d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00 Fix :add docs in user guide - - - - - 808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00 ci: remove unused build_make/test_make in ci script - - - - - d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00 typo - - - - - fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00 typos - - - - - a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00 whitespace - - - - - 04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Minor SDoc cleanup Change calls to renderWithContext with showSDocOneLine; it's more efficient and explanatory. Remove polyPatSig (unused) - - - - - 7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Remove Outputable Char instance Use 'text' instead of 'ppr'. Using 'ppr' on the list "hello" rendered as "h,e,l,l,o". - - - - - 77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Export liftA2 from Prelude Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details. - - - - - 442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Add changelog entry for liftA2 export from Prelude - - - - - fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule containers to one with liftA2 warnings fixed - - - - - f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule Cabal to one with liftA2 warnings fixed - - - - - a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Isolate some Applicative hidings to GHC.Prelude By reexporting the entirety of Applicative from GHC.Prelude, we can save ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude. This also has the benefit of isolating this type of change to GHC.Prelude, so that people in the future don't have to think about it. - - - - - 9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00 CmmToC: enable 64-bit CallishMachOp on 32-bit targets Normally, the unregisterised builds avoid generating 64-bit CallishMachOp in StgToCmm, so CmmToC doesn't support these. However, there do exist cases where we'd like to invoke cmmToC for other cmm inputs which may contain such CallishMachOps, and it's a rather low effort to add support for these since they only require calling into existing ghc-prim cbits. - - - - - 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by M Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - 657ccdbd by John Ericson at 2022-12-10T11:36:59-05:00 Clarify laws of `TestCoercion` - Add law to `TestCoercion` to match `TestEquality` - Remove recommendation for singleton types because of uncertainty whether this is a good recommendation. - Discuss the singleton type quandary under an [expandable heading](https://haskell-haddock.readthedocs.io/en/latest/markup.html?highlight=expandable#headings) for anyone that is curious, without cluttering the main documentation. Follow up from a5ea78673eae7c837a5ccb7882e908a4df92e75d. - - - - - 21 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - + .gitlab/upload_ghc_libs.py - CODEOWNERS - HACKING.md - − MAKEHELP.md - − Makefile - README.md - − appveyor.yml - bindisttest/Makefile - − bindisttest/ghc.mk - boot - compiler/.hlint.yaml - compiler/CodeGen.Platform.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4f25746acbfc37457e8e0156125f0806acd2d97...657ccdbd479ef69cff34ea86ca6157098229eacd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4f25746acbfc37457e8e0156125f0806acd2d97...657ccdbd479ef69cff34ea86ca6157098229eacd You're receiving 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 Dec 10 16:44:45 2022 From: gitlab at gitlab.haskell.org (John Ericson (@Ericson2314)) Date: Sat, 10 Dec 2022 11:44:45 -0500 Subject: [Git][ghc/ghc][wip/clarify-test-coercion] Clarify laws of `TestCoercion` Message-ID: <6394b77d25c67_224fca2595e17c9846b0@gitlab.mail> John Ericson pushed to branch wip/clarify-test-coercion at Glasgow Haskell Compiler / GHC Commits: d343f493 by John Ericson at 2022-12-10T11:44:36-05:00 Clarify laws of `TestCoercion` - Add law to `TestCoercion` to match `TestEquality` - Remove recommendation for singleton types because of uncertainty whether this is a good recommendation. - Discuss the singleton type quandary under an [expandable heading](https://haskell-haddock.readthedocs.io/en/latest/markup.html?highlight=expandable#headings) for anyone that is curious, without cluttering the main documentation. Follow up from a5ea78673eae7c837a5ccb7882e908a4df92e75d. - - - - - 1 changed file: - libraries/base/Data/Type/Coercion.hs Changes: ===================================== libraries/base/Data/Type/Coercion.hs ===================================== @@ -97,9 +97,64 @@ instance Coercible a b => Enum (Coercion a b) where -- | @since 4.7.0.0 deriving instance Coercible a b => Bounded (Coercion a b) --- | This class contains types where you can learn the equality of two types --- from information contained in /terms/. Typically, only singleton types should --- inhabit this class. +-- | This class contains types where you can learn the coercibility of two +-- types from information contained in /terms/. +-- +-- The result should be @Just Coercion@ if and only if the types applied to @f@ +-- are coercible: +-- +-- @testCoercion (x :: f a) (y :: f b) = Just Coercion@ ⟺ Coercible a b@ +-- +-- === __Guidance on use with singleton types__ +-- +-- It was previously recommend that only singleton types should inhabit this +-- class. However, it is unclear what the singleton types should represent. +-- +-- Normally, a singleton type has one value per *type*: types quotiented by +-- nominal equivalence, i.e. just types. +-- +-- An example of this would be: +-- +-- @ +-- data Nom0 :: Type -> Type where +-- Nom0Int :: Nom0 Int +-- Nom0Bool :: Nom0 Bool +-- @ +-- +-- Which, to make relationship to the next part more clear, let's rewrite more +-- verbosely as: +-- +-- @ +-- data Nom1 :: Type -> Type where +-- Nom1Int :: forall a. a ~ Int => Nom1 a +-- Nom1Bool :: forall a. a ~ Bool => Nom1 a +-- @ +-- +-- But arguably, given that we are testing for coercibility, it would be better +-- to have one value per *representation*: types quotiented by representational +-- equivalence, i.e. equivalence classes of types that are +-- pairwise-'Coercible'. +-- +-- An example of this would be: +-- +-- @ +-- data Rep :: Type -> Type where +-- RepInt :: forall a. a `Coercible` Int => Rep a +-- RepBool :: forall a. a `Coercible` Bool => Rep a +-- @ +-- +-- The goal of this would be to have laws similar to that for 'TestEquality' +-- when used with singletons: +-- +-- @testCoercion (x :: f a) (y :: f b) = Just Refl ⟺ a `Coercible` b ⟺ coerce x = coerce y@ +-- +-- @isJust (testCoercion x y) = coerce x == coerce y@ +-- +-- However, GHC today thinks the argument to 'Rep' must have a nominal role, +-- and therefore the above doesn't work. +-- +-- Regardless, singleton types are not required, however, and so the latter +-- would-be laws are not in fact valid in general. class TestCoercion f where -- | Conditionally prove the representational equality of @a@ and @b at . testCoercion :: f a -> f b -> Maybe (Coercion a b) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d343f4937706d8f3563b2f07be02710439cacb9d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d343f4937706d8f3563b2f07be02710439cacb9d You're receiving 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 Dec 11 11:26:09 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 11 Dec 2022 06:26:09 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Update containers submodule Message-ID: <6395be5170c3a_224fca1d7887741019580@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - 38239c84 by Oleg Grenrus at 2022-12-11T06:25:59-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - 2eedf815 by Bodigrim at 2022-12-11T06:26:03-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 16 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Lint.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Make.hs - configure.ac - hadrian/bootstrap/generate_bootstrap_plans - hadrian/bootstrap/hadrian-bootstrap-gen.cabal - − hadrian/bootstrap/plan-8_10_1.json - − hadrian/bootstrap/plan-8_10_2.json - − hadrian/bootstrap/plan-8_10_3.json - − hadrian/bootstrap/plan-8_10_4.json - − hadrian/bootstrap/plan-8_10_5.json - − hadrian/bootstrap/plan-8_10_7.json - − hadrian/bootstrap/plan-9_0_1.json - − hadrian/bootstrap/plan-9_0_2.json The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/38e42040e26983f3ecd80429f54d5e5033030301...2eedf815a9c58484dc1a27be7f508551953d7594 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/38e42040e26983f3ecd80429f54d5e5033030301...2eedf815a9c58484dc1a27be7f508551953d7594 You're receiving 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 Dec 11 15:20:26 2022 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sun, 11 Dec 2022 10:20:26 -0500 Subject: [Git][ghc/ghc][wip/decode_cloned_stack] Fix tests Message-ID: <6395f53a51a2_224fca2595e17c10392ce@gitlab.mail> Sven Tennie pushed to branch wip/decode_cloned_stack at Glasgow Haskell Compiler / GHC Commits: 651d7b71 by Sven Tennie at 2022-12-11T15:19:58+00:00 Fix tests - - - - - 9 changed files: - + libraries/ghc-heap/GHC/Exts/DecodeHeap.hs - libraries/ghc-heap/GHC/Exts/DecodeStack.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - libraries/ghc-heap/tests/TestUtils.hs - libraries/ghc-heap/tests/stack_big_ret.hs - + libraries/ghc-heap/tests/stack_misc_closures.c - + libraries/ghc-heap/tests/stack_misc_closures.hs - libraries/ghc-heap/tests/stack_stm_frames.hs - libraries/ghc-heap/tests/stack_underflow.hs Changes: ===================================== libraries/ghc-heap/GHC/Exts/DecodeHeap.hs ===================================== @@ -0,0 +1,257 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE UnliftedFFITypes #-} + +module GHC.Exts.DecodeHeap where +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 qualified GHC.Exts.Heap.ProfInfo.PeekProfInfo as PPI + +import Control.Monad +import Data.Bits +import Foreign +import GHC.Exts + + +-- | Convert an unpacked heap object, to a `GenClosure b`. The inputs to this +-- function can be generated from a heap object using `unpackClosure#`. +getClosureDataFromHeapRep :: ByteArray# -> Ptr StgInfoTable -> [b] -> IO (GenClosure b) +getClosureDataFromHeapRep heapRep infoTablePtr pts = do + itbl <- peekItbl infoTablePtr + getClosureDataFromHeapRepPrim (dataConNames infoTablePtr) PPI.peekTopCCS itbl heapRep pts + +getClosureDataFromHeapRepPrim + :: IO (String, String, String) + -- ^ A continuation used to decode the constructor description field, + -- in ghc-debug this code can lead to segfaults because dataConNames + -- will dereference a random part of memory. + -> (Ptr a -> IO (Maybe CostCentreStack)) + -- ^ A continuation which is used to decode a cost centre stack + -- In ghc-debug, this code will need to call back into the debuggee to + -- fetch the representation of the CCS before decoding it. Using + -- `peekTopCCS` for this argument can lead to segfaults in ghc-debug as + -- the CCS argument will point outside the copied closure. + -> StgInfoTable + -- ^ The `StgInfoTable` of the closure, extracted from the heap + -- representation. + -> 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. + -> [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. +getClosureDataFromHeapRepPrim getConDesc decodeCCS itbl heapRep pts = do + 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) <- getConDesc + pure $ ConstrClosure itbl pts npts p m n + + t | t >= THUNK && t <= THUNK_STATIC -> do + pure $ ThunkClosure itbl pts npts + + THUNK_SELECTOR -> do + unless (length pts >= 1) $ + fail "Expected at least 1 ptr argument to THUNK_SELECTOR" + pure $ SelectorClosure itbl (head pts) + + t | t >= FUN && t <= FUN_STATIC -> do + pure $ FunClosure itbl pts npts + + AP -> 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 payloadWords >= 2) $ + fail "Expected at least 2 raw words to AP" + let splitWord = payloadWords !! 0 + pure $ APClosure itbl +#if defined(WORDS_BIGENDIAN) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) +#else + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) +#endif + (head pts) (tail pts) + + PAP -> 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 payloadWords >= 2) $ + fail "Expected at least 2 raw words to PAP" + let splitWord = payloadWords !! 0 + pure $ PAPClosure itbl +#if defined(WORDS_BIGENDIAN) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) + (fromIntegral splitWord) +#else + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) +#endif + (head pts) (tail pts) + + AP_STACK -> do + unless (length pts >= 1) $ + fail "Expected at least 1 ptr argument to AP_STACK" + pure $ APStackClosure itbl (head pts) (tail pts) + + IND -> do + unless (length pts >= 1) $ + fail "Expected at least 1 ptr argument to IND" + pure $ IndClosure itbl (head pts) + + IND_STATIC -> do + unless (length pts >= 1) $ + fail "Expected at least 1 ptr argument to IND_STATIC" + pure $ IndClosure itbl (head pts) + + BLACKHOLE -> do + unless (length pts >= 1) $ + fail "Expected at least 1 ptr argument to BLACKHOLE" + pure $ BlackholeClosure itbl (head pts) + + BCO -> do + unless (length pts >= 3) $ + fail $ "Expected at least 3 ptr argument to BCO, found " + ++ show (length pts) + unless (length payloadWords >= 4) $ + fail $ "Expected at least 4 words to BCO, found " + ++ 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)) + (fromIntegral splitWord) +#else + (fromIntegral splitWord) + (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) +#endif + (drop 4 payloadWords) + + ARR_WORDS -> do + unless (length payloadWords >= 1) $ + fail $ "Expected at least 1 words to ARR_WORDS, found " + ++ 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 payloadWords >= 2) $ + fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " + ++ "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 payloadWords >= 1) $ + fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " + ++ "found " ++ show (length payloadWords) + pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts + + 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 + unless (length pts >= 3) $ + fail $ "Expected at least 3 ptrs to MVAR, found " + ++ show (length pts) + pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) + + BLOCKING_QUEUE -> + pure $ OtherClosure itbl pts rawHeapWords + -- pure $ BlockingQueueClosure itbl + -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) + + -- pure $ OtherClosure itbl pts rawHeapWords + -- + WEAK -> do + pure $ WeakClosure + { info = itbl + , cfinalizers = pts !! 0 + , key = pts !! 1 + , value = pts !! 2 + , finalizer = pts !! 3 + , weakLink = case drop 4 pts of + [] -> Nothing + [p] -> Just p + _ -> error $ "Expected 4 or 5 words in WEAK, found " ++ show (length pts) + } + TSO | [ u_lnk, u_gbl_lnk, tso_stack, u_trec, u_blk_ex, u_bq] <- pts + -> withArray rawHeapWords (\ptr -> do + fields <- FFIClosures.peekTSOFields decodeCCS 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 + -> 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 + }) + | otherwise + -> fail $ "Expected 0 ptr argument to STACK, found " + ++ show (length pts) + + _ -> + pure $ UnsupportedClosure itbl ===================================== libraries/ghc-heap/GHC/Exts/DecodeStack.hs ===================================== @@ -16,7 +16,8 @@ -- TODO: Find better place than top level. Re-export from top-level? module GHC.Exts.DecodeStack ( - decodeStack + decodeStack, + decodeStack' ) where import GHC.Exts.StackConstants ===================================== libraries/ghc-heap/GHC/Exts/Heap/Closures.hs ===================================== @@ -539,6 +539,7 @@ data TsoFlags | TsoFlagsUnknownValue Word32 -- ^ Please report this as a bug deriving (Eq, Show, Generic, Ord) +-- TODO: Fix this to include stack frames -- | For generic code, this function returns all referenced closures. allClosures :: GenClosure b -> [b] allClosures (ConstrClosure {..}) = ptrArgs ===================================== libraries/ghc-heap/tests/TestUtils.hs ===================================== @@ -8,7 +8,8 @@ module TestUtils ( assertEqual, assertThat, - assertStackInvariants + assertStackInvariants, + unbox ) where @@ -16,9 +17,11 @@ import Data.Array.Byte import GHC.Exts import GHC.Exts.DecodeStack import GHC.Exts.Heap +import GHC.Exts.Heap.Closures import GHC.Records import GHC.Stack (HasCallStack) import GHC.Stack.CloneStack +import Unsafe.Coerce (unsafeCoerce) assertEqual :: (HasCallStack, Monad m, Show a, Eq a) => a -> a -> m () assertEqual a b @@ -28,7 +31,7 @@ assertEqual a b assertThat :: (HasCallStack, Monad m) => String -> (a -> Bool) -> a -> m () assertThat s f a = if f a then pure () else error s -assertStackInvariants :: (HasCallStack, Monad m) => StackSnapshot -> [StackFrame] -> m () +assertStackInvariants :: (HasCallStack, Monad m) => StackSnapshot -> [Closure] -> m () assertStackInvariants stack decodedStack = do assertThat "Last frame is stop frame" @@ -47,7 +50,7 @@ class ToClosureTypes a where instance ToClosureTypes StackSnapshot where toClosureTypes = stackSnapshotToClosureTypes . foldStackToArrayClosure -instance ToClosureTypes StackFrame where +instance ToClosureTypes Closure where toClosureTypes = stackFrameToClosureTypes instance ToClosureTypes a => ToClosureTypes [a] where @@ -81,23 +84,25 @@ stackSnapshotToClosureTypes = wordsToClosureTypes . toWords toInt# :: Int -> Int# toInt# (I# i#) = i# -stackFrameToClosureTypes :: StackFrame -> [ClosureType] -stackFrameToClosureTypes sf = - case sf of - (UpdateFrame {updatee, ..}) -> UPDATE_FRAME : getClosureTypes updatee - (CatchFrame {handler, ..}) -> CATCH_FRAME : getClosureTypes handler - (CatchStmFrame {code, handler}) -> CATCH_STM_FRAME : getClosureTypes code ++ getClosureTypes handler - (CatchRetryFrame {first_code, alt_code, ..}) -> CATCH_RETRY_FRAME : getClosureTypes first_code ++ getClosureTypes alt_code - (AtomicallyFrame {code, result}) -> ATOMICALLY_FRAME : getClosureTypes code ++ getClosureTypes result - (UnderflowFrame {..}) -> [UNDERFLOW_FRAME] - StopFrame -> [STOP_FRAME] - (RetSmall {payload, ..}) -> RET_SMALL : getBitmapClosureTypes payload - (RetBig {payload}) -> RET_BIG : getBitmapClosureTypes payload - (RetFun {fun, payload, ..}) -> RET_FUN : getClosureTypes fun ++ getBitmapClosureTypes payload - (RetBCO {instrs, literals, ptrs, payload, ..}) -> - RET_BCO : getClosureTypes instrs ++ getClosureTypes literals ++ getClosureTypes ptrs ++ getBitmapClosureTypes payload +-- TODO: Can probably be simplified once all stack closures have into tables attached. +stackFrameToClosureTypes :: Closure -> [ClosureType] +stackFrameToClosureTypes = getClosureTypes where getClosureTypes :: Closure -> [ClosureType] + -- Stack frame closures + getClosureTypes (UpdateFrame {updatee, ..}) = UPDATE_FRAME : getClosureTypes (unbox updatee) + getClosureTypes (CatchFrame {handler, ..}) = CATCH_FRAME : getClosureTypes (unbox handler) + getClosureTypes (CatchStmFrame {catchFrameCode, handler}) = CATCH_STM_FRAME : getClosureTypes (unbox catchFrameCode) ++ getClosureTypes (unbox handler) + getClosureTypes (CatchRetryFrame {first_code, alt_code, ..}) = CATCH_RETRY_FRAME : getClosureTypes (unbox first_code) ++ getClosureTypes (unbox alt_code) + getClosureTypes (AtomicallyFrame {atomicallyFrameCode, result}) = ATOMICALLY_FRAME : getClosureTypes (unbox atomicallyFrameCode) ++ getClosureTypes (unbox result) + getClosureTypes (UnderflowFrame {..}) = [UNDERFLOW_FRAME] + getClosureTypes StopFrame = [STOP_FRAME] + getClosureTypes (RetSmall {payload, ..}) = RET_SMALL : getBitmapClosureTypes payload + getClosureTypes (RetBig {payload}) = RET_BIG : getBitmapClosureTypes payload + getClosureTypes (RetFun {retFunFun, retFunPayload, ..}) = RET_FUN : getClosureTypes (unbox retFunFun) ++ getBitmapClosureTypes retFunPayload + getClosureTypes (RetBCO {bcoInstrs, bcoLiterals, bcoPtrs, bcoPayload, ..}) = + RET_BCO : getClosureTypes (unbox bcoInstrs) ++ getClosureTypes (unbox bcoLiterals) ++ getClosureTypes (unbox bcoPtrs) ++ getBitmapClosureTypes bcoPayload + -- Other closures getClosureTypes (ConstrClosure {info, ..}) = [tipe info] getClosureTypes (FunClosure {info, ..}) = [tipe info] getClosureTypes (ThunkClosure {info, ..}) = [tipe info] @@ -122,13 +127,16 @@ stackFrameToClosureTypes sf = getClosureTypes (UnsupportedClosure {info, ..}) = [tipe info] getClosureTypes _ = [] - getBitmapClosureTypes :: [BitmapPayload] -> [ClosureType] + getBitmapClosureTypes :: [Box] -> [ClosureType] getBitmapClosureTypes bps = reverse $ foldl - ( \acc p -> case p of - (Closure c) -> getClosureTypes c ++ acc - (Primitive _) -> acc + ( \acc p -> case unbox p of + UnknownTypeWordSizedPrimitive _ -> acc + c -> getClosureTypes c ++ acc ) [] bps + +unbox :: Box -> Closure +unbox (Box c) = unsafeCoerce c ===================================== libraries/ghc-heap/tests/stack_big_ret.hs ===================================== @@ -10,7 +10,7 @@ import Data.Maybe import GHC.Exts (StackSnapshot#) import GHC.Exts.DecodeStack import GHC.Exts.Heap.ClosureTypes -import GHC.Exts.Heap.Closures qualified as CL +import GHC.Exts.Heap.Closures import GHC.Exts.Heap.InfoTable.Types import GHC.IO.Unsafe import GHC.Stack (HasCallStack) @@ -36,27 +36,27 @@ main = do mbStackSnapshot <- readIORef stackRef let stackSnapshot = fromJust mbStackSnapshot - !decodedStack <- decodeStack stackSnapshot + !decodedStack <- decodeStack' stackSnapshot assertStackInvariants stackSnapshot decodedStack assertThat "Stack contains one big return frame" (== 1) (length $ filter isBigReturnFrame decodedStack) - let xs = zip [1 ..] $ (payload . head) $ filter isBigReturnFrame decodedStack + let xs = zip [1 ..] $ (map unbox . payload . head) $ filter isBigReturnFrame decodedStack mapM_ (uncurry checkArg) xs -checkArg :: Word -> BitmapPayload -> IO () +checkArg :: Word -> Closure -> IO () checkArg w bp = case bp of - Primitive _ -> error "Unexpected payload type from bitmap." - Closure c -> do - assertEqual CONSTR_0_1 $ (tipe . CL.info) c - assertEqual "I#" (CL.name c) - assertEqual "ghc-prim" (CL.pkg c) - assertEqual "GHC.Types" (CL.modl c) - assertEqual True $ (null . CL.ptrArgs) c - assertEqual [w] (CL.dataArgs c) + UnknownTypeWordSizedPrimitive _ -> error "Unexpected payload type from bitmap." + c -> do + assertEqual CONSTR_0_1 $ (tipe . info) c + assertEqual "I#" (name c) + assertEqual "ghc-prim" (pkg c) + assertEqual "GHC.Types" (modl c) + assertEqual True $ (null . ptrArgs) c + assertEqual [w] (dataArgs c) pure () isBigReturnFrame (RetBig _) = True ===================================== libraries/ghc-heap/tests/stack_misc_closures.c ===================================== @@ -0,0 +1,20 @@ +#include "Rts.h" +#include "RtsAPI.h" +#include "rts/Messages.h" +#include "rts/Types.h" +#include "rts/storage/ClosureMacros.h" +#include "rts/storage/Closures.h" +#include "stg/Types.h" +#include + +StgStack *update_frame() { + Capability *cap = rts_lock(); + StgWord closureSizeBytes = sizeof(StgStack) + sizeof(StgStopFrame) + sizeof(StgUpdateFrame); + StgStack *stack = (StgStack*) allocate(cap, ROUNDUP_BYTES_TO_WDS(closureSizeBytes)); + SET_HDR(stack, &, CCS_SYSTEM); + stack->stack_size = closureSizeBytes; + stack->dirty = 0; + stack->marking = 0; + rts_unlock(cap); + return stack; +} ===================================== libraries/ghc-heap/tests/stack_misc_closures.hs ===================================== ===================================== libraries/ghc-heap/tests/stack_stm_frames.hs ===================================== @@ -3,6 +3,7 @@ module Main where import Control.Concurrent.STM import Control.Exception import GHC.Conc +import GHC.Exts.Heap.Closures import GHC.Exts.DecodeStack import GHC.Stack.CloneStack import TestUtils @@ -23,16 +24,16 @@ main = do (== 1) (length $ filter isAtomicallyFrame decodedStack) -getDecodedStack :: IO (StackSnapshot, [StackFrame]) +getDecodedStack :: IO (StackSnapshot, [Closure]) getDecodedStack = do s <-cloneMyStack - fs <- decodeStack s + fs <- decodeStack' s pure (s, fs) -isCatchStmFrame :: StackFrame -> Bool +isCatchStmFrame :: Closure -> Bool isCatchStmFrame (CatchStmFrame _ _) = True isCatchStmFrame _ = False -isAtomicallyFrame :: StackFrame -> Bool +isAtomicallyFrame :: Closure -> Bool isAtomicallyFrame (AtomicallyFrame _ _) = True isAtomicallyFrame _ = False ===================================== libraries/ghc-heap/tests/stack_underflow.hs ===================================== @@ -3,6 +3,7 @@ module Main where import Data.Bool (Bool (True)) +import GHC.Exts.Heap.Closures import GHC.Exts.DecodeStack import GHC.Stack (HasCallStack) import GHC.Stack.CloneStack @@ -17,7 +18,7 @@ loop n = print "x" >> loop (n - 1) >> print "x" getStack :: HasCallStack => IO () getStack = do !s <- cloneMyStack - !decodedStack <- decodeStack s + !decodedStack <- decodeStack' s -- Uncomment to see the frames (for debugging purposes) -- hPutStrLn stderr $ "Stack frames : " ++ show decodedStack assertStackInvariants s decodedStack @@ -31,7 +32,7 @@ getStack = do isUnderflowFrame (UnderflowFrame _) = True isUnderflowFrame _ = False -assertStackChunksAreDecodable :: HasCallStack => [StackFrame] -> IO () +assertStackChunksAreDecodable :: HasCallStack => [Closure] -> IO () assertStackChunksAreDecodable s = do let underflowFrames = filter isUnderflowFrame s framesOfChunks <- mapM (decodeStack . nextChunk) underflowFrames View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/651d7b71c7d614f1a90e924bf42c9aabe9ae3e54 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/651d7b71c7d614f1a90e924bf42c9aabe9ae3e54 You're receiving 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 Dec 11 16:59:35 2022 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Sun, 11 Dec 2022 11:59:35 -0500 Subject: [Git][ghc/ghc][wip/decode_cloned_stack] 772 commits: TTG: Move HsModule to L.H.S Message-ID: <63960c7749b89_224fcabe792c0105513a@gitlab.mail> Sven Tennie pushed to branch wip/decode_cloned_stack at Glasgow Haskell Compiler / GHC Commits: 3a8970ac by romes at 2022-07-03T14:11:31-04:00 TTG: Move HsModule to L.H.S Move the definition of HsModule defined in GHC.Hs to Language.Haskell.Syntax with an added TTG parameter and corresponding extension fields. This is progress towards having the haskell-syntax package, as described in #21592 - - - - - f9f80995 by romes at 2022-07-03T14:11:31-04:00 TTG: Move ImpExp client-independent bits to L.H.S.ImpExp Move the GHC-independent definitions from GHC.Hs.ImpExp to Language.Haskell.Syntax.ImpExp with the required TTG extension fields such as to keep the AST independent from GHC. This is progress towards having the haskell-syntax package, as described in #21592 Bumps haddock submodule - - - - - c43dbac0 by romes at 2022-07-03T14:11:31-04:00 Refactor ModuleName to L.H.S.Module.Name ModuleName used to live in GHC.Unit.Module.Name. In this commit, the definition of ModuleName and its associated functions are moved to Language.Haskell.Syntax.Module.Name according to the current plan towards making the AST GHC-independent. The instances for ModuleName for Outputable, Uniquable and Binary were moved to the module in which the class is defined because these instances depend on GHC. The instance of Eq for ModuleName is slightly changed to no longer depend on unique explicitly and instead uses FastString's instance of Eq. - - - - - 2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00 Expand `Ord` instance for `Down` Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610 - - - - - 36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00 Add applyWhen to Data.Function per CLC prop Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233 - - - - - 3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00 hadrian: Don't read package environments in ghc-stage1 wrapper The stage1 compiler may be on the brink of existence and not have even a working base library. You may have installed packages globally with a similar stage2 compiler which will then lead to arguments such as --show-iface not even working because you are passing too many package flags. The solution is simple, don't read these implicit files. Fixes #21803 - - - - - aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00 Ticky:Make json info a separate field. Fixes #21233 - - - - - 74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00 Add docs:<pkg> command to hadrian to build docs for just one package - - - - - 418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00 upload-docs: propagate publish correctly in upload_sdist - - - - - ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00 docs-upload: Fix upload script when no packages are listed - - - - - d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00 hadrian: Add --haddock-base-url option for specifying base-url when generating docs The motiviation for this flag is to be able to produce documentation which is suitable for uploading for hackage, ie, the cross-package links work correctly. There are basically three values you want to set this to: * off - default, base_url = ../%pkg% which works for local browsing * on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload * on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation. The `%pkg%` string is a template variable which is replaced with the package identifier for the relevant package. This is one step towards fixing #21749 - - - - - 41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00 Add nightly job for generating docs suitable for hackage upload - - - - - 620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00 ghci: Support :set prompt in multi repl This adds supports for various :set commands apart from `:set <FLAG>` in multi repl, this includes `:set prompt` and so-on. Fixes #21796 - - - - - b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00 Vendor filepath inside template-haskell Adding filepath as a dependency of template-haskell means that it can't be reinstalled if any build-plan depends on template-haskell. This is a temporary solution for the 9.4 release. A longer term solution is to split-up the template-haskell package into the wired-in part and a non-wired-in part which can be reinstalled. This was deemed quite risky on the 9.4 release timescale. Fixes #21738 - - - - - c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00 Factor fields of `CoreDoSimplify` into separate data type This avoids some partiality. The work @mmhat is doing cleaning up and modularizing `Core.Opt` will build on this nicely. - - - - - d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00 https urls - - - - - 803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00 options and typos - - - - - 5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00 grammar - - - - - 4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00 sources - - - - - c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00 Fix lint warnings in bootstrap.py - - - - - 86ced2ad by romes at 2022-07-06T01:36:23-04:00 Restore Eq instance of ImportDeclQualifiedStyle Fixes #21819 - - - - - 3547e264 by romes at 2022-07-06T13:50:27-04:00 Prune L.H.S modules of GHC dependencies Move around datatypes, functions and instances that are GHC-specific out of the `Language.Haskell.Syntax.*` modules to reduce the GHC dependencies in them -- progressing towards #21592 Creates a module `Language.Haskell.Syntax.Basic` to hold basic definitions required by the other L.H.S modules (and don't belong in any of them) - - - - - e4eea07b by romes at 2022-07-06T13:50:27-04:00 TTG: Move CoreTickish out of LHS.Binds Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and move them to the extension point instance, according to the plan outlined in #21592 to separate the base AST from the GHC specific bits. - - - - - acc1816b by romes at 2022-07-06T13:50:27-04:00 TTG for ForeignImport/Export Add a TTG parameter to both `ForeignImport` and `ForeignExport` and, according to #21592, move the GHC-specific bits in them and in the other AST data types related to foreign imports and exports to the TTG extension point. - - - - - 371c5ecf by romes at 2022-07-06T13:50:27-04:00 TTG for HsTyLit Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText` fields to the extension point and out of the base AST. Progress towards #21592 - - - - - fd379d1b by romes at 2022-07-06T13:50:27-04:00 Remove many GHC dependencies from L.H.S Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC imports according to the plan in the linked issue. Moves more GHC-specific declarations to `GHC.*` and brings more required GHC-independent declarations to `Language.Haskell.Syntax.*` (extending e.g. `Language.Haskell.Syntax.Basic`). Progress towards #21592 Bump haddock submodule for !8308 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00 Fix exact printing of the HsRule name Prior to this branch, the HsRule name was XRec pass (SourceText,RuleName) and there is an ExactPrint instance for (SourceText, RuleName). The SourceText has moved to a different location, so synthesise the original to trigger the correct instance when printing. We need both the SourceText and RuleName when exact printing, as it is possible to have a NoSourceText variant, in which case we fall back to the FastString. - - - - - 665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00 driver: Fix issue with module loops and multiple home units We were attempting to rehydrate all dependencies of a particular module, but we actually only needed to rehydrate those of the current package (as those are the ones participating in the loop). This fixes loading GHC into a multi-unit session. Fixes #21814 - - - - - bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00 Remove a bogus #define from ClosureMacros.h - - - - - fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00 winio: make consoleReadNonBlocking not wait for any events at all. - - - - - 42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00 rts: allow NULL to be used as an invalid StgStablePtr - - - - - 3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00 RTS: Add stack marker to StgCRunAsm.S Every object file must be properly marked for non-executable stack, even if it contains no code. - - - - - a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00 Bump unix submodule Adds `config.sub` to unix's `.gitignore`, fixing #19574. - - - - - 3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00 ghci: Fix most calls to isLoaded to work in multi-mode The most egrarious thing this fixes is the report about the total number of loaded modules after starting a session. Ticket #20889 - - - - - fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00 Enable :edit command in ghci multi-mode. This works after the last change to isLoaded. Ticket #20888 - - - - - 46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00 Fix a scoping bug in the Specialiser In the call to `specLookupRule` in `already_covered`, in `specCalls`, we need an in-scope set that includes the free vars of the arguments. But we simply were not guaranteeing that: did not include the `rule_bndrs`. Easily fixed. I'm not sure how how this bug has lain for quite so long without biting us. Fixes #21828. - - - - - 6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Edit Note [idArity varies independently of dmdTypeDepth] ...and refer to it in GHC.Core.Lint.lintLetBind. Fixes #21452 - - - - - 89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Tiny documentation wibbles (comments only) - - - - - 61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix readme - - - - - 61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix bootstrap - - - - - 8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00 tarball - - - - - e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Fix scopes for deriving clauses and instance signatures (#18425) - - - - - c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Record location of filled in default method bindings This is useful for hie files to reconstruct the evidence that default methods depend on. - - - - - 9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00 testsuite: Factor out common parts from hiefile tests - - - - - 6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00 Hadrian: update documentation of settings The documentation for key-value settings was a bit out of date. This patch updates it to account for `cabal.configure.opts` and `hsc2hs.run.opts`. The user-settings document was also re-arranged, to make the key-value settings more prominent (as it doesn't involve changing the Hadrian source code, and thus doesn't require any recompilation of Hadrian). - - - - - a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00 Fix potential space leak that arise from ModuleGraphs retaining references to previous ModuleGraphs, in particular the lazy `mg_non_boot` field. This manifests in `extendMG`. Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which is only called in two places in the compiler, and should only be called at most once for every home unit: GHC.Driver.Make: mainModuleSrcPath :: Maybe String mainModuleSrcPath = do ms <- mgLookupModule mod_graph (mainModIs hue) ml_hs_file (ms_location ms) GHCI.UI: listModuleLine modl line = do graph <- GHC.getModuleGraph let this = GHC.mgLookupModule graph modl Instead `mgLookupModule` can be a linear function that looks through the entire list of `ModuleGraphNodes` Fixes #21816 - - - - - dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00 rts: Fix AdjustorPool bitmap manipulation Previously the implementation of bitmap_first_unset assumed that `__builtin_clz` would accept `uint8_t` however it apparently rather extends its argument to `unsigned int`. To fix this we simply revert to a naive implementation since handling the various corner cases with `clz` is quite tricky. This should be fine given that AdjustorPool isn't particularly hot. Ideally we would have a single, optimised bitmap implementation in the RTS but I'll leave this for future work. Fixes #21838. - - - - - ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00 Change GHCi bytecode return convention for unlifted datatypes. This changes the bytecode return convention for unlifted algebraic datatypes to be the same as for lifted types, i.e. ENTER/PUSH_ALTS instead of RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED Fixes #20849 - - - - - 5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00 Compute record-dot-syntax types Ensures type information for record-dot-syntax is included in HieASTs. See #21797 - - - - - 89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00 Add record-dot-syntax test - - - - - 4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00 Document RuntimeRep polymorphism limitations of catch#, et al As noted in #21868, several primops accepting continuations producing RuntimeRep-polymorphic results aren't nearly as polymorphic as their types suggest. Document this limitation and adapt the `UnliftedWeakPtr` test to avoid breaking this limitation in `keepAlive#`. - - - - - 4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00 Make keepAlive# out-of-line This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203 - - - - - 1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00 Suppress extra output from configure check for c++ libraries - - - - - 3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00 rel-notes: Drop mention of #21745 fix Since we have backported the fix to 9.4.1. - - - - - b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00 Align the behaviour of `dopt` and `log_dopt` Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying function `log_dopt`) were different as the latter did not take the verbosity level into account. This led to problems during the refactoring as we cannot simply replace calls to `dopt` with calls to `logHasDumpFlag`. In addition to that a subtle bug in the GHC module was fixed: `setSessionDynFlags` did not update the logger and as a consequence the verbosity value of the logger was not set appropriately. Fixes #21861 - - - - - 28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00 rts: forkOn context switches the target capability Fixes #21824 - - - - - f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Eliminate orphan Outputable instances Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and `OutputableP` instances for the Cmm AST. This makes it significantly easier to use the Cmm pretty-printers in tracing output without incurring module import cycles. - - - - - f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Move toBlockList to GHC.Cmm - - - - - fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00 compiler: Add haddock sections to GHC.Utils.Panic - - - - - 097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00 configure: Don't override Windows CXXFLAGS At some point we used the clang distribution from msys2's `MINGW64` environment for our Windows toolchain. This defaulted to using libgcc and libstdc++ for its runtime library. However, we found for a variety of reasons that compiler-rt, libunwind, and libc++ were more reliable, consequently we explicitly overrode the CXXFLAGS to use these. However, since then we have switched to use the `CLANG64` packaging, which default to these already. Consequently we can drop these arguments, silencing some redundant argument warnings from clang. Fixes #21669. - - - - - e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Check that there are no NULL ctors - - - - - 616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Introduce support for invoking finalizers on unload Addresses #20494. - - - - - cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add T20494 - - - - - 03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Rename finit field to fini fini is short for "finalizer", which does not contain a "t". - - - - - 033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Refactor handling of oc->info Previously we would free oc->info after running initializers. However, we can't do this is we want to also run finalizers. Moreover, freeing oc->info so early was wrong for another reason: we will need it in order to unregister the exception tables (see the call to `RtlDeleteFunctionTable`). In service of #20494. - - - - - f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Add finalization support This implements #20494 for the PEi386 linker. Happily, this also appears to fix `T9405`, resolving #21361. - - - - - 2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00 Loader: Implement gnu-style -l:$path syntax Gnu ld allows `-l` to be passed an absolute file path, signalled by a `:` prefix. Implement this in the GHC's loader search logic. - - - - - 5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00 Statically-link against libc++ on Windows Unfortunately on Windows we have no RPATH-like facility, making dynamic linking extremely fragile. Since we cannot assume that the user will add their GHC installation to `$PATH` (and therefore their DLL search path) we cannot assume that the loader will be able to locate our `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on Windows. Fixes #21435. - - - - - 8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run It turns out that PE objects may have multiple `.ctors`/`.dtors` sections but the RTS linker had assumed that there was only one. Fix this. Fixes #21618. - - - - - fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Respect dtor/ctor priority Previously we would run constructors and destructors in arbitrary order despite explicit priorities. Fixes #21847. - - - - - 1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add test for #21618 and #21847 - - - - - 6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Fix exception unwind unregistration RtlDeleteFunctionTable expects a pointer to the .pdata section yet we passed it the .xdata section. Happily, this fixes #21354. - - - - - d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Drop dead code - - - - - d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Use section flags to identify initializers - - - - - fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Introduce finalizer support - - - - - 5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl - - - - - 6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker/Elf: Work around GCC 6 init/fini behavior It appears that GCC 6t (at least on i386) fails to give init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY section types, instead marking them as SHT_PROGBITS. This caused T20494 to fail on Debian. - - - - - 5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Mark T13366Cxx as unbroken on Darwin - - - - - 1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Fix resolution of __dso_handle on Darwin Darwin expects a leading underscore. - - - - - a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Clean up section kinds - - - - - aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Ensure that __cxa_finalize is called on code unload - - - - - 028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00 testsuite: Fix T11829 on Centos 7 It appears that Centos 7 has a more strict C++ compiler than most distributions since std::runtime_error is defined in <stdexcept> rather than <exception>. In T11829 we mistakenly imported the latter. - - - - - a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00 hadrian: Rename documentation directories for consistency with make * Rename `docs` to `doc` * Place pdf documentation in `doc/` instead of `doc/pdfs/` Fixes #21164. - - - - - b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00 Fix incorrect proof of applyWhen’s properties - - - - - eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00 hadrian: Add multi:<pkg> and multi targets for starting a multi-repl This patch adds support to hadrian for starting a multi-repl containing all the packages which stage0 can build. In particular, there is the new user-facing command: ``` ./hadrian/ghci-multi ``` which when executed will start a multi-repl containing the `ghc` package and all it's dependencies. This is implemented by two new hadrian targets: ``` ./hadrian/build multi:<pkg> ``` Construct the arguments for a multi-repl session where the top-level package is <pkg>. For example, `./hadrian/ghci-multi` is implemented using `multi:ghc` target. There is also the `multi` command which constructs a repl for everything in stage0 which we can build. - - - - - 19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00 changelog typo - - - - - af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00 typos - - - - - 415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00 Refactor SpecConstr to use treat bindings uniformly This patch, provoked by #21457, simplifies SpecConstr by treating top-level and nested bindings uniformly (see the new scBind). * Eliminates the mysterious scTopBindEnv * Refactors scBind to handle top-level and nested definitions uniformly. * But, for now at least, continues the status quo of not doing SpecConstr for top-level non-recursive bindings. (In contrast we do specialise nested non-recursive bindings, although the original paper did not; see Note [Local let bindings].) I tried the effect of specialising top-level non-recursive bindings (which is now dead easy to switch on, unlike before) but found some regressions, so I backed off. See !8135. It's a pure refactoring. I think it'll do a better job in a few cases, but there is no regression test. - - - - - d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00 Rule matching: Don't compute the FVs if we don't look at them. - - - - - 5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 White space only in FamInstEnv - - - - - ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make transferPolyIdInfo work for CPR I don't know why this hasn't bitten us before, but it was plain wrong. - - - - - 9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Inline mapAccumLM This function is called in inner loops in the compiler, and it's overloaded and higher order. Best just to inline it. This popped up when I was looking at something else. I think perhaps GHC is delicately balanced on the cusp of inlining this automatically. - - - - - d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make SetLevels honour floatConsts This fix, in the definition of profitableFloat, is just for consistency. `floatConsts` should do what it says! I don't think it'll affect anything much, though. - - - - - d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Refactor wantToUnboxArg a bit * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg and similarly wantToUnboxResult to canUnboxResult. * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg, avoiding some yukky duplication. I decided it was clearer to give it a new data type for its return type, because I nedeed the FD_RecBox case which was not otherwise readiliy expressible. * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload * Get rid of the Unlift constructor of UnboxingDecision, eliminate two panics, and two arguments to canUnboxArg (new name). Much nicer now. - - - - - 6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00 Allow running memInventory when the concurrent nonmoving gc is enabled If the nonmoving gc is enabled and we are using a threaded RTS, we now try to grab the collector mutex to avoid memInventory and the collection racing. Before memInventory was disabled. - - - - - aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00 gitignore: don't ignore all aclocal.m4 files While GHC's own aclocal.m4 is generated by the aclocal tool, other packages' aclocal.m4 are committed in the repository. Previously `.gitignore` included an entry which covered *any* file named `aclocal.m4`, which lead to quite some confusion (e.g. see #21740). Fix this by modifying GHC's `.gitignore` to only cover GHC's own `aclocal.m4`. - - - - - 4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00 Add mapAccumM, forAccumM to Data.Traversable Approved by Core Libraries Committee in https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433 - - - - - bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00 configure: Use AC_PATH_TOOL to detect tools Previously we used AC_PATH_PROG which, as noted by #21601, does not look for tools with a target prefix, breaking cross-compilation. Fixes #21601. - - - - - e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00 driver: Fix implementation of -S We were failing to stop before running the assembler so the object file was also created. Fixes #21869 - - - - - e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00 rts/ProfHeap: Ensure new Censuses are zeroed When growing the Census array ProfHeap previously neglected to zero the new part of the array. Consequently `freeEra` would attempt to free random words that often looked suspiciously like pointers. Fixes #21880. - - - - - 81d65f7f by sheaf at 2022-07-21T15:37:22+02:00 Make withDict opaque to the specialiser As pointed out in #21575, it is not sufficient to set withDict to inline after the typeclass specialiser, because we might inline withDict in one module and then import it in another, and we run into the same problem. This means we could still end up with incorrect runtime results because the typeclass specialiser would assume that distinct typeclass evidence terms at the same type are equal, when this is not necessarily the case when using withDict. Instead, this patch introduces a new magicId, 'nospec', which is only inlined in CorePrep. We make use of it in the definition of withDict to ensure that the typeclass specialiser does not common up distinct typeclass evidence terms. Fixes #21575 - - - - - 9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00 Refactored Simplify pass * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify namespace and GHC.Core.Opt.Stats. Also removed services from configuration records. * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration. * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm` and moved the Simplify driver to GHC.Core.Opt.Simplify. * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env. * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment in GHC.Core.Opt.Simplify.Monad. * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions for those in a new module GHC.Driver.Config.Core.Opt.Simplify. Also added initialization functions for `SimplMode` to that module. * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types and the counting types and functions (`SimplCount` and `Tick`) to new module GHC.Core.Opt.Stats. * Added getter functions for the fields of `SimplMode`. The pedantic bottoms option and the platform are retrieved from the ArityOpts and RuleOpts and the getter functions allow us to retrieve values from `SpecEnv` without the knowledge where the data is stored exactly. * Moved the coercion optimization options from the top environment to `SimplMode`. This way the values left in the top environment are those dealing with monadic functionality, namely logging, IO related stuff and counting. Added a note "The environments of the Simplify pass". * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead. * Prep work before removing `InteractiveContext` from `HscEnv`. - - - - - 2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00 Make the specialiser deal better with specialised methods This patch fixes #21848, by being more careful to update unfoldings in the type-class specialiser. See the new Note [Update unfolding after specialisation] Now that we are being so much more careful about unfoldings, it turned out that I could dispense with se_interesting, and all its tricky corners. Hooray. This fixes #21368. - - - - - ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00 ghc-boot: Clean up UTF-8 codecs In preparation for moving the UTF-8 codecs into `base`: * Move them to GHC.Utils.Encoding.UTF8 * Make names more consistent * Add some Haddocks - - - - - e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00 base: Introduce GHC.Encoding.UTF8 Here we copy a subset of the UTF-8 implementation living in `ghc-boot` into `base`, with the intent of dropping the former in the future. For this reason, the `ghc-boot` copy is now CPP-guarded on `MIN_VERSION_base(4,18,0)`. Naturally, we can't copy *all* of the functions defined by `ghc-boot` as some depend upon `bytestring`; we rather just copy those which only depend upon `base` and `ghc-prim`. Further consolidation? ---------------------- Currently GHC ships with at least five UTF-8 implementations: * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this can be used at a number of types including `Addr#`, `ByteArray#`, `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this can be removed in GHC 9.6+2, when the copies in `base` will become available to `ghc-boot`. * the copy of the `ghc-boot` definition now exported by `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`, `ByteArray#`, and `ForeignPtr` * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`; this is specialised at `Addr#`. * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`; this is specialised at `Addr#` but, unlike the above, supports recovery in the presence of partial codepoints (since in IO contexts codepoints may be broken across buffers) * the implementation provided by the `text` library This does seem a tad silly. On the other hand, these implementations *do* materially differ from one another (e.g. in the types they support, the detail in errors they can report, and the ability to recover from partial codepoints). Consequently, it's quite unclear that further consolidate would be worthwhile. - - - - - f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00 Add a Note summarising GHC's UTF-8 implementations GHC has a somewhat dizzying array of UTF-8 implementations. This note describes why this is the case. - - - - - 72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00 upload_ghc_libs: Fix path to documentation The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35 but this one occurrence was note updated. Finally closes #21164. - - - - - a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00 Add test for #21871 This adds a test for #21871, which was fixed by the No Skolem Info rework (MR !7105). Fixes #21871 - - - - - 6379f942 by sheaf at 2022-07-22T08:18:46-04:00 Add test for #21360 The way record updates are typechecked/desugared changed in MR !7981. Because we desugar in the typechecker to a simple case expression, the pattern match checker becomes able to spot the long-distance information and avoid emitting an incorrect pattern match warning. Fixes #21360 - - - - - ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00 Hadrian: don't try to build "unix" on Windows - - - - - dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Implement DeepSubsumption This MR adds the language extension -XDeepSubsumption, implementing GHC proposal #511. This change mitigates the impact of GHC proposal The changes are highly localised, by design. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. The main changes are: * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010, but off in Haskell2021. -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change. -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds: it makes type inference more complicated and less predictable, but it may be convenient in practice. * The main changes are in: * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result type. Without deep subsumption, unifyExpectedType would be sufficent. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. * There are no changes to Quick Look at all. * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to GHC.Magic.Dict * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where we'd forgotten to take the free vars of the multiplicity of an Id. * I also had to fix tcSplitNestedSigmaTys When I did the shallow-subsumption patch commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f Date: Sun Feb 2 18:23:11 2020 +0000 Simple subsumption I changed tcSplitNestedSigmaTys to not look through function arrows any more. But that was actually an un-forced change. This function is used only in * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect All to do with validity checking and error messages. Acutally its fine to look under function arrows here, and quite useful a test DeepSubsumption05 (a test motivated by a build failure in the `lens` package) shows. The fix is easy. I added Note [tcSplitNestedSigmaTys]. - - - - - e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption - - - - - 67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add DeepSubsumption08 - - - - - 5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Fix the interaction of operator sections and deep subsumption Fixes DeepSubsumption08 - - - - - 918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00 Add DeepSubsumption09 - - - - - 2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00 Default implementation for mempty/(<>) Approved by: https://github.com/haskell/core-libraries-committee/issues/61 This adds a default implementation for `mempty` and `(<>)` along with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid` instances can be defined in terms of `sconcat` / `mconcat`. The description for each class has also been updated to include the equivalent set of laws for the `sconcat`-only / `mconcat`-only instances. - - - - - 73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00 ci: Disable (broken) perf-nofib See #21859 - - - - - c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00 Docs: clarify ConstraintKinds infelicity GHC doesn't consistently require the ConstraintKinds extension to be enabled, as it allows programs such as type families returning a constraint without this extension. MR !7784 fixes this infelicity, but breaking user programs was deemed to not be worth it, so we document it instead. Fixes #21061. - - - - - 5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00 More improvements to worker/wrapper This patch fixes #21888, and simplifies finaliseArgBoxities by eliminating the (recently introduced) data type FinalDecision. A delicate interaction meant that this patch commit d1c25a48154236861a413e058ea38d1b8320273f Date: Tue Jul 12 16:33:46 2022 +0100 Refactor wantToUnboxArg a bit make worker/wrapper go into an infinite loop. This patch fixes it by narrowing the handling of case (B) of Note [Boxity for bottoming functions], to deal only the arguemnts that are type variables. Only then do we drop the trimBoxity call, which is what caused the bug. I also * Added documentation of case (B), which was previously completely un-mentioned. And a regression test, T21888a, to test it. * Made unboxDeeplyDmd stop at lazy demands. It's rare anyway for a bottoming function to have a lazy argument (mainly when the data type is recursive and then we don't want to unbox deeply). Plus there is Note [No lazy, Unboxed demands in demand signature] * Refactored the Case equation for dmdAnal a bit, to do less redundant pattern matching. - - - - - b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00 Fix a small buglet in tryEtaReduce Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was making an ill-formed cast. It didn't matter, because the subsequent guard discarded it; but still worth fixing. Spurious warnings are distracting. - - - - - 3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00 Fix #21889, GHCi misbehaves with Ctrl-C on Windows On Windows, we create multiple levels of wrappers for GHCi which ultimately execute ghc --interactive. In order to handle console events properly, each of these wrappers must call FreeConsole() in order to hand off event processing to the child process. See #14150. In addition to this, FreeConsole must only be called from interactive processes (#13411). This commit makes two changes to fix this situation: 1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole` if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi. 2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`: Before: ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe After: ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe - - - - - 79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00 docs: Fix documentation of \cases Fixes #21902. - - - - - e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00 ghc-cabal: allow Cabal 3.8 to unbreak make build When bootstrapping GHC 9.4.*, the build will fail when configuring ghc-cabal as part of the make based build system due to this upper bound, as Cabal has been updated to a 3.8 release. Reference #21914, see especially https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699 - - - - - 726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Fix isEvaldUnfolding and isValueUnfolding This fixes (1) in #21831. Easy, obviously correct. - - - - - 5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Switch off eta-expansion in rules and unfoldings I think this change will make little difference except to reduce clutter. But that's it -- if it causes problems we can switch it on again. - - - - - d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Teach SpecConstr about typeDeterminesValue This patch addresses #21831, point 2. See Note [generaliseDictPats] in SpecConstr I took the opportunity to refactor the construction of specialisation rules a bit, so that the rule name says what type we are specialising at. Surprisingly, there's a 20% decrease in compile time for test perf/compiler/T18223. I took a look at it, and the code size seems the same throughout. I did a quick ticky profile which seemed to show a bit less substitution going on. Hmm. Maybe it's the "don't do eta-expansion in stable unfoldings" patch, which is part of the same MR as this patch. Anyway, since it's a move in the right direction, I didn't think it was worth looking into further. Metric Decrease: T18223 - - - - - 65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Add a 'notes' file in testsuite/tests/perf/compiler This file is just a place to accumlate notes about particular benchmarks, so that I don't keep re-inventing the wheel. - - - - - 61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00 Get the in-scope set right in FamInstEnv.injectiveBranches There was an assert error, as Gergo pointed out in #21896. I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs. And also to GHC.Core.Unify.niFixTCvSubst. I also took the opportunity to get a couple more InScopeSets right, and to change some substTyUnchecked into substTy. This MR touches a lot of other files, but only because I also took the opportunity to introduce mkInScopeSetList, and use it. - - - - - 4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00 Add location to cc phase - - - - - 96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00 Avoid as pipeline when compiling c - - - - - 2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00 testsuite: Skip test cases involving -S when testing unregisterised GHC We no longer generate .s files anyway. Metric Decrease: MultiLayerModules T10421 T13035 T13701 T14697 T16875 T18140 T18304 T18923 T9198 - - - - - 82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00 testsuite: introduce nonmoving_thread_sanity way (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae) - - - - - 4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Track segment state It can often be useful during debugging to be able to determine the state of a nonmoving segment. Introduce some state, enabled by DEBUG, to track this. (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f) - - - - - 54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Don't scavenge objects which weren't evacuated This fixes a rather subtle bug in the logic responsible for scavenging objects evacuated to the non-moving generation. In particular, objects can be allocated into the non-moving generation by two ways: a. evacuation out of from-space by the garbage collector b. direct allocation by the mutator Like all evacuation, objects moved by (a) must be scavenged, since they may contain references to other objects located in from-space. To accomplish this we have the following scheme: * each nonmoving segment's block descriptor has a scan pointer which points to the first object which has yet to be scavenged * the GC tracks a set of "todo" segments which have pending scavenging work * to scavenge a segment, we scavenge each of the unmarked blocks between the scan pointer and segment's `next_free` pointer. We skip marked blocks since we know the allocator wouldn't have allocated into marked blocks (since they contain presumably live data). We can stop at `next_free` since, by definition, the GC could not have evacuated any objects to blocks above `next_free` (otherwise `next_free wouldn't be the first free block). However, this neglected to consider objects allocated by path (b). In short, the problem is that objects directly allocated by the mutator may become unreachable (but not swept, since the containing segment is not yet full), at which point they may contain references to swept objects. Specifically, we observed this in #21885 in the following way: 1. the mutator (specifically in #21885, a `lockCAF`) allocates an object (specifically a blackhole, which here we will call `blkh`; see Note [Static objects under the nonmoving collector] for the reason why) on the non-moving heap. The bitmap of the allocated block remains 0 (since allocation doesn't affect the bitmap) and the containing segment's (which we will call `blkh_seg`) `next_free` is advanced. 2. We enter the blackhole, evaluating the blackhole to produce a result (specificaly a cons cell) in the nursery 3. The blackhole gets updated into an indirection pointing to the cons cell; it is pushed to the generational remembered set 4. we perform a GC, the cons cell is evacuated into the nonmoving heap (into segment `cons_seg`) 5. the cons cell is marked 6. the GC concludes 7. the CAF and blackhole become unreachable 8. `cons_seg` is filled 9. we start another GC; the cons cell is swept 10. we start a new GC 11. something is evacuated into `blkh_seg`, adding it to the "todo" list 12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks between `scan` and `next_free`, which includes `blkh`). We attempt to evacuate `blkh`'s indirectee, which is the previously-swept cons cell. This is unsafe, since the indirectee is no longer a valid heap object. The problem here was that the scavenging logic *assumed* that (a) was the only source of allocations into the non-moving heap and therefore *all* unmarked blocks between `scan` and `next_free` were evacuated. However, due to (b) this is not true. The solution is to ensure that that the scanned region only encompasses the region of objects allocated during evacuation. We do this by updating `scan` as we push the segment to the todo-segment list to point to the block which was evacuated into. Doing this required changing the nonmoving scavenging implementation's update of the `scan` pointer to bump it *once*, instead of after scavenging each block as was done previously. This is because we may end up evacuating into the segment being scavenged as we scavenge it. This was quite tricky to discover but the result is quite simple, demonstrating yet again that global mutable state should be used exceedingly sparingly. Fixes #21885 (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060) - - - - - 25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00 testsuite: Skip a few tests as in the nonmoving collector Residency monitoring under the non-moving collector is quite conservative (e.g. the reported value is larger than reality) since otherwise we would need to block on concurrent collection. Skip a few tests that are sensitive to residency. (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70) - - - - - 42147534 by sternenseemann at 2022-07-26T16:26:53-04:00 hadrian: add flag disabling selftest rules which require QuickCheck The hadrian executable depends on QuickCheck for building, meaning this library (and its dependencies) will need to be built for bootstrapping GHC in the future. Building QuickCheck, however, can require TemplateHaskell. When building a statically linking GHC toolchain, TemplateHaskell can be tricky to get to work, and cross-compiling TemplateHaskell doesn't work at all without -fexternal-interpreter, so QuickCheck introduces an element of fragility to GHC's bootstrap. Since the selftest rules are the only part of hadrian that need QuickCheck, we can easily eliminate this bootstrap dependency when required by introducing a `selftest` flag guarding the rules' inclusion. Closes #8699. - - - - - 9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00 Regression test for #21848 - - - - - ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00 driver: Don't create LinkNodes when -no-link is enabled Fixes #21866 - - - - - fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00 Docs: fix mistaken claim about kind signatures This patch fixes #21806 by rectifying an incorrect claim about the usage of kind variables in the header of a data declaration with a standalone kind signature. It also adds some clarifications about the number of parameters expected in GADT declarations and in type family declarations. - - - - - 2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00 testsuite: Correctly set withNativeCodeGen Fixes #21918 - - - - - f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00 Fix since annotations in GHC.Stack.CloneStack Fixes #21894 - - - - - aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00 Add -dsuppress-coercion-types to make coercions even smaller. Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)`` simply print `` `cast` <Co:11> :: ... `` - - - - - 97655ad8 by sheaf at 2022-08-02T19:27:29-04:00 User's guide: fix typo in hasfield.rst Fixes #21950 - - - - - 35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00 Remove TCvSubst and use Subst for both term and type-level subst This patch removes the TCvSubst data type and instead uses Subst as the environment for both term and type level substitution. This change is partially motivated by the existential type proposal, which will introduce types that contain expressions and therefore forces us to carry around an "IdSubstEnv" even when substituting for types. It also reduces the amount of code because "Subst" and "TCvSubst" share a lot of common operations. There isn't any noticeable impact on performance (geo. mean for ghc/alloc is around 0.0% but we have -94 loc and one less data type to worry abount). Currently, the "TCvSubst" data type for substitution on types is identical to the "Subst" data type except the former doesn't store "IdSubstEnv". Using "Subst" for type-level substitution means there will be a redundant field stored in the data type. However, in cases where the substitution starts from the expression, using "Subst" for type-level substitution saves us from having to project "Subst" into a "TCvSubst". This probably explains why the allocation is mostly even despite the redundant field. The patch deletes "TCvSubst" and moves "Subst" and its relevant functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst". Substitution on expressions is still defined in "GHC.Core.Subst" so we don't have to expose the definition of "Expr" in the hs-boot file that "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a distinct function from "isEmptySubst"; the former ignores the emptiness of "IdSubstEnv"). These exceptions mainly exist for performance reasons and will go away when "Expr" and "Type" are mutually recursively defined (we won't be able to take those shortcuts if we can't make the assumption that expressions don't appear in types). - - - - - b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00 Fix TH + defer-type-errors interaction (#21920) Previously, we had to disable defer-type-errors in splices because of #7276. But this fix is no longer necessary, the test T7276 no longer segfaults and is now correctly deferred. - - - - - fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00 Add a note about about W/W for unlifting strict arguments This fixes #21236. - - - - - fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force safeInferred to avoid retaining extra copy of DynFlags This will only have a (very) modest impact on memory but we don't want to retain old copies of DynFlags hanging around so best to force this value. - - - - - 0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force name selectors to ensure no reference to Ids enter the NameCache I observed some unforced thunks in the NameCache which were retaining a whole Id, which ends up retaining a Type.. which ends up retaining old copies of HscEnv containing stale HomeModInfo. - - - - - 0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Fix leaks in --make mode when there are module loops This patch fixes quite a tricky leak where we would end up retaining stale ModDetails due to rehydrating modules against non-finalised interfaces. == Loops with multiple boot files It is possible for a module graph to have a loop (SCC, when ignoring boot files) which requires multiple boot files to break. In this case we must perform the necessary hydration steps before and after compiling modules which have boot files which are described above for corectness but also perform an additional hydration step at the end of the SCC to remove space leaks. Consider the following example: ┌───────┐ ┌───────┐ │ │ │ │ │ A │ │ B │ │ │ │ │ └─────┬─┘ └───┬───┘ │ │ ┌────▼─────────▼──┐ │ │ │ C │ └────┬─────────┬──┘ │ │ ┌────▼──┐ ┌───▼───┐ │ │ │ │ │ A-boot│ │ B-boot│ │ │ │ │ └───────┘ └───────┘ A, B and C live together in a SCC. Say we compile the modules in order A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps (because A has a boot file). Therefore C will be hydrated relative to A, and the ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again, and so B will reference C/A,B, its interface will be hydrated relative to both A and B. Now there is a space leak because say C is a very big module, there are now two different copies of ModDetails kept alive by modules A and B. The way to avoid this space leak is to rehydrate an entire SCC together at the end of compilation so that all the ModDetails point to interfaces for .hs files. In this example, when we hydrate A, B and C together then both A and B will refer to C/A,B. See #21900 for some more discussion. ------------------------------------------------------- In addition to this simple case, there is also the potential for a leak during parallel upsweep which is also fixed by this patch. Transcibed is Note [ModuleNameSet, efficiency and space leaks] Note [ModuleNameSet, efficiency and space leaks] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During unsweep the results of compiling modules are placed into a MVar, to find the environment the module needs to compile itself in the MVar is consulted and the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking module dependencies and recreating the HUG from scratch each time is very expensive. In serial mode (-j1), this all works out fine because a module can only be compiled after its dependencies have finished compiling and not interleaved with compiling module loops. Therefore when we create the finalised or no loop interfaces, the HUG only contains finalised interfaces. In parallel mode, we have to be more careful because the HUG variable can contain non-finalised interfaces which have been started by another thread. In order to avoid a space leak where a finalised interface is compiled against a HPT which contains a non-finalised interface we have to restrict the HUG to only the visible modules. The visible modules is recording in the ModuleNameSet, this is propagated upwards whilst compiling and explains which transitive modules are visible from a certain point. This set is then used to restrict the HUG before the module is compiled to only the visible modules and thus avoiding this tricky space leak. Efficiency of the ModuleNameSet is of utmost importance because a union occurs for each edge in the module graph. Therefore the set is represented directly as an IntSet which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode. See test "jspace" for an example which used to trigger this problem. Fixes #21900 - - - - - 1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Store interfaces in ModIfaceCache more directly I realised hydration was completely irrelavant for this cache because the ModDetails are pruned from the result. So now it simplifies things a lot to just store the ModIface and Linkable, which we can put into the cache straight away rather than wait for the final version of a HomeModInfo to appear. - - - - - 6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00 cmm: Remove unused ReadOnlyData16 We don't actually emit rodata16 sections anywhere. - - - - - 16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00 findExternalRules: Don't needlessly traverse the list of rules. - - - - - 52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00 Remove backported items from 9.6 release notes They have been backported to 9.4 in commits 5423d84bd9a28f, 13c81cb6be95c5, 67ccbd6b2d4b9b. - - - - - 78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00 ci: Fix pages job The job has been failing because we don't bundle haddock docs anymore in the docs dist created by hadrian. Fixes #21789 - - - - - 037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00 codeGen/X86: Don't clobber switch variable in switch generation Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was safe to clobber the switch variable when generating code for a jump table since we were at the end of a block. However, this assumption is wrong; the register could be live in the jump target. Fixes #21968. - - - - - 50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00 Fix equality operator in jspace test - - - - - e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Improve BUILD_PAP comments - - - - - 41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Make dropTail comment a haddock comment - - - - - ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Add one more sanity check in stg_restore_cccs - - - - - 1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00 StgToCmm: Fix isSimpleScrut when profiling is enabled. When profiling is enabled we must enter functions that might represent thunks in order for their sccs to show up in the profile. We might allocate even if the function is already evaluated in this case. So we can't consider any potential function thunk to be a simple scrut when profiling. Not doing so caused profiled binaries to segfault. - - - - - fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Change `-fprof-late` to insert cost centres after unfolding creation. The former behaviour of adding cost centres after optimization but before unfoldings are created is not available via the flag `prof-late-inline` instead. I also reduced the overhead of -fprof-late* by pushing the cost centres into lambdas. This means the cost centres will only account for execution of functions and not their partial application. Further I made LATE_CC cost centres it's own CC flavour so they now won't clash with user defined ones if a user uses the same string for a custom scc. LateCC: Don't put cost centres inside constructor workers. With -fprof-late they are rarely useful as the worker is usually inlined. Even if the worker is not inlined or we use -fprof-late-linline they are generally not helpful but bloat compile and run time significantly. So we just don't add sccs inside constructor workers. ------------------------- Metric Decrease: T13701 ------------------------- - - - - - f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00 gitlab-ci: Fix hadrian bootstrapping of release pipelines Previously we would attempt to test hadrian bootstrapping in the `validate` build flavour. However, `ci.sh` refuses to run validation builds during release pipelines, resulting in job failures. Fix this by testing bootstrapping in the `release` flavour during release pipelines. We also attempted to record perf notes for these builds, which is redundant work and undesirable now since we no longer build in a consistent flavour. - - - - - c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00 compiler: Eliminate two uses of foldr in favor of foldl' These two uses constructed maps, which is a case where foldl' is generally more efficient since we avoid constructing an intermediate O(n)-depth stack. - - - - - d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00 rts: Fix code style - - - - - 57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00 genprimopcode: Drop ArrayArray# references As ArrayArray# no longer exists - - - - - 7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00 base: Organize Haddocks in GHC.Conc.Sync - - - - - aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00 Add primop to list threads A user came to #ghc yesterday wondering how best to check whether they were leaking threads. We ended up using the eventlog but it seems to me like it would be generally useful if Haskell programs could query their own threads. - - - - - 6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00 rts: Move thread labels into TSO This eliminates the thread label HashTable and instead tracks this information in the TSO, allowing us to use proper StgArrBytes arrays for backing the label and greatly simplifying management of object lifetimes when we expose them to the user with the coming `threadLabel#` primop. - - - - - 1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00 Add a primop to query the label of a thread - - - - - 43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00 base: Share finalization thread label For efficiency's sake we float the thread label assigned to the finalization thread to the top-level, ensuring that we only need to encode the label once. - - - - - 1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00 users-guide: Add release notes entry for thread introspection support - - - - - 09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix binary distribution install attributes Previously we would use plain `cp` to install various parts of the binary distribution. However, `cp`'s behavior w.r.t. file attributes is quite unclear; for this reason it is much better to rather use `install`. Fixes #21965. - - - - - 2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix installation of system-cxx-std-lib package conf - - - - - 7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00 gitlab-ci: Bump Docker images To give the ARMv7 job access to lld, fixing #21875. - - - - - afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Don't use mk/config.mk.in Ultimately we want to drop mk/config.mk so here I extract the bits needed by the Hadrian bindist installation logic into a Hadrian-specific file. While doing this I fixed binary distribution installation, #21901. - - - - - b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Fix naming of cross-compiler wrappers - - - - - 78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00 hadrian: Extend xattr Darwin hack to cover /lib As noted in #21506, it is now necessary to remove extended attributes from `/lib` as well as `/bin` to avoid SIP issues on Darwin. Fixes #21506. - - - - - 20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00 NCG(x86): Compile add+shift as lea if possible. - - - - - 742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00 dataToTag#: Skip runtime tag check if argument is infered tagged This addresses one part of #21710. - - - - - 1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00 rts: remove redundant stg_traceCcszh This out-of-line primop has no Haskell wrapper and hasn't been used anywhere in the tree. Furthermore, the code gets in the way of !7632, so it should be garbage collected. - - - - - a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00 Document a divergence from the report in parsing function lhss. GHC is happy to parse `(f) x y = x + y` when it should be a parse error based on the Haskell report. Seems harmless enough so we won't fix it but it's documented now. Fixes #19788 - - - - - 5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00 gitlab-ci: Add release job for aarch64/debian 11 - - - - - 5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Introduce validation job for aarch64 cross-compilation Begins to address #11958. - - - - - e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00 Bump process submodule - - - - - ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Add basic support for cross-compiler testiing Here we add a simple qemu-based test for cross-compilers. - - - - - 50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00 rts: Ensure that Array# card arrays are initialized In #19143 I noticed that newArray# failed to initialize the card table of newly-allocated arrays. However, embarrassingly, I then only fixed the issue in newArrayArray# and, in so doing, introduced the potential for an integer underflow on zero-length arrays (#21962). Here I fix the issue in newArray#, this time ensuring that we do not underflow in pathological cases. Fixes #19143. - - - - - e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00 testsuite: Add test for #21962 - - - - - c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00 gitlab-ci: Don't use coreutils on Darwin In general we want to ensure that the tested environment is as similar as possible to the environment the user will use. In the case of Darwin, this means we want to use the system's BSD command-line utilities, not coreutils. This would have caught #21974. - - - - - 1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00 hadrian: Fix bindist installation on Darwin It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does. - - - - - 681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00 hadrian: Fix access mode of installed package registration files Previously hadrian's bindist Makefile would modify package registrations placed by `install` via a shell pipeline and `mv`. However, the use of `mv` means that if umask is set then the user may otherwise end up with package registrations which are inaccessible. Fix this by ensuring that the mode is 0644. - - - - - e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00 Cleanups around pretty-printing * Remove hack when printing OccNames. No longer needed since e3dcc0d5 * Remove unused `pprCmms` and `instance Outputable Instr` * Simplify `pprCLabel` (no need to pass platform) * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by ImmLit, but that can take just a String instead. * Remove instance `Outputable CLabel` - proper output of labels needs a platform, and is done by the `OutputableP` instance - - - - - 66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00 rts/linker: Resolve iconv_* on FreeBSD FreeBSD's libiconv includes an implementation of the iconv_* functions in libc. Unfortunately these can only be resolved using dlvsym, which is how the RTS linker usually resolves such functions. To fix this we include an ad-hoc special case for iconv_*. Fixes #20354. - - - - - 5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00 system-cxx-std-lib: Add support for FreeBSD libcxxrt - - - - - ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00 gitlab-ci: Bump to use freebsd13 runners - - - - - d71a2051 by sheaf at 2022-08-09T13:47:28-04:00 Fix size_up_alloc to account for UnliftedDatatypes The size_up_alloc function mistakenly considered any type that isn't lifted to not allocate anything, which is wrong. What we want instead is to check the type isn't boxed. This accounts for (BoxedRep Unlifted). Fixes #21939 - - - - - 76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. - - - - - 7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. - - - - - dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00 Updates language extension documentation Adding a 'Status' field with a few values: - Deprecated - Experimental - InternalUseOnly - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98' Those values are pulled from the existing descriptions or elsewhere in the documentation. While at it, include the :implied by: where appropriate, to provide more detail. Fixes #21475 - - - - - 823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00 hadrian RunRest: add type signature for stageNumber avoids warning seen on 9.4.1: src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults] • Defaulting the following constraints to type ‘Integer’ (Show a0) arising from a use of ‘show’ at src/Settings/Builders/RunTest.hs:264:53-84 (Num a0) arising from a use of ‘stageNumber’ at src/Settings/Builders/RunTest.hs:264:59-83 • In the second argument of ‘(++)’, namely ‘show (stageNumber (C.stage ctx))’ In the second argument of ‘($)’, namely ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’ In the expression: arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | 264 | , arg "-e", arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compilation tested locally - - - - - f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00 Add support for external static plugins (#20964) This patch adds a new command-line flag: -fplugin-library=<file-path>;<unit-id>;<module>;<args> used like this: -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"] It allows a plugin to be loaded directly from a shared library. With this approach, GHC doesn't compile anything for the plugin and doesn't load any .hi file for the plugin and its dependencies. As such GHC doesn't need to support two environments (one for plugins, one for target code), which was the more ambitious approach tracked in #14335. Fix #20964 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Fix ARMv7 build It appears that the CI refactoring carried out in 5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some critical configuration: setting the build/host/target platforms and forcing use of a non-broken linker. - - - - - 596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Run ARMv7 jobs when ~ARM label is used - - - - - 7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00 hadrian: Don't attempt to install documentation if doc/ doesn't exist Previously we would attempt to install documentation even if the `doc` directory doesn't exist (e.g. due to `--docs=none`). This would result in the surprising side-effect of the entire contents of the bindist being installed in the destination documentation directory. Fix this. Fixes #21976. - - - - - 67575f20 by normalcoder at 2022-08-10T15:38:34-04:00 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - - - - - 45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00 Note [Trimming auto-rules]: State that this improves compiler perf. - - - - - 5c24b1b3 by Bodigrim at 2022-08-10T22:41:50-04:00 Document that threadDelay / timeout are susceptible to overflows on 32-bit machines - - - - - ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 Updates haddock submodule - - - - - dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00 Revert "gitlab-ci: Add release job for aarch64/debian 11" This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46. The job was not tested before being merged and fails CI (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392) Ticket #22005 - - - - - ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00 typo - - - - - cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00 CmmToLlvm: Don't aliasify builtin LLVM variables Our aliasification logic would previously turn builtin LLVM variables into aliases, which apparently confuses LLVM. This manifested in initializers failing to be emitted, resulting in many profiling failures with the LLVM backend. Fixes #22019. - - - - - dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00 run_ci: remove monoidal-containers Fixes #21492 MonoidalMap is inlined and used to implement Variables, as before. The top-level value "jobs" is reimplemented as a regular Map, since it doesn't use the monoidal union anyway. - - - - - 64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00 CmmToAsm/AArch64: correct a typo - - - - - f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00 Fix #21979 - compact-share failing with -O I don't have good reason to believe the optimization level should affect if sharing works or not here. So limit the test to the normal way. - - - - - 68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix reference to dead llvm-version substitution Fixes #22052. - - - - - 28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix incorrect reference to `:extension: role - - - - - 71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Add :ghc-flag: reference - - - - - 385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00 hadrian: Place manpage in docroot This relocates it from docs/ to doc/ - - - - - 84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00 Bump haddock submodule Includes merge of `main` into `ghc-head` as well as some Haddock users guide fixes. - - - - - 59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00 base: Add changelog entries from ghc-9.2 Closes #21922. - - - - - a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00 relnotes: Add "included libraries" section As noted in #21988, some users rely on this. - - - - - a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Rephrase the rewrite rule documentation Previously the wording was a tad unclear. Fix this. Closes #21114. - - - - - 3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00 Implement Response File support for HPC This is an improvement to HPC authored by Richard Wallace (https://github.com/purefn) and myself. I have received permission from him to attempt to upstream it. This improvement was originally implemented as a patch to HPC via input-output-hk/haskell.nix: https://github.com/input-output-hk/haskell.nix/pull/1464 Paraphrasing Richard, HPC currently requires all inputs as command line arguments. With large projects this can result in an argument list too long error. I have only seen this error in Nix, but I assume it can occur is a plain Unix environment. This MR adds the standard response file syntax support to HPC. For example you can now pass a file to the command line which contains the arguments. ``` hpc @response_file_1 @response_file_2 ... The contents of a Response File must have this format: COMMAND ... example: report my_library.tix --include=ModuleA --include=ModuleB ``` Updates hpc submodule Co-authored-by: Richard Wallace <rwallace at thewallacepack.net> Fixes #22050 - - - - - 436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00 ghc-heap: Fix decoding of TSO closures An extra field was added to the TSO structure in 6d1700b6 but the decoding logic in ghc-heap was not updated for this new field. Fixes #22046 - - - - - a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00 driver: Honour -x option The -x option is used to manually specify which phase a file should be started to be compiled from (even if it lacks the correct extension). I just failed to implement this when refactoring the driver. In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to preprocess source files using GHC. I added a test to exercise this case. Fixes #22044 - - - - - e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00 Be more careful in chooseInferredQuantifiers This fixes #22065. We were failing to retain a quantifier that was mentioned in the kind of another retained quantifier. Easy to fix. - - - - - 714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00 testsuite: Add test for #21583 - - - - - 989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00 compiler: Drop --build-id=none hack Since 2011 the object-joining implementation has had a hack to pass `--build-id=none` to `ld` when supported, seemingly to work around a linker bug. This hack is now unnecessary and may break downstream users who expect objects to have valid build-ids. Remove it. Closes #22060. - - - - - 519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00 Make ru_fn field strict to avoid retaining Ids It's better to perform this projection from Id to Name strictly so we don't retain an old Id (hence IdInfo, hence Unfolding, hence everything etc) - - - - - 7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force `getOccFS bndr` to avoid retaining reference to Bndr. This is another symptom of #19619 - - - - - 4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force unfoldings when they are cleaned-up in Tidy and CorePrep If these thunks are not forced then the entire unfolding for the binding is live throughout the whole of CodeGen despite the fact it should have been discarded. Fixes #22071 - - - - - 2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00 haddock docs: Fix links from identifiers to dependent packages When implementing the base_url changes I made the pretty bad mistake of zipping together two lists which were in different orders. The simpler thing to do is just modify `haddockDependencies` to also return the package identifier so that everything stays in sync. Fixes #22001 - - - - - 9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00 Revert "Refactor SpecConstr to use treat bindings uniformly" This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729. This refactoring introduced quite a severe residency regression (900MB live from 650MB live when compiling mmark), see #21993 for a reproducer and more discussion. Ticket #21993 - - - - - 9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00 tc: warn about lazy annotations on unlifted arguments (fixes #21951) - - - - - e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00 Fix #22048 where we failed to drop rules for -fomit-interface-pragmas. Now we also filter the local rules (again) which fixes the issue. - - - - - 51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00 Print constraints in quotes (#21167) This patch improves the uniformity of error message formatting by printing constraints in quotes, as we do for types. Fix #21167 - - - - - ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00 19217 Implicitly quantify type variables in :kind command - - - - - 9939e95f by MorrowM at 2022-08-21T16:51:38-04:00 Recognize file-header pragmas in GHCi (#21507) - - - - - fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00 hadrian: Fix bootstrapping with ghc-9.4 The error was that we were trying to link together containers from boot package library (which depends template-haskell in boot package library) template-haskell from in-tree package database So the fix is to build containers in stage0 (and link against template-haskell built in stage0). Fixes #21981 - - - - - b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00 Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942. * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence * `ParensT` constructor is now always printed parenthesized * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down * using `>=` instead of former `>` to match the Core type printing logic * some test outputs have changed, losing extraneous parentheses - - - - - fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00 Fix and test for issue #21723 - - - - - 33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00 Test for issue #21942 - - - - - c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00 Updated the changelog - - - - - 80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00 hadrian: Don't duplicate binaries on installation Previously we used `install` on symbolic links, which ended up copying the target file rather than installing a symbolic link. Fixes #22062. - - - - - b929063e by M Farkas-Dyck at 2022-08-24T02:37:01-04:00 Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`. Closes #22092. - - - - - 112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00 driver: don't actually merge objects when ar -L works - - - - - a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00 rts: Consistently use MiB in stats output Previously we would say `MB` even where we meant `MiB`. - - - - - a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694, #21755. It also makes sure that #21948 and fix to #21694. * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * To make "no free join points in arityType" work out I had to avoid trying to use eta-expansion for runRW#. This entailed a few changes in the Simplifier's treatment of runRW#. See GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#] * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * Rewrote Note [Combining case branches: optimistic one-shot-ness] * arityType previously treated join points differently to other let-bindings. This patch makes them unform; arityType analyses the RHS of all bindings to get its ArityType, and extends am_sigs. I realised that, now we have am_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. * And finally, it was the strange treatment of join-point Ids in arityType (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring, which treats them uniformly; but without breaking #18328. In fact, the arity for recursive join bindings is pretty tricky; see the long Note [Arity for recursive join bindings] in GHC.Core.Opt.Simplify.Utils. That led to more refactoring, including deciding that an Id could have an Arity that is bigger than its JoinArity; see Note [Invariants on join points], item 2(b) in GHC.Core * Make sure that the "demand threshold" for join points in DmdAnal is no bigger than the join-arity. In GHC.Core.Opt.DmdAnal see Note [Demand signatures are computed for a threshold arity based on idArity] * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity, where it more properly belongs. * Remove an old, redundant hack in FloatOut. The old Note was Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels. Compile time improves very slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- T18223(normal) ghc/alloc 725,808,720 747,839,216 +3.0% BAD T6048(optasm) ghc/alloc 105,006,104 101,599,472 -3.2% GOOD geo. mean -0.2% minimum -3.2% maximum +3.0% For some reason Windows was better T10421(normal) ghc/alloc 125,888,360 124,129,168 -1.4% GOOD T18140(normal) ghc/alloc 85,974,520 83,884,224 -2.4% GOOD T18698b(normal) ghc/alloc 236,764,568 234,077,288 -1.1% GOOD T18923(normal) ghc/alloc 75,660,528 73,994,512 -2.2% GOOD T6048(optasm) ghc/alloc 112,232,512 108,182,520 -3.6% GOOD geo. mean -0.6% I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3% increase in exchange for goodness elsewhere. Metric Decrease: T10421 T18140 T18698b T18923 T6048 Metric Increase: T18223 - - - - - 909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00 upload_ghc_libs: Add means of passing Hackage credentials - - - - - 28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00 Scrub some partiality in `CommonBlockElim`. - - - - - 54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00 hadrian: Fix whitespace Previously this region of Settings.Packages was incorrectly indented. - - - - - c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00 validate: Drop --legacy flag In preparation for removal of the legacy `make`-based build system. - - - - - 822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00 gitlab-ci: Drop make build validation jobs In preparation for removal of the `make`-based build system - - - - - 6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop make build system Here we at long last remove the `make`-based build system, it having been replaced with the Shake-based Hadrian build system. Users are encouraged to refer to the documentation in `hadrian/doc` and this [1] blog post for details on using Hadrian. Closes #17527. [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html - - - - - dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00 Remove testsuite/tests/perf/haddock/.gitignore As noted in #16802, this is no longer needed. Closes #16802. - - - - - fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop hc-build script This has not worked for many, many years and relied on the now-removed `make`-based build system. - - - - - 659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mkdirhier This is only used by nofib's dead `dist` target - - - - - 4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mk/{build,install,config}.mk.in - - - - - 46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00 compiler: Drop comment references to make - - - - - d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add inits1 and tails1 to Data.List.NonEmpty See https://github.com/haskell/core-libraries-committee/issues/67 - - - - - 8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add since annotations and changelog entries - - - - - 6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00 Fix redundant import This fixes a build error on x86_64-linux-alpine3_12-validate. See the function 'loadExternalPlugins' defined in this file. - - - - - 4786acf7 by sheaf at 2022-08-26T15:05:23-04:00 Pmc: consider any 2 dicts of the same type equal This patch massages the keys used in the `TmOracle` `CoreMap` to ensure that dictionaries of coherent classes give the same key. That is, whenever we have an expression we want to insert or lookup in the `TmOracle` `CoreMap`, we first replace any dictionary `$dict_abcd :: ct` with a value of the form `error @ct`. This allows us to common-up view pattern functions with required constraints whose arguments differed only in the uniques of the dictionaries they were provided, thus fixing #21662. This is a rather ad-hoc change to the keys used in the `TmOracle` `CoreMap`. In the long run, we would probably want to use a different representation for the keys instead of simply using `CoreExpr` as-is. This more ambitious plan is outlined in #19272. Fixes #21662 Updates unix submodule - - - - - f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00 Remove label style from printing context Previously, the SDocContext used for code generation contained information whether the labels should use Asm or C style. However, at every individual call site, this is known statically. This removes the parameter to 'PprCode' and replaces every 'pdoc' used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'. The OutputableP instance is now used only for dumps. The output of T15155 changes, it now uses the Asm style (which is faithful to what actually happens). - - - - - 1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00 boot: cleanup legacy args Cleanup legacy boot script args, following removal of the legacy make build system. - - - - - 95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00 Improve SpecConstr for evals As #21763 showed, we were over-specialising in some cases, when the function involved was doing a simple 'eval', but not taking the value apart, or branching on it. This MR fixes the problem. See Note [Do not specialise evals]. Nofib barely budges, except that spectral/cichelli allocates about 3% less. Compiler bytes-allocated improves a bit geo. mean -0.1% minimum -0.5% maximum +0.0% The -0.5% is on T11303b, for what it's worth. - - - - - 565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Revert "Revert "Refactor SpecConstr to use treat bindings uniformly"" This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8. This commit was originally reverted due to an increase in space usage. This was diagnosed as because the SCE increased in size and that was being retained by another leak. See #22102 - - - - - 82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Avoid retaining bindings via ModGuts held on the stack It's better to overwrite the bindings fields of the ModGuts before starting an iteration as then all the old bindings can be collected as soon as the simplifier has processed them. Otherwise we end up with the old bindings being alive until right at the end of the simplifier pass as the mg_binds field is only modified right at the end. - - - - - 64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00 Force imposs_deflt_cons in filterAlts This fixes a pretty serious space leak as the forced thunk would retain `Alt b` values which would then contain reference to a lot of old bindings and other simplifier gunk. The OtherCon unfolding was not forced on subsequent simplifier runs so more and more old stuff would be retained until the end of simplification. Fixing this has a drastic effect on maximum residency for the mmark package which goes from ``` 45,005,401,056 bytes allocated in the heap 17,227,721,856 bytes copied during GC 818,281,720 bytes maximum residency (33 sample(s)) 9,659,144 bytes maximum slop 2245 MiB total memory in use (0 MB lost due to fragmentation) ``` to ``` 45,039,453,304 bytes allocated in the heap 13,128,181,400 bytes copied during GC 331,546,608 bytes maximum residency (40 sample(s)) 7,471,120 bytes maximum slop 916 MiB total memory in use (0 MB lost due to fragmentation) ``` See #21993 for some more discussion. - - - - - a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Use Solo to avoid retaining the SCE but to avoid performing the substitution The use of Solo here allows us to force the selection into the SCE to obtain the Subst but without forcing the substitution to be applied. The resulting thunk is placed into a lazy field which is rarely forced, so forcing it regresses peformance. - - - - - 161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00 Fix a nasty loop in Tidy As the remarkably-simple #22112 showed, we were making a black hole in the unfolding of a self-recursive binding. Boo! It's a bit tricky. Documented in GHC.Iface.Tidy, Note [tidyTopUnfolding: avoiding black holes] - - - - - 68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnIllegalHsigDefaultMethods TcRnBadGenericMethod TcRnWarningMinimalDefIncomplete TcRnDefaultMethodForPragmaLacksBinding TcRnIgnoreSpecialisePragmaOnDefMethod TcRnBadMethodErr TcRnNoExplicitAssocTypeOrDefaultDeclaration - - - - - cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00 Fix a bug in anyInRnEnvR This bug was a subtle error in anyInRnEnvR, introduced by commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06 Author: Andreas Klebinger <klebinger.andreas at gmx.at> Date: Sat Jul 9 01:19:52 2022 +0200 Rule matching: Don't compute the FVs if we don't look at them. The net result was #22028, where a rewrite rule would wrongly match on a lambda. The fix to that function is easy. - - - - - 0154bc80 by sheaf at 2022-08-30T06:05:41-04:00 Various Hadrian bootstrapping fixes - Don't always produce a distribution archive (#21629) - Use correct executable names for ghc-pkg and hsc2hs on windows (we were missing the .exe file extension) - Fix a bug where we weren't using the right archive format on Windows when unpacking the bootstrap sources. Fixes #21629 - - - - - 451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00 ci: Attempt using normal submodule cloning strategy We do not use any recursively cloned submodules, and this protects us from flaky upstream remotes. Fixes #22121 - - - - - 9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: stray "--" - - - - - 3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: syntatic -> syntactic - - - - - 7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00 Add a missing trimArityType This buglet was exposed by #22114, a consequence of my earlier refactoring of arity for join points. - - - - - e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump binary submodule to 0.8.9.1 - - - - - 4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump stm submodule to 2.5.1.0 - - - - - 837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00 users-guide: Document system-cxx-std-lib - - - - - f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00 Update submodule containers to 0.6.6 - - - - - 4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00 Update submodule process to 1.6.15.0 - - - - - 1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00 Bump directory submodule to 1.3.7.1 - - - - - 7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00 Bump text submodule to 2.0.1 - - - - - fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00 Bump deepseq submodule to 1.4.8.0 - - - - - a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00 Add dates to base, ghc-prim changelogs - - - - - 2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00 Update autoconf scripts Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983 - - - - - e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00 Bump bytestring submodule to 0.11.3.1 - - - - - f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00 Update submodule Cabal to tag Cabal-v3.8.1.0 closes #21931 - - - - - e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00 Refine in-tree compiler args for --test-compiler=stage1 Some of the logic to calculate in-tree arguments was not correct for the stage1 compiler. Namely we were not correctly reporting whether we were building static or dynamic executables and whether debug assertions were enabled. Fixes #22096 - - - - - 6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00 Make ghcDebugAssertions into a Stage predicate (Stage -> Bool) We also care whether we have debug assertions enabled for a stage one compiler, but the way which we turned on the assertions was quite different from the stage2 compiler. This makes the logic for turning on consistent across both and has the advantage of being able to correct determine in in-tree args whether a flavour enables assertions or not. Ticket #22096 - - - - - 15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00 Add regression test for #21550 This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5 "Use local instances with least superclass depth" - - - - - 7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00 Minor cleanup - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused), isCoVar_maybe (duplicated by getCoVar_maybe) - Replace a few occurrences of voidPrimId with (# #). void# is a deprecated synonym for the unboxed tuple. - Use showSDoc in :show linker. This makes it consistent with the other :show commands - - - - - 31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - 7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00 Fix bootstrap with ghc-9.0 It turns out Solo is a very recent addition to base, so for older GHC versions we just defined it inline here the one place we use it in the compiler. - - - - - d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00 DmdAnal: Don't panic in addCaseBndrDmd (#22039) Rather conservatively return Top. See Note [Untyped demand on case-alternative binders]. I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and `fieldBndrDmds`. Fixes #22039. - - - - - 25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00 gitlab-ci: Ensure that ghc derivation is in scope Previously the lint-ci job attempted to use cabal-install (specifically `cabal update`) without a GHC in PATH. However, cabal-install-3.8 appears to want GHC, even for `cabal update`. - - - - - f37b621f by sheaf at 2022-09-06T11:51:53+00:00 Update instances.rst, clarifying InstanceSigs Fixes #22103 - - - - - d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00 Fix :add docs in user guide - - - - - 808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00 ci: remove unused build_make/test_make in ci script - - - - - d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00 typo - - - - - fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00 typos - - - - - a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00 whitespace - - - - - 04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Minor SDoc cleanup Change calls to renderWithContext with showSDocOneLine; it's more efficient and explanatory. Remove polyPatSig (unused) - - - - - 7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Remove Outputable Char instance Use 'text' instead of 'ppr'. Using 'ppr' on the list "hello" rendered as "h,e,l,l,o". - - - - - 77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Export liftA2 from Prelude Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details. - - - - - 442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Add changelog entry for liftA2 export from Prelude - - - - - fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule containers to one with liftA2 warnings fixed - - - - - f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule Cabal to one with liftA2 warnings fixed - - - - - a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Isolate some Applicative hidings to GHC.Prelude By reexporting the entirety of Applicative from GHC.Prelude, we can save ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude. This also has the benefit of isolating this type of change to GHC.Prelude, so that people in the future don't have to think about it. - - - - - 9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00 CmmToC: enable 64-bit CallishMachOp on 32-bit targets Normally, the unregisterised builds avoid generating 64-bit CallishMachOp in StgToCmm, so CmmToC doesn't support these. However, there do exist cases where we'd like to invoke cmmToC for other cmm inputs which may contain such CallishMachOps, and it's a rather low effort to add support for these since they only require calling into existing ghc-prim cbits. - - - - - 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by M Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - 54cb0f6b by Sven Tennie at 2022-12-11T15:51:43+00:00 Save point: Decode to list of closure types - - - - - f535e674 by Sven Tennie at 2022-12-11T15:52:10+00:00 cleanup - - - - - e8d894d6 by Sven Tennie at 2022-12-11T15:52:10+00:00 Sync for Zurihack - - - - - dd250080 by Sven Tennie at 2022-12-11T15:52:10+00:00 Segfaults, but compiles again - - - - - 5e52733c by Sven Tennie at 2022-12-11T15:52:10+00:00 Doesn't segfault anymore - - - - - 1977c312 by Sven Tennie at 2022-12-11T15:52:10+00:00 More on RET_SMALL decoding - - - - - 69fc7fc4 by Sven Tennie at 2022-12-11T15:52:10+00:00 Decode BIG_RET - - - - - 4bf30301 by Sven Tennie at 2022-12-11T15:52:10+00:00 Debug issue with GC / implement BIG_RET - - - - - 8f1ba03d by Sven Tennie at 2022-12-11T15:53:08+00:00 Decode with correct stack bottom - - - - - b6e034fb by Sven Tennie at 2022-12-11T15:53:11+00:00 Hacked further - - - - - b52ccbed by Sven Tennie at 2022-12-11T15:53:11+00:00 More on bitmap decoding - - - - - 138258e2 by Sven Tennie at 2022-12-11T15:53:11+00:00 Decode large bitmap... - - - - - 5ea87797 by Sven Tennie at 2022-12-11T15:53:11+00:00 More on Large Bitmaps - - - - - 9fd510a7 by Sven Tennie at 2022-12-11T15:53:11+00:00 Cleanup - - - - - e15d2a1c by Sven Tennie at 2022-12-11T15:53:11+00:00 Fix some warnings - - - - - ab2ca4d0 by Sven Tennie at 2022-12-11T15:53:11+00:00 Cleanup belching - - - - - 225846d7 by Sven Tennie at 2022-12-11T15:53:11+00:00 Assert closures are valid - - - - - 7922f6f0 by Sven Tennie at 2022-12-11T15:53:11+00:00 Assert more - - - - - 4f5401c5 by Sven Tennie at 2022-12-11T15:53:11+00:00 Assert more - - - - - 8a86f5e8 by Sven Tennie at 2022-12-11T15:53:11+00:00 Sober casts; mute debug belchs - - - - - 744873c8 by Sven Tennie at 2022-12-11T15:53:11+00:00 Cleanup - - - - - 6ca27fb2 by Sven Tennie at 2022-12-11T15:53:11+00:00 Delete unused StackFFI HSC code - - - - - a451336d by Sven Tennie at 2022-12-11T15:53:11+00:00 Recognize special small rets - - - - - 36421a19 by Sven Tennie at 2022-12-11T15:53:11+00:00 Check sanity of stacks - - - - - 56a369fe by Sven Tennie at 2022-12-11T15:53:11+00:00 Start Update frames - - - - - 9c5fe94c by Sven Tennie at 2022-12-11T15:53:11+00:00 Decode Update Frame type - - - - - 58405d68 by Sven Tennie at 2022-12-11T15:53:11+00:00 Decode catch frames - - - - - 915f53cb by Sven Tennie at 2022-12-11T15:56:40+00:00 Decode and test underflow frames - - - - - f1c69a23 by Sven Tennie at 2022-12-11T15:56:43+00:00 Test big return frames - - - - - 3471f40b by Sven Tennie at 2022-12-11T15:56:43+00:00 Decode StgCatchStmFrame - - - - - d8018f9d by Sven Tennie at 2022-12-11T15:56:43+00:00 Unify decoding of referenced closures - - - - - 36979dfc by Sven Tennie at 2022-12-11T15:56:43+00:00 Decode Atomically and CatchRetry frames - - - - - f091117e by Sven Tennie at 2022-12-11T15:56:43+00:00 Save - - - - - 849f7b7f by Sven Tennie at 2022-12-11T15:56:43+00:00 RetFun - - - - - 8d6e20ea by Sven Tennie at 2022-12-11T15:56:43+00:00 Save - - - - - 990cd85f by Sven Tennie at 2022-12-11T15:56:43+00:00 Save 3 - - - - - 8c605dbb by Sven Tennie at 2022-12-11T15:56:43+00:00 Compiles (again) - - - - - 3ed2e581 by Sven Tennie at 2022-12-11T15:56:43+00:00 Refactor: Extract decodeSmallBitmap - - - - - a818d79e by Sven Tennie at 2022-12-11T15:56:43+00:00 Refactor: extract getClosure - - - - - 3401336b by Sven Tennie at 2022-12-11T15:56:43+00:00 Refactor: extract getHalfWord - - - - - 844db728 by Sven Tennie at 2022-12-11T15:56:43+00:00 Refactor: extract getWord - - - - - b7673380 by Sven Tennie at 2022-12-11T15:56:43+00:00 Refactor: Use StackFrameIter where possible - - - - - 9b924c03 by Sven Tennie at 2022-12-11T15:56:43+00:00 Fix warnings - - - - - 8f666272 by Sven Tennie at 2022-12-11T15:56:43+00:00 Get rid of performUnsafeIO, fix unpackClosureReferencedByFramezh - - - - - 963deb3b by Sven Tennie at 2022-12-11T15:56:43+00:00 Save - - - - - 000e2a3e by Sven Tennie at 2022-12-11T15:56:43+00:00 Save - - - - - 0ea027c3 by Sven Tennie at 2022-12-11T15:56:43+00:00 stack_comparison can decode simple stack - - - - - cfeac57b by Sven Tennie at 2022-12-11T15:56:43+00:00 CLeanup / Formatting - - - - - e8e21097 by Sven Tennie at 2022-12-11T15:56:43+00:00 stack_comparison - - - - - 93548404 by Sven Tennie at 2022-12-11T15:56:43+00:00 Invariant: Haskell ClosureTypes should be the same as if decoded with C - - - - - b67d45a0 by Sven Tennie at 2022-12-11T15:56:43+00:00 Add Atomically assertion - - - - - 228b6b55 by Sven Tennie at 2022-12-11T16:03:12+00:00 Make stack frame closure types heap closures types - - - - - f6750071 by Sven Tennie at 2022-12-11T16:03:18+00:00 Fix tests - - - - - cd4ada0e by Sven Tennie at 2022-12-11T16:58:36+00:00 Fixup - - - - - edfbc390 by Sven Tennie at 2022-12-11T16:58:51+00:00 Delete shell.nix - - - - - 24 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - .gitlab/upload_ghc_libs.py - CODEOWNERS - − MAKEHELP.md - − Makefile - README.md - − appveyor.yml - − bindisttest/ghc.mk - boot - compile_flags.txt - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/651d7b71c7d614f1a90e924bf42c9aabe9ae3e54...edfbc390939f61df380c184dc755b47334cd8191 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/651d7b71c7d614f1a90e924bf42c9aabe9ae3e54...edfbc390939f61df380c184dc755b47334cd8191 You're receiving 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 Dec 11 17:26:34 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 11 Dec 2022 12:26:34 -0500 Subject: [Git][ghc/ghc][master] Add heqT, a kind-heterogeneous variant of heq Message-ID: <639612caf4220_224fca2595e17c106178c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - 2 changed files: - libraries/base/Data/Typeable.hs - libraries/base/changelog.md Changes: ===================================== libraries/base/Data/Typeable.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy #-} +{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} ----------------------------------------------------------------------------- @@ -56,6 +57,7 @@ module Data.Typeable -- * Type-safe cast , cast , eqT + , heqT , gcast -- a generalisation of cast -- * Generalized casts for higher-order kinds @@ -135,8 +137,14 @@ cast x -- @since 4.7.0.0 eqT :: forall a b. (Typeable a, Typeable b) => Maybe (a :~: b) eqT - | Just HRefl <- ta `I.eqTypeRep` tb = Just Refl - | otherwise = Nothing + | Just HRefl <- heqT @a @b = Just Refl + | otherwise = Nothing + +-- | Extract a witness of heterogeneous equality of two types +-- +-- @since 4.18.0.0 +heqT :: forall a b. (Typeable a, Typeable b) => Maybe (a :~~: b) +heqT = ta `I.eqTypeRep` tb where ta = I.typeRep :: I.TypeRep a tb = I.typeRep :: I.TypeRep b ===================================== libraries/base/changelog.md ===================================== @@ -57,6 +57,7 @@ of individually allocated pointers as well as freeing each one of them when freeing a `Pool`. (#14762) (#18338) * `Type.Reflection.Unsafe` is now marked as unsafe. + * Add `Data.Typeable.heqT`, a kind-heterogeneous version of `Data.Typeable.eqT`. ## 4.17.0.0 *August 2022* View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3e98a926ac05b8e59e3b31b74b019d4ecb462f6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3e98a926ac05b8e59e3b31b74b019d4ecb462f6 You're receiving 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 Dec 11 17:27:20 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sun, 11 Dec 2022 12:27:20 -0500 Subject: [Git][ghc/ghc][master] Document that Bifunctor instances for tuples are lawful only up to laziness Message-ID: <639612f8e63bb_224fcafbc6768106694@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 1 changed file: - libraries/base/Data/Bifunctor.hs Changes: ===================================== libraries/base/Data/Bifunctor.hs ===================================== @@ -120,8 +120,17 @@ class (forall a. Functor (p a)) => Bifunctor p where second = bimap id - --- | @since 4.8.0.0 +-- | Class laws for tuples hold only up to laziness. Both +-- 'first' 'id' and 'second' 'id' are lazier than 'id' (and 'fmap' 'id'): +-- +-- >>> first id (undefined :: (Int, Word)) `seq` () +-- () +-- >>> second id (undefined :: (Int, Word)) `seq` () +-- () +-- >>> id (undefined :: (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.8.0.0 instance Bifunctor (,) where bimap f g ~(a, b) = (f a, g b) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bfd7c1e653c207dd5dea599f16ee4afad03f2ea5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bfd7c1e653c207dd5dea599f16ee4afad03f2ea5 You're receiving 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 Dec 11 20:08:23 2022 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Sun, 11 Dec 2022 15:08:23 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-split-header-comments Message-ID: <639638b73621b_224fcabe792c0108185@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-split-header-comments at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-split-header-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 Dec 12 08:40:20 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Mon, 12 Dec 2022 03:40:20 -0500 Subject: [Git][ghc/ghc] Deleted branch wip/17733-fragile-conc024 Message-ID: <6396e8f4b05cb_224fca1d78877411249e2@gitlab.mail> Bryan R deleted branch wip/17733-fragile-conc024 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 Dec 12 08:43:31 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Mon, 12 Dec 2022 03:43:31 -0500 Subject: [Git][ghc/ghc] Deleted branch wip/T21583 Message-ID: <6396e9b355444_224fca6068011251dd@gitlab.mail> Bryan R deleted branch wip/T21583 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 Dec 12 11:20:13 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Mon, 12 Dec 2022 06:20:13 -0500 Subject: [Git][ghc/ghc][wip/or-pats] 2 commits: Update submodule Message-ID: <63970e6d1b7ed_224fca18f7d75411468d9@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: c6c565a2 by David Knothe at 2022-12-08T10:54:58+01:00 Update submodule - - - - - 8b306b81 by David Knothe at 2022-12-12T12:20:06+01:00 Check for variable/dictionary binders after zonking - - - - - 7 changed files: - compiler/GHC/Hs/Utils.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Utils/Zonk.hs - utils/haddock Changes: ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1159,7 +1159,7 @@ collect_pat flag pat bndrs = case pat of ParPat _ _ pat _ -> collect_lpat flag pat bndrs ListPat _ pats -> foldr (collect_lpat flag) bndrs pats TuplePat _ pats _ -> foldr (collect_lpat flag) bndrs pats - OrPat _ _ -> [] -- or-patterns can't bind any variables and we don't want to have "conflicting defintions" errors + OrPat _ pats -> [] -- Don't collect binders recursively as we only want to get an error in the most specific or-pattern SumPat _ pat _ _ -> collect_lpat flag pat bndrs LitPat _ _ -> bndrs NPat {} -> bndrs ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -609,14 +609,7 @@ rnPatAndThen mk (TuplePat _ pats boxed) rnPatAndThen mk (OrPat _ pats) = do { pats' <- rnLPatsAndThen mk (NE.toList pats) - ; mapM_ checkNoVarsBound pats' ; return (OrPat noExtField (NE.fromList pats')) } - where - checkNoVarsBound :: LPat GhcRn -> CpsRn () - checkNoVarsBound pat = do - let bnds = collectPatsBinders CollNoDictBinders [pat] - unless (null bnds) $ - liftCps $ addErrAt (locA $ getLoc pat) (TcRnOrPatBindsVariables pat) rnPatAndThen mk (SumPat _ pat alt arity) = do { pat <- rnLPatAndThen mk pat ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1153,8 +1153,9 @@ instance Diagnostic TcRnMessage where False -> text (TH.pprint item)) TcRnReportCustomQuasiError _ msg -> mkSimpleDecorated $ text msg TcRnInterfaceLookupError _ sdoc -> mkSimpleDecorated sdoc - TcRnOrPatBindsVariables pat - -> mkSimpleDecorated $ vcat [text "Or-pattern may not bind variables:" <+> ppr (unLoc pat)] + TcRnOrPatBindsVariables pat vars -> case vars of + True -> mkSimpleDecorated $ text "Or-pattern may not bind variables:" <+> ppr pat + False -> mkSimpleDecorated $ text "Or-pattern may not bind (type) variable, dictionary or equality constraints:" <+> ppr pat TcRnUnsatisfiedMinimalDef mindef -> mkSimpleDecorated $ vcat [text "No explicit implementation for" ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2549,12 +2549,15 @@ data TcRnMessage where TcRnInterfaceLookupError :: !Name -> !SDoc -> TcRnMessage {-| TcRnOrPatBindsVariables is an error that happens when an - or-pattern binds variables, e.g. (one of A, B x). + or-pattern binds variables or has dictionary or evidence biders, e.g. (one of A, B x). Test case: none yet (TODO) -} - TcRnOrPatBindsVariables :: LPat GhcRn -> TcRnMessage + TcRnOrPatBindsVariables + :: Pat GhcTc -- the or-pattern + -> Bool -- True => pattern contains just variables; False => pattern contains other dictionary/evidence binders + -> TcRnMessage {- | TcRnUnsatisfiedMinimalDef is a warning that occurs when a class instance is missing methods that are required by the minimal definition. ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -382,12 +382,10 @@ tc_pat pat_ty penv ps_pat thing_inside = case ps_pat of { (pat', res) <- tc_lpat pat_ty penv pat thing_inside ; return (BangPat x pat', res) } - -- TODO: reject more programs - OrPat _ (NE.toList -> pats) -> do { - (pats', res) <- tc_lpats (map (const pat_ty) pats) penv pats thing_inside; - pat_ty <- expTypeToType (scaledThing pat_ty); - return (OrPat pat_ty (NE.fromList pats'), res) - } + OrPat _ (NE.toList -> pats) -> do -- or-patterns with variables are rejected later, after zonking + { (pats', res) <- tc_lpats (map (const pat_ty) pats) penv pats thing_inside + ; pat_ty <- expTypeToType (scaledThing pat_ty) + ; return (OrPat pat_ty (NE.fromList pats'), res) } LazyPat x pat -> do { mult_wrap <- checkManyPattern pat_ty ===================================== compiler/GHC/Tc/Utils/Zonk.hs ===================================== @@ -56,6 +56,7 @@ import GHC.Tc.Utils.TcType import GHC.Tc.Utils.TcMType import GHC.Tc.Utils.Env ( tcLookupGlobalOnly ) import GHC.Tc.Types.Evidence +import GHC.Tc.Errors.Types import GHC.Core.TyCo.Ppr ( pprTyVar ) import GHC.Core.TyCon @@ -1339,10 +1340,17 @@ zonk_pat env (TuplePat tys pats boxed) ; (env', pats') <- zonkPats env pats ; return (env', TuplePat tys' pats' boxed) } -zonk_pat env (OrPat ty pats) +zonk_pat env p@(OrPat ty pats) = do { ty' <- zonkTcTypeToTypeX env ty ; (env', pats') <- zonkPats env (NE.toList pats) + ; checkNoVarsBound pats' p ; return (env', OrPat ty' (NE.fromList pats')) } + where + checkNoVarsBound :: [LPat GhcTc] -> Pat GhcTc -> TcRn () + checkNoVarsBound pats orpat = do + let bnds = collectPatsBinders CollWithDictBinders pats + let varBnds = collectPatsBinders CollNoDictBinders pats + unless (null bnds) $ addErr (TcRnOrPatBindsVariables orpat (varBnds `equalLength` bnds)) zonk_pat env (SumPat tys pat alt arity ) = do { tys' <- mapM (zonkTcTypeToTypeX env) tys ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 2ffde83344bab8ed0aee3e8ef46f43856c7ca6ef +Subproject commit f6bb16e7ea03a20d0b929fffc58031ef42526405 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d3b2d20835c7b9c3bed896e1472d67913640b42e...8b306b81a1f3db1f660dc88b34f2e1c1260ce81e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d3b2d20835c7b9c3bed896e1472d67913640b42e...8b306b81a1f3db1f660dc88b34f2e1c1260ce81e You're receiving 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 Dec 12 12:06:51 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 07:06:51 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/t21476 Message-ID: <6397195b8f4db_224fca1d7887741178293@gitlab.mail> Matthew Pickering pushed new branch wip/t21476 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t21476 You're receiving 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 Dec 12 12:30:05 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 07:30:05 -0500 Subject: [Git][ghc/ghc][wip/T22272] 32 commits: Add test for #22162 Message-ID: <63971ecda1e95_224fca605f411883d1@gitlab.mail> Matthew Pickering pushed to branch wip/T22272 at Glasgow Haskell Compiler / GHC Commits: 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 1e39c832 by Gergő Érdi at 2022-12-12T12:29:42+00:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Lit.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/60658ec130cf328e937be84f8e4b9a1823cffb18...1e39c832aa0fc5b7b44d164de14d16ac150c91b8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/60658ec130cf328e937be84f8e4b9a1823cffb18...1e39c832aa0fc5b7b44d164de14d16ac150c91b8 You're receiving 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 Dec 12 12:58:40 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 07:58:40 -0500 Subject: [Git][ghc/ghc][wip/T22272] Apply 2 suggestion(s) to 1 file(s) Message-ID: <63972580cd847_224fca605f41207573@gitlab.mail> Matthew Pickering pushed to branch wip/T22272 at Glasgow Haskell Compiler / GHC Commits: 0071f57e by sheaf at 2022-12-12T12:58:38+00:00 Apply 2 suggestion(s) to 1 file(s) - - - - - 1 changed file: - compiler/GHC/IfaceToCore.hs Changes: ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1821,7 +1821,7 @@ variables in `e`. Now we can see the problem: to set the `uf_is_value` field of `foo`'s unfolding, we look at its unfolding (in this case just `foo` itself!). Loop. This is the root cause of ticket #22272. -The simple solution we chose is to serialise the various auxilary +The simple solution we chose is to serialise the various auxiliary fields of `CoreUnfolding` so that we don't need to recreate them when rehydrating. Specifically, the following fields are moved to the 'UnfoldingCache', which is persisted in the interface file: @@ -1835,7 +1835,7 @@ These four bits make the interface files only one byte larger per unfolding; on the other hand, this does save calls to 'exprIsValue', 'exprIsExpandable' etc for every imported Id. -We could choose to do this only for loop breakers. But thats a bit +We could choose to do this only for loop breakers. But that's a bit more complicated and it seems good all round. -} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0071f57e9d0427eb540f36f577fc2926a61fe7d2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0071f57e9d0427eb540f36f577fc2926a61fe7d2 You're receiving 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 Dec 12 12:59:22 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 07:59:22 -0500 Subject: [Git][ghc/ghc][wip/T22272] Fix loop in the interface representation of some `Unfolding` fields Message-ID: <639725aa1393d_224fca605f4120821e@gitlab.mail> Matthew Pickering pushed to branch wip/T22272 at Glasgow Haskell Compiler / GHC Commits: 2ce35a4b by Gergő Érdi at 2022-12-12T12:59:04+00:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 23 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/simplCore/should_compile/T22272.hs - + testsuite/tests/simplCore/should_compile/T22272.stderr - + testsuite/tests/simplCore/should_compile/T22272_A.hs - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -52,7 +52,7 @@ module GHC.Core ( isRuntimeArg, isRuntimeVar, -- * Unfolding data types - Unfolding(..), UnfoldingGuidance(..), UnfoldingSource(..), + Unfolding(..), UnfoldingCache(..), UnfoldingGuidance(..), UnfoldingSource(..), -- ** Constructing 'Unfolding's noUnfolding, bootUnfolding, evaldUnfolding, mkOtherCon, @@ -1277,15 +1277,8 @@ data Unfolding uf_tmpl :: CoreExpr, -- Template; occurrence info is correct uf_src :: UnfoldingSource, -- Where the unfolding came from uf_is_top :: Bool, -- True <=> top level binding - uf_is_value :: Bool, -- exprIsHNF template (cached); it is ok to discard - -- a `seq` on this variable - uf_is_conlike :: Bool, -- True <=> applicn of constructor or CONLIKE function - -- Cached version of exprIsConLike - uf_is_work_free :: Bool, -- True <=> doesn't waste (much) work to expand - -- inside an inlining - -- Cached version of exprIsCheap - uf_expandable :: Bool, -- True <=> can expand in RULE matching - -- Cached version of exprIsExpandable + uf_cache :: UnfoldingCache, -- Cache of flags computable from the expr + -- See Note [Tying the 'CoreUnfolding' knot] uf_guidance :: UnfoldingGuidance -- Tells about the *size* of the template. } -- ^ An unfolding with redundant cached information. Parameters: @@ -1305,7 +1298,22 @@ data Unfolding -- uf_guidance: Tells us about the /size/ of the unfolding template ------------------------------------------------- +-- | Properties of a 'CoreUnfolding' that could be computed on-demand from its template. +-- See Note [UnfoldingCache] +data UnfoldingCache + = UnfoldingCache { + uf_is_value :: !Bool, -- exprIsHNF template (cached); it is ok to discard + -- a `seq` on this variable + uf_is_conlike :: !Bool, -- True <=> applicn of constructor or CONLIKE function + -- Cached version of exprIsConLike + uf_is_work_free :: !Bool, -- True <=> doesn't waste (much) work to expand + -- inside an inlining + -- Cached version of exprIsCheap + uf_expandable :: !Bool -- True <=> can expand in RULE matching + -- Cached version of exprIsExpandable + } + deriving (Eq) + -- | 'UnfoldingGuidance' says when unfolding should take place data UnfoldingGuidance = UnfWhen { -- Inline without thinking about the *size* of the uf_tmpl @@ -1335,7 +1343,23 @@ data UnfoldingGuidance | UnfNever -- The RHS is big, so don't inline it deriving (Eq) -{- +{- Note [UnfoldingCache] +~~~~~~~~~~~~~~~~~~~~~~~~ +The UnfoldingCache field of an Unfolding holds four (strict) booleans, +all derived from the uf_tmpl field of the unfolding. + +* We serialise the UnfoldingCache to and from interface files, for + reasons described in Note [Tying the 'CoreUnfolding' knot] in + GHC.IfaceToCore + +* Because it is a strict data type, we must be careful not to + pattern-match on it until we actually want its values. E.g + GHC.Core.Unfold.callSiteInline/tryUnfolding are careful not to force + it unnecessarily. Just saves a bit of work. + +* When `seq`ing Core to eliminate space leaks, to suffices to `seq` on + the cache, but not its fields, because it is strict in all fields. + Note [Historical note: unfoldings for wrappers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to have a nice clever scheme in interface files for @@ -1436,42 +1460,44 @@ otherCons _ = [] -- yield a value (something in HNF): returns @False@ if unsure isValueUnfolding :: Unfolding -> Bool -- Returns False for OtherCon -isValueUnfolding (CoreUnfolding { uf_is_value = is_evald }) = is_evald -isValueUnfolding (DFunUnfolding {}) = True -isValueUnfolding _ = False +isValueUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_value cache +isValueUnfolding (DFunUnfolding {}) = True +isValueUnfolding _ = False -- | Determines if it possibly the case that the unfolding will -- yield a value. Unlike 'isValueUnfolding' it returns @True@ -- for 'OtherCon' isEvaldUnfolding :: Unfolding -> Bool -- Returns True for OtherCon -isEvaldUnfolding (OtherCon _) = True -isEvaldUnfolding (DFunUnfolding {}) = True -isEvaldUnfolding (CoreUnfolding { uf_is_value = is_evald }) = is_evald -isEvaldUnfolding _ = False +isEvaldUnfolding (OtherCon _) = True +isEvaldUnfolding (DFunUnfolding {}) = True +isEvaldUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_value cache +isEvaldUnfolding _ = False -- | @True@ if the unfolding is a constructor application, the application -- of a CONLIKE function or 'OtherCon' isConLikeUnfolding :: Unfolding -> Bool -isConLikeUnfolding (OtherCon _) = True -isConLikeUnfolding (CoreUnfolding { uf_is_conlike = con }) = con -isConLikeUnfolding _ = False +isConLikeUnfolding (OtherCon _) = True +isConLikeUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_conlike cache +isConLikeUnfolding _ = False -- | Is the thing we will unfold into certainly cheap? isCheapUnfolding :: Unfolding -> Bool -isCheapUnfolding (CoreUnfolding { uf_is_work_free = is_wf }) = is_wf -isCheapUnfolding _ = False +isCheapUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_work_free cache +isCheapUnfolding _ = False isExpandableUnfolding :: Unfolding -> Bool -isExpandableUnfolding (CoreUnfolding { uf_expandable = is_expable }) = is_expable -isExpandableUnfolding _ = False +isExpandableUnfolding (CoreUnfolding { uf_cache = cache }) = uf_expandable cache +isExpandableUnfolding _ = False expandUnfolding_maybe :: Unfolding -> Maybe CoreExpr -- Expand an expandable unfolding; this is used in rule matching -- See Note [Expanding variables] in GHC.Core.Rules -- The key point here is that CONLIKE things can be expanded -expandUnfolding_maybe (CoreUnfolding { uf_expandable = True, uf_tmpl = rhs }) = Just rhs -expandUnfolding_maybe _ = Nothing +expandUnfolding_maybe (CoreUnfolding { uf_cache = cache, uf_tmpl = rhs }) + | uf_expandable cache + = Just rhs +expandUnfolding_maybe _ = Nothing isCompulsoryUnfolding :: Unfolding -> Bool isCompulsoryUnfolding (CoreUnfolding { uf_src = src }) = isCompulsorySource src ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -4210,7 +4210,7 @@ simplLetUnfolding env bind_cxt id new_rhs rhs_ty arity unf mkLetUnfolding :: UnfoldingOpts -> TopLevelFlag -> UnfoldingSource -> InId -> OutExpr -> SimplM Unfolding mkLetUnfolding !uf_opts top_lvl src id new_rhs - = return (mkUnfolding uf_opts src is_top_lvl is_bottoming new_rhs) + = return (mkUnfolding uf_opts src is_top_lvl is_bottoming new_rhs Nothing) -- We make an unfolding *even for loop-breakers*. -- Reason: (a) It might be useful to know that they are WHNF -- (b) In GHC.Iface.Tidy we currently assume that, if we want to @@ -4270,7 +4270,7 @@ simplStableUnfolding env bind_cxt id rhs_ty id_arity unf -- A test case is #4138 -- But retain a previous boring_ok of True; e.g. see -- the way it is set in calcUnfoldingGuidanceWithArity - in return (mkCoreUnfolding src is_top_lvl expr' guide') + in return (mkCoreUnfolding src is_top_lvl expr' Nothing guide') -- See Note [Top-level flag on inline rules] in GHC.Core.Unfold _other -- Happens for INLINABLE things ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -2169,7 +2169,7 @@ abstractFloats uf_opts top_lvl main_tvs floats body = (poly_id `setIdUnfolding` unf, poly_rhs) where poly_rhs = mkLams tvs_here rhs - unf = mkUnfolding uf_opts VanillaSrc is_top_lvl False poly_rhs + unf = mkUnfolding uf_opts VanillaSrc is_top_lvl False poly_rhs Nothing -- We want the unfolding. Consider -- let ===================================== compiler/GHC/Core/Ppr.hs ===================================== @@ -627,18 +627,14 @@ instance Outputable Unfolding where <+> sep (map (pprBndr LambdaBind) bndrs) <+> arrow) 2 (ppr con <+> sep (map ppr args)) ppr (CoreUnfolding { uf_src = src - , uf_tmpl=rhs, uf_is_top=top, uf_is_value=hnf - , uf_is_conlike=conlike, uf_is_work_free=wf - , uf_expandable=exp, uf_guidance=g }) + , uf_tmpl=rhs, uf_is_top=top + , uf_cache=cache, uf_guidance=g }) = text "Unf" <> braces (pp_info $$ pp_rhs) where pp_info = fsep $ punctuate comma [ text "Src=" <> ppr src , text "TopLvl=" <> ppr top - , text "Value=" <> ppr hnf - , text "ConLike=" <> ppr conlike - , text "WorkFree=" <> ppr wf - , text "Expandable=" <> ppr exp + , ppr cache , text "Guidance=" <> ppr g ] pp_tmpl = ppUnlessOption sdocSuppressUnfoldings (text "Tmpl=" <+> ppr rhs) @@ -647,6 +643,15 @@ instance Outputable Unfolding where -- Don't print the RHS or we get a quadratic -- blowup in the size of the printout! +instance Outputable UnfoldingCache where + ppr (UnfoldingCache { uf_is_value = hnf, uf_is_conlike = conlike + , uf_is_work_free = wf, uf_expandable = exp }) + = fsep $ punctuate comma + [ text "Value=" <> ppr hnf + , text "ConLike=" <> ppr conlike + , text "WorkFree=" <> ppr wf + , text "Expandable=" <> ppr exp ] + {- ----------------------------------------------------- -- Rules ===================================== compiler/GHC/Core/Seq.hs ===================================== @@ -104,10 +104,11 @@ seqAlts (Alt c bs e:alts) = c `seq` seqBndrs bs `seq` seqExpr e `seq` seqAlts al seqUnfolding :: Unfolding -> () seqUnfolding (CoreUnfolding { uf_tmpl = e, uf_is_top = top, - uf_is_value = b1, uf_is_work_free = b2, - uf_expandable = b3, uf_is_conlike = b4, - uf_guidance = g}) - = seqExpr e `seq` top `seq` b1 `seq` b2 `seq` b3 `seq` b4 `seq` seqGuidance g + uf_cache = cache, uf_guidance = g}) + = seqExpr e `seq` top `seq` cache `seq` seqGuidance g + -- The unf_cache :: UnfoldingCache field is a strict data type, + -- so it is sufficient to use plain `seq` for this field + -- See Note [UnfoldingCache] in GHC.Core seqUnfolding _ = () ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -759,7 +759,7 @@ add_info env old_bndr top_level new_rhs new_bndr unfolding_from_rhs = mkUnfolding uf_opts VanillaSrc (isTopLevel top_level) False -- may be bottom or not - new_rhs + new_rhs Nothing simpleUnfoldingFun :: IdUnfoldingFun simpleUnfoldingFun id ===================================== compiler/GHC/Core/Tidy.hs ===================================== @@ -375,15 +375,16 @@ tidyNestedUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = arg (tidy_env', bndrs') = tidyBndrs tidy_env bndrs tidyNestedUnfolding tidy_env - unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_is_value = is_value }) + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_cache = cache }) | isStableSource src = seqIt $ unf { uf_tmpl = tidyExpr tidy_env unf_rhs } -- Preserves OccInfo - -- This seqIt avoids a space leak: otherwise the uf_is_value, - -- uf_is_conlike, ... fields may retain a reference to the - -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) + -- This seqIt avoids a space leak: otherwise the uf_cache + -- field may retain a reference to the pre-tidied + -- expression forever (GHC.CoreToIface doesn't look at + -- them) -- Discard unstable unfoldings, but see Note [Preserve evaluatedness] - | is_value = evaldUnfolding + | uf_is_value cache = evaldUnfolding | otherwise = noUnfolding where ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -1036,11 +1036,11 @@ callSiteInline logger opts !case_depth id active_unfolding lone_variable arg_inf -- Things with an INLINE pragma may have an unfolding *and* -- be a loop breaker (maybe the knot is not yet untied) CoreUnfolding { uf_tmpl = unf_template - , uf_is_work_free = is_wf - , uf_guidance = guidance, uf_expandable = is_exp } + , uf_cache = unf_cache + , uf_guidance = guidance } | active_unfolding -> tryUnfolding logger opts case_depth id lone_variable arg_infos cont_info unf_template - is_wf is_exp guidance + unf_cache guidance | otherwise -> traceInline logger opts id "Inactive unfolding:" (ppr id) Nothing NoUnfolding -> Nothing BootUnfolding -> Nothing @@ -1162,11 +1162,10 @@ needed on a per-module basis. -} tryUnfolding :: Logger -> UnfoldingOpts -> Int -> Id -> Bool -> [ArgSummary] -> CallCtxt - -> CoreExpr -> Bool -> Bool -> UnfoldingGuidance + -> CoreExpr -> UnfoldingCache -> UnfoldingGuidance -> Maybe CoreExpr -tryUnfolding logger opts !case_depth id lone_variable - arg_infos cont_info unf_template - is_wf is_exp guidance +tryUnfolding logger opts !case_depth id lone_variable arg_infos + cont_info unf_template unf_cache guidance = case guidance of UnfNever -> traceInline logger opts id str (text "UnfNever") Nothing @@ -1178,7 +1177,7 @@ tryUnfolding logger opts !case_depth id lone_variable -> traceInline logger opts id str (mk_doc some_benefit empty False) Nothing where some_benefit = calc_some_benefit uf_arity - enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) + enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) UnfIfGoodArgs { ug_args = arg_discounts, ug_res = res_discount, ug_size = size } | unfoldingVeryAggressive opts @@ -1189,9 +1188,6 @@ tryUnfolding logger opts !case_depth id lone_variable -> traceInline logger opts id str (mk_doc some_benefit extra_doc False) Nothing where some_benefit = calc_some_benefit (length arg_discounts) - extra_doc = vcat [ text "case depth =" <+> int case_depth - , text "depth based penalty =" <+> int depth_penalty - , text "discounted size =" <+> int adjusted_size ] -- See Note [Avoid inlining into deeply nested cases] depth_treshold = unfoldingCaseThreshold opts depth_scaling = unfoldingCaseScaling opts @@ -1201,7 +1197,18 @@ tryUnfolding logger opts !case_depth id lone_variable small_enough = adjusted_size <= unfoldingUseThreshold opts discount = computeDiscount arg_discounts res_discount arg_infos cont_info + extra_doc = vcat [ text "case depth =" <+> int case_depth + , text "depth based penalty =" <+> int depth_penalty + , text "discounted size =" <+> int adjusted_size ] + where + -- Unpack the UnfoldingCache lazily because it may not be needed, and all + -- its fields are strict; so evaluating unf_cache at all forces all the + -- isWorkFree etc computations to take place. That risks wasting effort for + -- Ids that are never going to inline anyway. + -- See Note [UnfoldingCache] in GHC.Core + UnfoldingCache{ uf_is_work_free = is_wf, uf_expandable = is_exp } = unf_cache + mk_doc some_benefit extra_doc yes_or_no = vcat [ text "arg infos" <+> ppr arg_infos , text "interesting continuation" <+> ppr cont_info ===================================== compiler/GHC/Core/Unfold/Make.hs ===================================== @@ -6,6 +6,7 @@ module GHC.Core.Unfold.Make , mkUnfolding , mkCoreUnfolding , mkFinalUnfolding + , mkFinalUnfolding' , mkSimpleUnfolding , mkWorkerUnfolding , mkInlineUnfoldingWithArity, mkInlineUnfoldingNoArity @@ -35,6 +36,8 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Panic +import Data.Maybe ( fromMaybe ) + -- the very simple optimiser is used to optimise unfoldings import {-# SOURCE #-} GHC.Core.SimpleOpt @@ -43,7 +46,14 @@ import {-# SOURCE #-} GHC.Core.SimpleOpt mkFinalUnfolding :: UnfoldingOpts -> UnfoldingSource -> DmdSig -> CoreExpr -> Unfolding -- "Final" in the sense that this is a GlobalId that will not be further -- simplified; so the unfolding should be occurrence-analysed -mkFinalUnfolding opts src strict_sig expr +mkFinalUnfolding opts src strict_sig expr = mkFinalUnfolding' opts src strict_sig expr Nothing + +-- See Note [Tying the 'CoreUnfolding' knot] for why interfaces need +-- to pass a precomputed 'UnfoldingCache' +mkFinalUnfolding' :: UnfoldingOpts -> UnfoldingSource -> DmdSig -> CoreExpr -> Maybe UnfoldingCache -> Unfolding +-- "Final" in the sense that this is a GlobalId that will not be further +-- simplified; so the unfolding should be occurrence-analysed +mkFinalUnfolding' opts src strict_sig expr = mkUnfolding opts src True {- Top level -} (isDeadEndSig strict_sig) @@ -57,7 +67,7 @@ mkCompulsoryUnfolding' opts expr = mkCompulsoryUnfolding (simpleOptExpr opts exp mkCompulsoryUnfolding :: CoreExpr -> Unfolding mkCompulsoryUnfolding expr = mkCoreUnfolding CompulsorySrc True - expr + expr Nothing (UnfWhen { ug_arity = 0 -- Arity of unfolding doesn't matter , ug_unsat_ok = unSaturatedOk, ug_boring_ok = boringCxtOk }) @@ -69,7 +79,7 @@ mkCompulsoryUnfolding expr mkSimpleUnfolding :: UnfoldingOpts -> CoreExpr -> Unfolding mkSimpleUnfolding !opts rhs - = mkUnfolding opts VanillaSrc False False rhs + = mkUnfolding opts VanillaSrc False False rhs Nothing mkDFunUnfolding :: [Var] -> DataCon -> [CoreExpr] -> Unfolding mkDFunUnfolding bndrs con ops @@ -81,7 +91,7 @@ mkDFunUnfolding bndrs con ops mkDataConUnfolding :: CoreExpr -> Unfolding -- Used for non-newtype data constructors with non-trivial wrappers mkDataConUnfolding expr - = mkCoreUnfolding StableSystemSrc True expr guide + = mkCoreUnfolding StableSystemSrc True expr Nothing guide -- No need to simplify the expression where guide = UnfWhen { ug_arity = manifestArity expr @@ -93,7 +103,7 @@ mkWrapperUnfolding :: SimpleOpts -> CoreExpr -> Arity -> Unfolding -- after demand/CPR analysis mkWrapperUnfolding opts expr arity = mkCoreUnfolding StableSystemSrc True - (simpleOptExpr opts expr) + (simpleOptExpr opts expr) Nothing (UnfWhen { ug_arity = arity , ug_unsat_ok = unSaturatedOk , ug_boring_ok = boringCxtNotOk }) @@ -104,7 +114,7 @@ mkWorkerUnfolding opts work_fn (CoreUnfolding { uf_src = src, uf_tmpl = tmpl , uf_is_top = top_lvl }) | isStableSource src - = mkCoreUnfolding src top_lvl new_tmpl guidance + = mkCoreUnfolding src top_lvl new_tmpl Nothing guidance where new_tmpl = simpleOptExpr opts (work_fn tmpl) guidance = calcUnfoldingGuidance (so_uf_opts opts) False new_tmpl @@ -119,7 +129,7 @@ mkInlineUnfoldingNoArity :: SimpleOpts -> UnfoldingSource -> CoreExpr -> Unfoldi mkInlineUnfoldingNoArity opts src expr = mkCoreUnfolding src True -- Note [Top-level flag on inline rules] - expr' guide + expr' Nothing guide where expr' = simpleOptExpr opts expr guide = UnfWhen { ug_arity = manifestArity expr' @@ -133,7 +143,7 @@ mkInlineUnfoldingWithArity :: SimpleOpts -> UnfoldingSource -> Arity -> CoreExpr mkInlineUnfoldingWithArity opts src arity expr = mkCoreUnfolding src True -- Note [Top-level flag on inline rules] - expr' guide + expr' Nothing guide where expr' = simpleOptExpr opts expr guide = UnfWhen { ug_arity = arity @@ -146,7 +156,7 @@ mkInlineUnfoldingWithArity opts src arity expr mkInlinableUnfolding :: SimpleOpts -> UnfoldingSource -> CoreExpr -> Unfolding mkInlinableUnfolding opts src expr - = mkUnfolding (so_uf_opts opts) src False False expr' + = mkUnfolding (so_uf_opts opts) src False False expr' Nothing where expr' = simpleOptExpr opts expr @@ -180,7 +190,7 @@ specUnfolding opts spec_bndrs spec_app rule_lhs_args , uf_guidance = old_guidance }) | isStableSource src -- See Note [Specialising unfoldings] , UnfWhen { ug_arity = old_arity } <- old_guidance - = mkCoreUnfolding src top_lvl new_tmpl + = mkCoreUnfolding src top_lvl new_tmpl Nothing (old_guidance { ug_arity = old_arity - arity_decrease }) where new_tmpl = simpleOptExpr opts $ @@ -310,11 +320,12 @@ mkUnfolding :: UnfoldingOpts -> Bool -- Definitely a bottoming binding -- (only relevant for top-level bindings) -> CoreExpr + -> Maybe UnfoldingCache -> Unfolding -- Calculates unfolding guidance -- Occurrence-analyses the expression before capturing it -mkUnfolding opts src top_lvl is_bottoming expr - = mkCoreUnfolding src top_lvl expr guidance +mkUnfolding opts src top_lvl is_bottoming expr cache + = mkCoreUnfolding src top_lvl expr cache guidance where is_top_bottoming = top_lvl && is_bottoming guidance = calcUnfoldingGuidance opts is_top_bottoming expr @@ -322,26 +333,20 @@ mkUnfolding opts src top_lvl is_bottoming expr -- See Note [Calculate unfolding guidance on the non-occ-anal'd expression] mkCoreUnfolding :: UnfoldingSource -> Bool -> CoreExpr - -> UnfoldingGuidance -> Unfolding + -> Maybe UnfoldingCache -> UnfoldingGuidance -> Unfolding -- Occurrence-analyses the expression before capturing it -mkCoreUnfolding src top_lvl expr guidance - = CoreUnfolding { uf_tmpl = is_value `seq` - is_conlike `seq` - is_work_free `seq` - is_expandable `seq` +mkCoreUnfolding src top_lvl expr precomputed_cache guidance + = CoreUnfolding { uf_tmpl = cache `seq` occurAnalyseExpr expr -- occAnalyseExpr: see Note [Occurrence analysis of unfoldings] - -- See #20905 for what a discussion of these 'seq's + -- See #20905 for what a discussion of this 'seq'. -- We are careful to make sure we only -- have one copy of an unfolding around at once. -- Note [Thoughtful forcing in mkCoreUnfolding] , uf_src = src , uf_is_top = top_lvl - , uf_is_value = is_value - , uf_is_conlike = is_conlike - , uf_is_work_free = is_work_free - , uf_expandable = is_expandable + , uf_cache = cache , uf_guidance = guidance } where is_value = exprIsHNF expr @@ -349,6 +354,13 @@ mkCoreUnfolding src top_lvl expr guidance is_work_free = exprIsWorkFree expr is_expandable = exprIsExpandable expr + recomputed_cache = UnfoldingCache { uf_is_value = is_value + , uf_is_conlike = is_conlike + , uf_is_work_free = is_work_free + , uf_expandable = is_expandable } + + cache = fromMaybe recomputed_cache precomputed_cache + ---------------- certainlyWillInline :: UnfoldingOpts -> IdInfo -> CoreExpr -> Maybe Unfolding -- ^ Sees if the unfolding is pretty certain to inline. @@ -476,4 +488,3 @@ reducing memory pressure. The result of fixing this led to a 1G reduction in peak memory usage (12G -> 11G) when compiling a very large module (peak 3 million terms). For more discussion see #20905. -} - ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -2253,10 +2253,9 @@ diffUnfold env (DFunUnfolding bs1 c1 a1) | c1 == c2 && equalLength bs1 bs2 = concatMap (uncurry (diffExpr False env')) (zip a1 a2) where env' = rnBndrs2 env bs1 bs2 -diffUnfold env (CoreUnfolding t1 _ _ v1 cl1 wf1 x1 g1) - (CoreUnfolding t2 _ _ v2 cl2 wf2 x2 g2) - | v1 == v2 && cl1 == cl2 - && wf1 == wf2 && x1 == x2 && g1 == g2 +diffUnfold env (CoreUnfolding t1 _ _ c1 g1) + (CoreUnfolding t2 _ _ c2 g2) + | c1 == c2 && g1 == g2 = diffExpr False env t1 t2 diffUnfold _ uf1 uf2 = [fsep [ppr uf1, text "/=", ppr uf2]] ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -508,9 +508,10 @@ toIfaceJoinInfo Nothing = IfaceNotJoinPoint toIfUnfolding :: Bool -> Unfolding -> Maybe IfaceInfoItem toIfUnfolding lb (CoreUnfolding { uf_tmpl = rhs , uf_src = src + , uf_cache = cache , uf_guidance = guidance }) = Just $ HsUnfold lb $ - IfCoreUnfold src (toIfGuidance src guidance) (toIfaceExpr rhs) + IfCoreUnfold src cache (toIfGuidance src guidance) (toIfaceExpr rhs) -- Yes, even if guidance is UnfNever, expose the unfolding -- If we didn't want to expose the unfolding, GHC.Iface.Tidy would -- have stuck in NoUnfolding. For supercompilation we want ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -596,8 +596,8 @@ rnIfaceInfoItem i = pure i rnIfaceUnfolding :: Rename IfaceUnfolding -rnIfaceUnfolding (IfCoreUnfold src guide if_expr) - = IfCoreUnfold src guide <$> rnIfaceExpr if_expr +rnIfaceUnfolding (IfCoreUnfold src cache guide if_expr) + = IfCoreUnfold src cache guide <$> rnIfaceExpr if_expr rnIfaceUnfolding (IfDFunUnfold bs ops) = IfDFunUnfold <$> rnIfaceBndrs bs <*> mapM rnIfaceExpr ops ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -49,7 +49,7 @@ import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey, import GHC.Types.Unique ( hasKey ) import GHC.Iface.Type import GHC.Iface.Recomp.Binary -import GHC.Core( IsOrphan, isOrphan ) +import GHC.Core( IsOrphan, isOrphan, UnfoldingCache(..) ) import GHC.Types.Demand import GHC.Types.Cpr import GHC.Core.Class @@ -365,9 +365,14 @@ data IfaceInfoItem -- only later attached to the Id. Partial reason: some are orphans. data IfaceUnfolding - = IfCoreUnfold UnfoldingSource IfGuidance IfaceExpr + = IfCoreUnfold UnfoldingSource + IfUnfoldingCache -- See Note [Tying the 'CoreUnfolding' knot] + IfGuidance + IfaceExpr | IfDFunUnfold [IfaceBndr] [IfaceExpr] +type IfUnfoldingCache = UnfoldingCache + data IfGuidance = IfNoGuidance -- Compute it from the IfaceExpr | IfWhen Arity Bool Bool -- Just like UnfWhen in Core.UnfoldingGuidance @@ -1522,7 +1527,7 @@ instance Outputable IfaceJoinInfo where ppr (IfaceJoinPoint ar) = angleBrackets (text "join" <+> ppr ar) instance Outputable IfaceUnfolding where - ppr (IfCoreUnfold src guide e) + ppr (IfCoreUnfold src _ guide e) = sep [ text "Core:" <+> ppr src <+> ppr guide, ppr e ] ppr (IfDFunUnfold bs es) = hang (text "DFun:" <+> sep (map ppr bs) <> dot) 2 (sep (map pprParendIfaceExpr es)) @@ -1774,7 +1779,7 @@ freeNamesItem (HsLFInfo (IfLFCon n)) = unitNameSet n freeNamesItem _ = emptyNameSet freeNamesIfUnfold :: IfaceUnfolding -> NameSet -freeNamesIfUnfold (IfCoreUnfold _ _ e) = freeNamesIfExpr e +freeNamesIfUnfold (IfCoreUnfold _ _ _ e) = freeNamesIfExpr e freeNamesIfUnfold (IfDFunUnfold bs es) = freeNamesIfBndrs bs &&& fnList freeNamesIfExpr es freeNamesIfExpr :: IfaceExpr -> NameSet @@ -2296,9 +2301,10 @@ instance Binary IfaceInfoItem where _ -> HsTagSig <$> get bh instance Binary IfaceUnfolding where - put_ bh (IfCoreUnfold s g e) = do + put_ bh (IfCoreUnfold s c g e) = do putByte bh 0 put_ bh s + putUnfoldingCache bh c put_ bh g put_ bh e put_ bh (IfDFunUnfold as bs) = do @@ -2309,9 +2315,10 @@ instance Binary IfaceUnfolding where h <- getByte bh case h of 0 -> do s <- get bh + c <- getUnfoldingCache bh g <- get bh e <- get bh - return (IfCoreUnfold s g e) + return (IfCoreUnfold s c g e) _ -> do as <- get bh bs <- get bh return (IfDFunUnfold as bs) @@ -2332,6 +2339,26 @@ instance Binary IfGuidance where c <- get bh return (IfWhen a b c) +putUnfoldingCache :: BinHandle -> IfUnfoldingCache -> IO () +putUnfoldingCache bh (UnfoldingCache { uf_is_value = hnf, uf_is_conlike = conlike + , uf_is_work_free = wf, uf_expandable = exp }) = do + let b = zeroBits .<<|. hnf .<<|. conlike .<<|. wf .<<|. exp + putByte bh b + +getUnfoldingCache :: BinHandle -> IO IfUnfoldingCache +getUnfoldingCache bh = do + b <- getByte bh + let hnf = testBit b 3 + conlike = testBit b 2 + wf = testBit b 1 + exp = testBit b 0 + return (UnfoldingCache { uf_is_value = hnf, uf_is_conlike = conlike + , uf_is_work_free = wf, uf_expandable = exp }) + +infixl 9 .<<|. +(.<<|.) :: (Bits a) => a -> Bool -> a +x .<<|. b = (if b then (`setBit` 0) else id) (x `shiftL` 1) + instance Binary IfaceAlt where put_ bh (IfaceAlt a b c) = do put_ bh a @@ -2688,8 +2715,9 @@ instance NFData IfGuidance where instance NFData IfaceUnfolding where rnf = \case - IfCoreUnfold src guidance expr -> src `seq` rnf guidance `seq` rnf expr - IfDFunUnfold bndrs exprs -> rnf bndrs `seq` rnf exprs + IfCoreUnfold src cache guidance expr -> src `seq` cache `seq` rnf guidance `seq` rnf expr + IfDFunUnfold bndrs exprs -> rnf bndrs `seq` rnf exprs + -- See Note [UnfoldingCache] in GHC.Core for why it suffices to merely `seq` on cache instance NFData IfaceExpr where rnf = \case ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1715,7 +1715,7 @@ tcIdInfo ignore_prags toplvl name ty info = do need_prag :: IfaceInfoItem -> Bool -- Always read in compulsory unfoldings -- See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy - need_prag (HsUnfold _ (IfCoreUnfold src _ _)) = isCompulsorySource src + need_prag (HsUnfold _ (IfCoreUnfold src _ _ _)) = isCompulsorySource src need_prag _ = False tcPrag :: IdInfo -> IfaceInfoItem -> IfL IdInfo @@ -1776,13 +1776,14 @@ tcLFInfo lfi = case lfi of tcUnfolding :: TopLevelFlag -> Name -> Type -> IdInfo -> IfaceUnfolding -> IfL Unfolding -- See Note [Lazily checking Unfoldings] -tcUnfolding toplvl name _ info (IfCoreUnfold src if_guidance if_expr) +tcUnfolding toplvl name _ info (IfCoreUnfold src cache if_guidance if_expr) = do { uf_opts <- unfoldingOpts <$> getDynFlags ; expr <- tcUnfoldingRhs (isCompulsorySource src) toplvl name if_expr ; let guidance = case if_guidance of IfWhen arity unsat_ok boring_ok -> UnfWhen arity unsat_ok boring_ok IfNoGuidance -> calcUnfoldingGuidance uf_opts is_top_bottoming expr - ; return $ mkCoreUnfolding src True expr guidance } + -- See Note [Tying the 'CoreUnfolding' knot] + ; return $ mkCoreUnfolding src True expr (Just cache) guidance } where -- Strictness should occur before unfolding! is_top_bottoming = isTopLevel toplvl && isDeadEndSig (dmdSigInfo info) @@ -1795,6 +1796,49 @@ tcUnfolding _toplvl name dfun_ty _ (IfDFunUnfold bs ops) doc = text "Class ops for dfun" <+> ppr name (_, _, cls, _) = tcSplitDFunTy dfun_ty +{- Note [Tying the 'CoreUnfolding' knot] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The unfolding of recursive definitions can contain references to the +Id being defined. Consider the following example: + + foo :: () + foo = foo + +The unfolding template of 'foo' is, of course, 'foo'; so the interface +file for this module contains: + + foo :: (); Unfolding = foo + +When rehydrating the interface file we are going to make an Id for +'foo' (in GHC.IfaceToCore), with an 'Unfolding'. We used to make this +'Unfolding' by calling 'mkFinalUnfolding', but that needs to populate, +among other fields, the 'uf_is_value' field, by computing +'exprIsValue' of the template (in this case, 'foo'). + +'exprIsValue e' looks at the unfoldings of variables in 'e' to see if +they are evaluated; so it consults the `uf_is_value` field of +variables in `e`. Now we can see the problem: to set the `uf_is_value` +field of `foo`'s unfolding, we look at its unfolding (in this case +just `foo` itself!). Loop. This is the root cause of ticket #22272. + +The simple solution we chose is to serialise the various auxiliary +fields of `CoreUnfolding` so that we don't need to recreate them when +rehydrating. Specifically, the following fields are moved to the +'UnfoldingCache', which is persisted in the interface file: + +* 'uf_is_conlike' +* 'uf_is_value' +* 'uf_is_work_free' +* 'uf_expandable' + +These four bits make the interface files only one byte larger per +unfolding; on the other hand, this does save calls to 'exprIsValue', +'exprIsExpandable' etc for every imported Id. + +We could choose to do this only for loop breakers. But that's a bit +more complicated and it seems good all round. +-} + {- Note [Lazily checking Unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For unfoldings, we try to do the job lazily, so that we never typecheck ===================================== testsuite/tests/deSugar/should_compile/T13208.stdout ===================================== @@ -1,6 +1,6 @@ - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}] f = \ (@p) _ [Occ=Dead] -> GHC.Types.True - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/numeric/should_compile/T14170.stdout ===================================== @@ -6,44 +6,50 @@ Result size of Tidy Core -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] NatVal.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] NatVal.$trModule3 = GHC.Types.TrNameS NatVal.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] NatVal.$trModule2 = "NatVal"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] NatVal.$trModule1 = GHC.Types.TrNameS NatVal.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] NatVal.$trModule = GHC.Types.Module NatVal.$trModule3 NatVal.$trModule1 -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} foo :: Integer [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] foo = GHC.Num.Integer.IS 0# ===================================== testsuite/tests/numeric/should_compile/T14465.stdout ===================================== @@ -6,43 +6,49 @@ Result size of Tidy Core -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} ten :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] ten = GHC.Num.Natural.NS 10## -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} M.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] M.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.$trModule3 = GHC.Types.TrNameS M.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} M.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] M.$trModule2 = "M"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.$trModule1 = GHC.Types.TrNameS M.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} M.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.$trModule = GHC.Types.Module M.$trModule3 M.$trModule1 -- RHS size: {terms: 1, types: 1, coercions: 0, joins: 0/0} @@ -50,23 +56,25 @@ minusOne :: Natural [GblId, Str=b, Cpr=b, - Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=False, ConLike=False, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] minusOne = GHC.Prim.Exception.raiseUnderflow @Natural -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} twoTimesTwo :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] twoTimesTwo = GHC.Num.Natural.NS 4## -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.one1 :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.one1 = GHC.Num.Natural.NS 1## -- RHS size: {terms: 4, types: 1, coercions: 0, joins: 0/0} @@ -74,15 +82,16 @@ plusOne :: Natural -> Natural [GblId, Arity=1, Str=<1L>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [0] 30 0}] plusOne = \ (n :: Natural) -> naturalAdd n M.one1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} one :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] one = M.one1 ===================================== testsuite/tests/numeric/should_compile/T7116.stdout ===================================== @@ -6,36 +6,41 @@ Result size of Tidy Core -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T7116.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] T7116.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T7116.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T7116.$trModule3 = GHC.Types.TrNameS T7116.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T7116.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] T7116.$trModule2 = "T7116"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T7116.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T7116.$trModule1 = GHC.Types.TrNameS T7116.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7116.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T7116.$trModule = GHC.Types.Module T7116.$trModule3 T7116.$trModule1 @@ -45,8 +50,8 @@ dr :: Double -> Double Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (x [Occ=Once1!] :: Double) -> case x of { GHC.Types.D# x1 -> @@ -62,8 +67,8 @@ dl :: Double -> Double Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] dl = dr @@ -73,8 +78,8 @@ fr :: Float -> Float Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (x [Occ=Once1!] :: Float) -> case x of { GHC.Types.F# x1 -> @@ -92,8 +97,8 @@ fl :: Float -> Float Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] fl = fr ===================================== testsuite/tests/simplCore/should_compile/T22272.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module T22272 where + +import T22272_A + +bar :: () +bar = foo ===================================== testsuite/tests/simplCore/should_compile/T22272.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling T22272_A ( T22272_A.hs, T22272_A.o ) +[2 of 2] Compiling T22272 ( T22272.hs, T22272.o ) ===================================== testsuite/tests/simplCore/should_compile/T22272_A.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module T22272_A where + +foo :: () +foo = foo ===================================== testsuite/tests/simplCore/should_compile/T3772.stdout ===================================== @@ -6,36 +6,41 @@ Result size of Tidy Core -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T3772.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] T3772.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T3772.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T3772.$trModule3 = GHC.Types.TrNameS T3772.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T3772.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] T3772.$trModule2 = "T3772"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T3772.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T3772.$trModule1 = GHC.Types.TrNameS T3772.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3772.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T3772.$trModule = GHC.Types.Module T3772.$trModule3 T3772.$trModule1 @@ -67,8 +72,8 @@ foo [InlPrag=NOINLINE[final]] :: Int -> () Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (n [Occ=Once1!] :: Int) -> case n of { GHC.Types.I# ww [Occ=Once1] -> ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -456,3 +456,4 @@ test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m - test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T22491', normal, compile, ['-O2']) +test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings -fno-omit-interface-pragmas -fno-ignore-interface-pragmas']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ce35a4bb732dc37e77597ca47b1d7579c92bb0f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ce35a4bb732dc37e77597ca47b1d7579c92bb0f You're receiving 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 Dec 12 14:36:11 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Mon, 12 Dec 2022 09:36:11 -0500 Subject: [Git][ghc/ghc][wip/or-pats] Clean-up Message-ID: <63973c5bb0da3_224fca60680123184a@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: af128825 by David Knothe at 2022-12-12T15:36:02+01:00 Clean-up - - - - - 26 changed files: - compiler/GHC/Hs/Pat.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Types/Name/Reader.hs - compiler/Language/Haskell/Syntax/Extension.hs - compiler/Language/Haskell/Syntax/Pat.hs - testsuite/tests/deSugar/should_run/Or5.hs → testsuite/tests/deSugar/should_run/Or4.hs - testsuite/tests/deSugar/should_run/Or5.stderr → testsuite/tests/deSugar/should_run/Or4.stderr - testsuite/tests/deSugar/should_run/Or5.stdout → testsuite/tests/deSugar/should_run/Or4.stdout - testsuite/tests/deSugar/should_run/all.T - testsuite/tests/parser/should_fail/Or1.hs - testsuite/tests/parser/should_fail/Or1.stderr - testsuite/tests/parser/should_fail/Or2.hs - testsuite/tests/parser/should_fail/Or2.stderr - − testsuite/tests/parser/should_fail/Or3.hs - − testsuite/tests/parser/should_fail/Or3.stderr - testsuite/tests/parser/should_fail/all.T - − testsuite/tests/rename/should_fail/Or4.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/rename/should_fail/Or4.hs → testsuite/tests/typecheck/should_fail/Or3.hs - + testsuite/tests/typecheck/should_fail/Or3.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Hs/Pat.hs ===================================== @@ -122,7 +122,7 @@ type instance XTuplePat GhcPs = EpAnn [AddEpAnn] type instance XTuplePat GhcRn = NoExtField type instance XTuplePat GhcTc = [Type] -type instance XOrPat GhcPs = EpAnn [AddEpAnn] +type instance XOrPat GhcPs = NoExtField type instance XOrPat GhcRn = NoExtField type instance XOrPat GhcTc = Type ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -425,13 +425,13 @@ tidyEqnInfo _ (EqnInfo { eqn_pats = [] }) tidyEqnInfo v eqn@(EqnInfo { eqn_pats = pat : pats, eqn_orig = orig }) = do { (wrap, pat') <- tidy1 v orig pat - ; return $ (wrap, eqn { eqn_pats = pat' : pats }) } + ; return (wrap, eqn { eqn_pats = pat' : pats }) } tidy1 :: Id -- The Id being scrutinised -> Origin -- Was this a pattern the user wrote? -> Pat GhcTc -- The pattern against which it is to be matched -> DsM (DsWrapper, -- Extra bindings to do before the match - Pat GhcTc) -- Equivalent pattern(s) + Pat GhcTc) -- Equivalent pattern ------------------------------------------------------- -- (pat', mr') = tidy1 v pat mr @@ -447,7 +447,7 @@ tidy1 v o (BangPat _ (L l p)) = tidy_bang_pat v o l p tidy1 v o (OrPat x pats) = do (wraps, pats) <- mapAndUnzipM (tidy1 v o . unLoc) (NEL.toList pats) let wrap = foldr (.) id wraps in - return $ (wrap, OrPat x (NEL.fromList $ map (L noSrcSpanA) pats)) + return (wrap, OrPat x (NEL.fromList $ map (L noSrcSpanA) pats)) -- case v of { x -> mr[] } -- = case v of { _ -> let x=v in mr[] } ===================================== compiler/GHC/HsToCore/Pmc/Desugar.hs ===================================== @@ -26,7 +26,7 @@ import GHC.Hs import GHC.Tc.Utils.Zonk (shortCutLit) import GHC.Types.Id import GHC.Core.ConLike -import GHC.Types.Name ( NamedThing(getName) ) +import GHC.Types.Name import GHC.Builtin.Types import GHC.Builtin.Names (rationalTyConName) import GHC.Types.SrcLoc ===================================== compiler/GHC/Parser.y ===================================== @@ -3063,7 +3063,7 @@ texp :: { ECP } | 'one' 'of' vocurly orpats close {% do { - let pat = sLLa $1 (reLoc (last $4)) (mkorpat $4) + let pat = sLLa $1 (reLoc (last $4)) (OrPat NoExtField (NE.fromList $4)) ; orPatsOn <- hintOrPats pat ; when (orPatsOn && length $4 < 2) $ addError $ mkPlainErrorMsgEnvelope (locA (getLoc pat)) (PsErrOrPatNeedsTwoAlternatives pat) ; return $ ecpFromPat pat @@ -4273,10 +4273,6 @@ msemim l = if isZeroWidthSpan (gl l) then Nothing else Just (EpaSpan $ rs $ gl l mu :: AnnKeywordId -> Located Token -> AddEpAnn mu a lt@(L l t) = AddEpAnn (toUnicodeAnn a lt) (EpaSpan $ rs l) --- Merge the source spans of the tokens into the first one. -merge_ts :: Located Token -> Located Token -> Located Token -merge_ts (L l1 t) (L l2 _) = L (combineSrcSpans l1 l2) t - -- | If the 'Token' is using its unicode variant return the unicode variant of -- the annotation toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId ===================================== compiler/GHC/Parser/Errors/Types.hs ===================================== @@ -471,8 +471,10 @@ data PsMessage Char -- ^ the character it looks like String -- ^ the name of the character that it looks like + -- | Or pattern used without -XOrPatterns | PsErrIllegalOrPat (LPat GhcPs) + -- | Or pattern with just a single alternative like (one of x) | PsErrOrPatNeedsTwoAlternatives (LPat GhcPs) deriving Generic ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -110,7 +110,7 @@ module GHC.Parser.PostProcess ( DisambECP(..), ecpFromExp, ecpFromCmd, - ecpFromPat, mkorpat, + ecpFromPat, PatBuilder, -- Type/datacon ambiguity resolution @@ -1469,9 +1469,6 @@ ecpFromCmd a = ECP (ecpFromCmd' a) ecpFromPat :: LPat GhcPs -> ECP ecpFromPat a = ECP (ecpFromPat' a) -mkorpat :: [LPat GhcPs] -> Pat GhcPs -mkorpat ps = OrPat EpAnnNotUsed (NE.fromList ps) - -- The 'fbinds' parser rule produces values of this type. See Note -- [RecordDotSyntax field updates]. type Fbind b = Either (LHsRecField GhcPs (LocatedA b)) (LHsRecProj GhcPs (LocatedA b)) @@ -1604,9 +1601,6 @@ class (b ~ (Body b) GhcPs, AnnoBody b) => DisambECP b where mkHsViewPatPV :: SrcSpan -> LHsExpr GhcPs -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b) -- | Disambiguate "a at b" (as-pattern) - mkHsOrPatPV - :: SrcSpan -> LocatedA b -> LocatedA b -> [AddEpAnn] -> PV (LocatedA b) - -- | Disambiguate "a at b" (as-pattern) mkHsAsPatPV :: SrcSpan -> LocatedN RdrName -> LHsToken "@" GhcPs -> LocatedA b -> PV (LocatedA b) -- | Disambiguate "~a" (lazy pattern) @@ -1729,8 +1723,6 @@ instance DisambECP (HsCmd GhcPs) where in pp_op <> ppr c mkHsViewPatPV l a b _ = cmdFail l $ ppr a <+> text "->" <+> ppr b - mkHsOrPatPV l a b _ = cmdFail l $ - ppr a <+> text "->" <+> ppr b mkHsAsPatPV l v _ c = cmdFail l $ pprPrefixOcc (unLoc v) <> text "@" <> ppr c mkHsLazyPatPV l c _ = cmdFail l $ @@ -1828,8 +1820,6 @@ instance DisambECP (HsExpr GhcPs) where return $ L l (SectionR (comment (realSrcSpan l) cs) op e) mkHsViewPatPV l a b _ = addError (mkPlainErrorMsgEnvelope l $ PsErrViewPatInExpr a b) >> return (L (noAnnSrcSpan l) (hsHoleExpr noAnn)) - mkHsOrPatPV l a b _ = addError (mkPlainErrorMsgEnvelope l $ PsErrViewPatInExpr a b) -- todo OR - >> return (L (noAnnSrcSpan l) (hsHoleExpr noAnn)) mkHsAsPatPV l v _ e = addError (mkPlainErrorMsgEnvelope l $ PsErrTypeAppWithoutSpace (unLoc v) e) >> return (L (noAnnSrcSpan l) (hsHoleExpr noAnn)) mkHsLazyPatPV l e _ = addError (mkPlainErrorMsgEnvelope l $ PsErrLazyPatWithoutSpace e) @@ -1914,15 +1904,6 @@ instance DisambECP (PatBuilder GhcPs) where p <- checkLPat b cs <- getCommentsFor l return $ L (noAnnSrcSpan l) (PatBuilderPat (ViewPat (EpAnn (spanAsAnchor l) anns cs) a p)) - mkHsOrPatPV l a b anns = do - p <- flatten <$> checkLPat a - q <- flatten <$> checkLPat b - cs <- getCommentsFor l - return $ L (noAnnSrcSpan l) (PatBuilderPat (OrPat (EpAnn (spanAsAnchor l) anns cs) (NE.append p q))) - where - flatten :: LPat GhcPs -> NE.NonEmpty (LPat GhcPs) - flatten (L _ (OrPat _ xs)) = join (NE.map flatten xs) - flatten x = NE.singleton x mkHsAsPatPV l v at e = do p <- checkLPat e cs <- getCommentsFor l ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -2552,7 +2552,7 @@ data TcRnMessage where or-pattern binds variables or has dictionary or evidence biders, e.g. (one of A, B x). Test case: - none yet (TODO) + testsuite/tests/typecheck/should_fail/Or3 -} TcRnOrPatBindsVariables :: Pat GhcTc -- the or-pattern ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1375,4 +1375,4 @@ pprLoc (UnhelpfulSpan {}) = empty -- | Indicate if the given name is the "@" operator opIsAt :: RdrName -> Bool -opIsAt e = e == mkUnqual varName (fsLit "@") \ No newline at end of file +opIsAt e = e == mkUnqual varName (fsLit "@") ===================================== compiler/Language/Haskell/Syntax/Extension.hs ===================================== @@ -66,7 +66,7 @@ See also Note [IsPass] and Note [NoGhcTc] in GHC.Hs.Extension. -} -- | A placeholder type for TTG extension points that are not currently --- unused to represent any particular value. +-- used to represent any particular value. -- -- This should not be confused with 'DataConCantHappen', which are found in unused -- extension /constructors/ and therefore should never be inhabited. In ===================================== compiler/Language/Haskell/Syntax/Pat.hs ===================================== @@ -140,7 +140,8 @@ data Pat p | OrPat (XOrPat p) (NEL.NonEmpty (LPat p)) - + -- ^ Or Pattern + | SumPat (XSumPat p) -- after typechecker, types of the alternative (LPat p) -- Sum sub-pattern ConTag -- Alternative (one-based) ===================================== testsuite/tests/deSugar/should_run/Or5.hs → testsuite/tests/deSugar/should_run/Or4.hs ===================================== ===================================== testsuite/tests/deSugar/should_run/Or5.stderr → testsuite/tests/deSugar/should_run/Or4.stderr ===================================== @@ -1,3 +1,3 @@ -Or5: no backtracking +Or4: no backtracking CallStack (from HasCallStack): - error, called at Or5.hs:42:8 in main:Main + error, called at Or4.hs:42:8 in main:Main ===================================== testsuite/tests/deSugar/should_run/Or5.stdout → testsuite/tests/deSugar/should_run/Or4.stdout ===================================== ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -75,4 +75,4 @@ test('T19680', normal, compile_and_run, ['']) test('T19680A', normal, compile_and_run, ['']) test('T20024', exit_code(1), compile_and_run, ['']) -test('Or5', exit_code(1), compile_and_run, ['']) +test('Or4', exit_code(1), compile_and_run, ['']) ===================================== testsuite/tests/parser/should_fail/Or1.hs ===================================== @@ -1,4 +1,9 @@ module Main where -main = case 1 of - (one of 2, 3) -> True \ No newline at end of file +main = g 3 && h 1 + +h y = case y of + (one of 2, 3) -> True + +g x = case x of + one of 4, 5 -> False \ No newline at end of file ===================================== testsuite/tests/parser/should_fail/Or1.stderr ===================================== @@ -1,4 +1,6 @@ -Or1.hs:4:4: error: [GHC-29847] +Or1.hs:6:4: error: [GHC-29847] Illegal or-pattern: one of 2, 3 Suggested fix: Perhaps you intended to use OrPatterns + +Or1.hs:9:7: error: [GHC-58481] parse error on input ‘of’ ===================================== testsuite/tests/parser/should_fail/Or2.hs ===================================== @@ -1,4 +1,6 @@ +{-# LANGUAGE OrPatterns #-} + module Main where main = case 3 of - one of 4, 5 -> False \ No newline at end of file + (one of 4) -> False \ No newline at end of file ===================================== testsuite/tests/parser/should_fail/Or2.stderr ===================================== @@ -1,2 +1,3 @@ -Or2.hs:4:7: error: [GHC-58481] parse error on input ‘of’ +Or2.hs:6:4: error: [GHC-96152] + Or-pattern needs at least two alternatives: one of 4 ===================================== testsuite/tests/parser/should_fail/Or3.hs deleted ===================================== @@ -1,7 +0,0 @@ -{-# LANGUAGE OrPatterns #-} - -module Main where - -main = case 3 of - (one of 4) -> False - (one of x, _) -> x == 3 \ No newline at end of file ===================================== testsuite/tests/parser/should_fail/Or3.stderr deleted ===================================== @@ -1,3 +0,0 @@ - -Or3.hs:6:4: error: [GHC-96152] - Or-pattern needs at least two alternatives: one of 4 ===================================== testsuite/tests/parser/should_fail/all.T ===================================== @@ -218,4 +218,3 @@ test('T21843f', normal, compile_fail, ['']) test('Or1', normal, compile_fail, ['']) test('Or2', normal, compile_fail, ['']) -test('Or3', normal, compile_fail, ['']) ===================================== testsuite/tests/rename/should_fail/Or4.stderr deleted ===================================== @@ -1,131 +0,0 @@ -*** Core Lint errors : in result of Desugar (before optimization) *** -Or4.hs:11:5: warning: - Out of scope: $dNum_aDz :: Num a_aDq - [LclId] - In the RHS of foo :: forall a. a -> GADT a -> a - In the body of lambda with binder a_aDq :: * - In the body of lambda with binder x_aw0 :: a_aDq - In the body of lambda with binder ds_dMh :: GADT a_aDq - In the body of lambda with binder ds_dMt :: (# #) - In an occurrence of $dNum_aDz :: Num a_aDq - Substitution: a_aDq] - CvSubst = []> -*** Offending Program *** -Rec { -$tcGADT :: TyCon -[LclIdX] -$tcGADT - = TyCon - 7315894308497656774#Word64 - 13366801423186927574#Word64 - $trModule - (TrNameS "GADT"#) - 0# - krep$*Arr* - -$tc'IsInt1 :: TyCon -[LclIdX] -$tc'IsInt1 - = TyCon - 1090152040133353571#Word64 - 3950193049621776869#Word64 - $trModule - (TrNameS "'IsInt1"#) - 0# - $krep_aLk - -$tc'IsInt2 :: TyCon -[LclIdX] -$tc'IsInt2 - = TyCon - 838859291769359256#Word64 - 1629192201818783450#Word64 - $trModule - (TrNameS "'IsInt2"#) - 0# - $krep_aLk - -$krep_aLk [InlPrag=[~]] :: KindRep -[LclId] -$krep_aLk - = KindRepTyConApp $tcGADT (: @KindRep $krep_aLl ([] @KindRep)) - -$krep_aLl [InlPrag=[~]] :: KindRep -[LclId] -$krep_aLl = KindRepTyConApp $tcInt ([] @KindRep) - -$trModule :: Module -[LclIdX] -$trModule = Module (TrNameS "main"#) (TrNameS "Main"#) - -foo :: forall a. a -> GADT a -> a -[LclIdX] -foo - = \ (@a_aDq) (x_aw0 :: a_aDq) (ds_dMh :: GADT a_aDq) -> - let { - success_dMs :: (# #) -> a_aDq - [LclId] - success_dMs - = \ (ds_dMt [OS=OneShot] :: (# #)) -> - + @a_aDq - $dNum_aDz - x_aw0 - (fromInteger @a_aDq $dNum_aDB (IS 1#)) } in - case ds_dMh of wild_00 { - IsInt1 co_aDt -> success_dMs (##); - IsInt2 co_aDv -> - let { - $dNum_aL2 :: Num Int - [LclId] - $dNum_aL2 = $fNumInt } in - let { - $dNum_aDB :: Num a_aDq - [LclId] - $dNum_aDB - = $dNum_aL2 - `cast` (Sub (Sym (Num co_aDt)_N) :: Num Int ~R# Num a_aDq) } in - let { - $dNum_aDz :: Num a_aDq - [LclId] - $dNum_aDz - = $dNum_aL2 - `cast` (Sub (Sym (Num co_aDt)_N) :: Num Int ~R# Num a_aDq) } in - success_dMs (##) - } - -main :: IO () -[LclIdX] -main - = let { - $dNum_aKU :: Num Int - [LclId] - $dNum_aKU = $fNumInt } in - let { - $dShow_aKR :: Show Int - [LclId] - $dShow_aKR = $fShowInt } in - letrec { - main_aDF :: IO () - [LclId] - main_aDF - = $ @LiftedRep - @Int - @(IO ()) - (print @Int $dShow_aKR) - (foo @Int (I# 3#) $WIsInt1); } in - main_aDF - -main :: IO () -[LclIdX] -main = runMainIO @() main -end Rec } - -*** End of Offense *** - - -: error: -Compilation had errors - - ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -179,6 +179,4 @@ test('T18138', normal, compile_fail, ['']) test('T20147', normal, compile_fail, ['']) test('RnEmptyStatementGroup1', normal, compile_fail, ['']) -test('RnImplicitBindInMdoNotation', normal, compile_fail, ['']) - -test('Or4', normal, compile_fail, ['']) \ No newline at end of file +test('RnImplicitBindInMdoNotation', normal, compile_fail, ['']) \ No newline at end of file ===================================== testsuite/tests/rename/should_fail/Or4.hs → testsuite/tests/typecheck/should_fail/Or3.hs ===================================== @@ -3,6 +3,14 @@ module Main where +data G a where + G1 :: Num a => G a + G2 :: Num a => G a + G3 :: Num a => G a + +bar :: G a -> a +bar (one of G2, G1) = 3 + data GADT a where IsInt1 :: GADT Int IsInt2 :: GADT Int @@ -10,4 +18,10 @@ data GADT a where foo :: a -> GADT a -> a foo x (one of IsInt1 {}, IsInt2 {}) = x + 1 +f x = case x of + (one of Left a, Right a) -> a + +g x = case x of + (one of _, (one of _, x)) -> x + main = print $ foo 3 IsInt1 \ No newline at end of file ===================================== testsuite/tests/typecheck/should_fail/Or3.stderr ===================================== @@ -0,0 +1,14 @@ + +Or3.hs:12:6: error: [GHC-81303] + Or-pattern may not bind (type) variable, dictionary or equality constraints: one of G2, + G1 + +Or3.hs:19:8: error: [GHC-81303] + Or-pattern may not bind (type) variable, dictionary or equality constraints: one of IsInt1 {}, + IsInt2 {} + +Or3.hs:22:4: error: [GHC-81303] + Or-pattern may not bind variables: one of Left a, Right a + +Or3.hs:25:15: error: [GHC-81303] + Or-pattern may not bind variables: one of _, x ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -663,3 +663,4 @@ test('MissingDefaultMethodBinding', normal, compile_fail, ['']) test('T21447', normal, compile_fail, ['']) test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) +test('Or3', normal, compile_fail, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af12882574c359c39c3f63ac352933d5c6fa79ac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af12882574c359c39c3f63ac352933d5c6fa79ac You're receiving 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 Dec 12 15:59:13 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 10:59:13 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/mp-9.4-backports Message-ID: <63974fd1d9b6b_224fca526d4124895d@gitlab.mail> Matthew Pickering pushed new branch wip/mp-9.4-backports at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/mp-9.4-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 Mon Dec 12 16:00:36 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Mon, 12 Dec 2022 11:00:36 -0500 Subject: [Git][ghc/ghc][wip/or-pats] Change error texts Message-ID: <639750245fec5_224fcafbc67681252647@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 72fab280 by David Knothe at 2022-12-12T17:00:29+01:00 Change error texts - - - - - 4 changed files: - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - testsuite/tests/parser/should_fail/Or2.stderr - testsuite/tests/typecheck/should_fail/Or3.stderr Changes: ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -524,7 +524,7 @@ instance Diagnostic PsMessage where , text "but it is not" ] PsErrOrPatNeedsTwoAlternatives pat - -> mkSimpleDecorated $ vcat [text "Or-pattern needs at least two alternatives:" <+> ppr (unLoc pat)] + -> mkSimpleDecorated $ vcat [text "An or-pattern needs at least two alternatives:" <+> ppr (unLoc pat)] PsErrIllegalOrPat pat -> mkSimpleDecorated $ vcat [text "Illegal or-pattern:" <+> ppr (unLoc pat)] ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1154,8 +1154,8 @@ instance Diagnostic TcRnMessage where TcRnReportCustomQuasiError _ msg -> mkSimpleDecorated $ text msg TcRnInterfaceLookupError _ sdoc -> mkSimpleDecorated sdoc TcRnOrPatBindsVariables pat vars -> case vars of - True -> mkSimpleDecorated $ text "Or-pattern may not bind variables:" <+> ppr pat - False -> mkSimpleDecorated $ text "Or-pattern may not bind (type) variable, dictionary or equality constraints:" <+> ppr pat + True -> mkSimpleDecorated $ text "An or-pattern may not bind variables:" <+> ppr pat + False -> mkSimpleDecorated $ text "An or-pattern may not bind (type) variables nor type class or equality constraints:" <+> ppr pat TcRnUnsatisfiedMinimalDef mindef -> mkSimpleDecorated $ vcat [text "No explicit implementation for" ===================================== testsuite/tests/parser/should_fail/Or2.stderr ===================================== @@ -1,3 +1,3 @@ Or2.hs:6:4: error: [GHC-96152] - Or-pattern needs at least two alternatives: one of 4 + An or-pattern needs at least two alternatives: one of 4 ===================================== testsuite/tests/typecheck/should_fail/Or3.stderr ===================================== @@ -1,14 +1,14 @@ Or3.hs:12:6: error: [GHC-81303] - Or-pattern may not bind (type) variable, dictionary or equality constraints: one of G2, - G1 + An or-pattern may not bind (type) variables nor type class or equality constraints: one of G2, + G1 Or3.hs:19:8: error: [GHC-81303] - Or-pattern may not bind (type) variable, dictionary or equality constraints: one of IsInt1 {}, - IsInt2 {} + An or-pattern may not bind (type) variables nor type class or equality constraints: one of IsInt1 {}, + IsInt2 {} Or3.hs:22:4: error: [GHC-81303] - Or-pattern may not bind variables: one of Left a, Right a + An or-pattern may not bind variables: one of Left a, Right a Or3.hs:25:15: error: [GHC-81303] - Or-pattern may not bind variables: one of _, x + An or-pattern may not bind variables: one of _, x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72fab2802f79756af7f9e240131e6f243733634e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72fab2802f79756af7f9e240131e6f243733634e You're receiving 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 Dec 12 16:29:38 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Mon, 12 Dec 2022 11:29:38 -0500 Subject: [Git][ghc/ghc][wip/or-pats] 66 commits: Add Javascript backend Message-ID: <639756f260557_224fca1d7887741289025@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 34a1ebad by David Knothe at 2022-12-12T17:29:14+01:00 Add Or Patterns (proposal 0522) - - - - - 26 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + compiler/GHC/Core/TyCo/FVs.hs-boot - 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/72fab2802f79756af7f9e240131e6f243733634e...34a1ebad3f3f3d02fbabb8d6d1db5797d8449233 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/72fab2802f79756af7f9e240131e6f243733634e...34a1ebad3f3f3d02fbabb8d6d1db5797d8449233 You're receiving 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 Dec 12 16:31:47 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 11:31:47 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/t22599 Message-ID: <639757738c7be_224fca6061c12951dc@gitlab.mail> Matthew Pickering pushed new branch wip/t22599 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t22599 You're receiving 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 Dec 12 16:32:36 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Dec 2022 11:32:36 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Add heqT, a kind-heterogeneous variant of heq Message-ID: <639757a4e951_224fca2595e17c1296989@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - c1871200 by Bryan Richter at 2022-12-12T11:32:29-05:00 Mark T21336a fragile - - - - - 26edef7b by Matthew Pickering at 2022-12-12T11:32:30-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - 6 changed files: - libraries/base/Data/Bifunctor.hs - libraries/base/Data/Typeable.hs - libraries/base/changelog.md - libraries/base/tests/IO/T21336/all.T - + testsuite/tests/simplCore/should_compile/T21476.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== libraries/base/Data/Bifunctor.hs ===================================== @@ -120,8 +120,17 @@ class (forall a. Functor (p a)) => Bifunctor p where second = bimap id - --- | @since 4.8.0.0 +-- | Class laws for tuples hold only up to laziness. Both +-- 'first' 'id' and 'second' 'id' are lazier than 'id' (and 'fmap' 'id'): +-- +-- >>> first id (undefined :: (Int, Word)) `seq` () +-- () +-- >>> second id (undefined :: (Int, Word)) `seq` () +-- () +-- >>> id (undefined :: (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.8.0.0 instance Bifunctor (,) where bimap f g ~(a, b) = (f a, g b) ===================================== libraries/base/Data/Typeable.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy #-} +{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} ----------------------------------------------------------------------------- @@ -56,6 +57,7 @@ module Data.Typeable -- * Type-safe cast , cast , eqT + , heqT , gcast -- a generalisation of cast -- * Generalized casts for higher-order kinds @@ -135,8 +137,14 @@ cast x -- @since 4.7.0.0 eqT :: forall a b. (Typeable a, Typeable b) => Maybe (a :~: b) eqT - | Just HRefl <- ta `I.eqTypeRep` tb = Just Refl - | otherwise = Nothing + | Just HRefl <- heqT @a @b = Just Refl + | otherwise = Nothing + +-- | Extract a witness of heterogeneous equality of two types +-- +-- @since 4.18.0.0 +heqT :: forall a b. (Typeable a, Typeable b) => Maybe (a :~~: b) +heqT = ta `I.eqTypeRep` tb where ta = I.typeRep :: I.TypeRep a tb = I.typeRep :: I.TypeRep b ===================================== libraries/base/changelog.md ===================================== @@ -57,6 +57,7 @@ of individually allocated pointers as well as freeing each one of them when freeing a `Pool`. (#14762) (#18338) * `Type.Reflection.Unsafe` is now marked as unsafe. + * Add `Data.Typeable.heqT`, a kind-heterogeneous version of `Data.Typeable.eqT`. ## 4.17.0.0 *August 2022* ===================================== libraries/base/tests/IO/T21336/all.T ===================================== @@ -1,6 +1,9 @@ # N.B. /dev/full exists on Darwin but cannot be opened, failing with -EPERM test('T21336a', - [unless(opsys('linux') or opsys('freebsd'), skip), js_broken(22261)], + [ unless(opsys('linux') or opsys('freebsd'), skip) + , js_broken(22261) + , fragile(22022) + ], compile_and_run, ['']) test('T21336b', [unless(opsys('linux') or opsys('freebsd'), skip), js_broken(22352)], ===================================== testsuite/tests/simplCore/should_compile/T21476.hs ===================================== @@ -0,0 +1,4 @@ +{-# LANGUAGE MagicHash #-} +module T21476 where +import GHC.Exts +f = keepAlive# ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -456,3 +456,4 @@ test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m - test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T22491', normal, compile, ['-O2']) +test('T21476', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2eedf815a9c58484dc1a27be7f508551953d7594...26edef7bde915be5481b1b42a1cbd1414538e57c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2eedf815a9c58484dc1a27be7f508551953d7594...26edef7bde915be5481b1b42a1cbd1414538e57c You're receiving 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 Dec 12 16:40:15 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 11:40:15 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-9.2-min-version Message-ID: <6397596fddc2e_224fca605f413116ad@gitlab.mail> Matthew Pickering pushed new branch wip/ghc-9.2-min-version at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-9.2-min-version You're receiving 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 Dec 12 16:40:34 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 11:40:34 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.2-min-version] configure: Bump min bootstrap GHC version to 9.2 Message-ID: <6397598210d56_224fcafbc676813118e8@gitlab.mail> Matthew Pickering pushed to branch wip/ghc-9.2-min-version at Glasgow Haskell Compiler / GHC Commits: 23779978 by Bryan Richter at 2022-12-12T16:40:18+00:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 1 changed file: - configure.ac Changes: ===================================== configure.ac ===================================== @@ -224,7 +224,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.0" +MinBootGhcVersion="9.2" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23779978548b7416e354c94ab2f51d6e1a7386a4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23779978548b7416e354c94ab2f51d6e1a7386a4 You're receiving 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 Dec 12 17:32:42 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 12 Dec 2022 12:32:42 -0500 Subject: [Git][ghc/ghc][wip/andreask/inlineable-threshold] Store guidance for stable unfoldings Message-ID: <639765bab131c_389fe2526988109c@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/inlineable-threshold at Glasgow Haskell Compiler / GHC Commits: 8da7e63d by Andreas Klebinger at 2022-12-12T18:30:53+01:00 Store guidance for stable unfoldings - - - - - 6 changed files: - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -4280,7 +4280,7 @@ simplStableUnfolding env bind_cxt id rhs_ty id_arity unf opt_rhs -- based on the size of the optimized core. After all this is what the unfolding -- will optimize to eventually! _other -> do - let rhs_guide = calcUnfoldingGuidance uf_opts (is_top_lvl && is_bottoming) src opt_rhs + let rhs_guide = calcUnfoldingGuidance uf_opts (is_top_lvl && is_bottoming) opt_rhs return (mkCoreUnfolding src is_top_lvl unf_expr' rhs_guide) -- return $ CoreUnfolding { uf_tmpl = unf_expr', uf_src = src, uf_guidance = rhs_guide } ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -229,13 +229,12 @@ inlineBoringOk e calcUnfoldingGuidance :: UnfoldingOpts -> Bool -- Definitely a top-level, bottoming binding - -> UnfoldingSource -- Tells us if this is a stable unfolding -> CoreExpr -- Expression to look at -> UnfoldingGuidance -calcUnfoldingGuidance opts is_top_bottoming src (Tick t expr) +calcUnfoldingGuidance opts is_top_bottoming (Tick t expr) | not (tickishIsCode t) -- non-code ticks don't matter for unfolding - = calcUnfoldingGuidance opts is_top_bottoming src expr -calcUnfoldingGuidance opts is_top_bottoming src expr + = calcUnfoldingGuidance opts is_top_bottoming expr +calcUnfoldingGuidance opts is_top_bottoming expr = case sizeExpr opts bOMB_OUT_SIZE val_bndrs body of TooBig -> UnfNever SizeIs size cased_bndrs scrut_discount ===================================== compiler/GHC/Core/Unfold/Make.hs ===================================== @@ -107,7 +107,7 @@ mkWorkerUnfolding opts work_fn = mkCoreUnfolding src top_lvl new_tmpl guidance where new_tmpl = simpleOptExpr opts (work_fn tmpl) - guidance = calcUnfoldingGuidance (so_uf_opts opts) False src new_tmpl + guidance = calcUnfoldingGuidance (so_uf_opts opts) False new_tmpl mkWorkerUnfolding _ _ _ = noUnfolding @@ -317,7 +317,7 @@ mkUnfolding opts src top_lvl is_bottoming expr = mkCoreUnfolding src top_lvl expr guidance where is_top_bottoming = top_lvl && is_bottoming - guidance = calcUnfoldingGuidance opts is_top_bottoming src expr + guidance = calcUnfoldingGuidance opts is_top_bottoming expr -- NB: *not* (calcUnfoldingGuidance (occurAnalyseExpr expr))! -- See Note [Calculate unfolding guidance on the non-occ-anal'd expression] ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -535,6 +535,8 @@ toIfGuidance :: UnfoldingSource -> UnfoldingGuidance -> IfGuidance toIfGuidance src guidance | UnfWhen arity unsat_ok boring_ok <- guidance , isStableSource src = IfWhen arity unsat_ok boring_ok + | UnfIfGoodArgs args size res <- guidance + , isStableSource src = IfStableGuidance args size res | otherwise = IfNoGuidance {- ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -371,6 +371,10 @@ data IfaceUnfolding data IfGuidance = IfNoGuidance -- Compute it from the IfaceExpr | IfWhen Arity Bool Bool -- Just like UnfWhen in Core.UnfoldingGuidance + | IfStableGuidance { iug_args :: [Int] + , iug_size :: Int + , iug_res :: Int + } -- We only serialise the IdDetails of top-level Ids, and even then -- we only need a very limited selection. Notably, none of the @@ -1530,6 +1534,8 @@ instance Outputable IfaceUnfolding where instance Outputable IfGuidance where ppr IfNoGuidance = empty ppr (IfWhen a u b) = angleBrackets (ppr a <> comma <> ppr u <> ppr b) + ppr (IfStableGuidance a s r) = + angleBrackets (ppr a <> comma <> ppr s <> comma <> ppr r) {- ************************************************************************ @@ -2323,14 +2329,23 @@ instance Binary IfGuidance where put_ bh a put_ bh b put_ bh c + put_ bh (IfStableGuidance a s r ) = do + putByte bh 2 + put_ bh a + put_ bh s + put_ bh r get bh = do h <- getByte bh case h of 0 -> return IfNoGuidance - _ -> do a <- get bh + 1 -> do a <- get bh b <- get bh c <- get bh return (IfWhen a b c) + _ -> do a <- get bh + s <- get bh + r <- get bh + return (IfStableGuidance a s r) instance Binary IfaceAlt where put_ bh (IfaceAlt a b c) = do @@ -2685,6 +2700,7 @@ instance NFData IfGuidance where rnf = \case IfNoGuidance -> () IfWhen a b c -> a `seq` b `seq` c `seq` () + IfStableGuidance a b c -> a `seq` b `seq` c `seq` () instance NFData IfaceUnfolding where rnf = \case ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1781,7 +1781,8 @@ tcUnfolding toplvl name _ info (IfCoreUnfold src if_guidance if_expr) ; expr <- tcUnfoldingRhs (isCompulsorySource src) toplvl name if_expr ; let guidance = case if_guidance of IfWhen arity unsat_ok boring_ok -> UnfWhen arity unsat_ok boring_ok - IfNoGuidance -> calcUnfoldingGuidance uf_opts is_top_bottoming src expr + IfStableGuidance args size res -> UnfIfGoodArgs args size res + IfNoGuidance -> calcUnfoldingGuidance uf_opts is_top_bottoming expr ; return $ mkCoreUnfolding src True expr guidance } where -- Strictness should occur before unfolding! View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8da7e63dfcefa07dd4f9ae070bd8252c0f8ced46 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8da7e63dfcefa07dd4f9ae070bd8252c0f8ced46 You're receiving 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 Dec 12 18:06:07 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 13:06:07 -0500 Subject: [Git][ghc/ghc][wip/t22599] ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Message-ID: <63976d8f45603_389fe252684883a5@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: 33d0fa9f by Matthew Pickering at 2022-12-12T18:05:49+00:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 4 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/ci.sh ===================================== @@ -320,7 +320,7 @@ function fetch_cabal() { MINGW64) cabal_arch="x86_64" ;; *) fail "unknown MSYSTEM $MSYSTEM" ;; esac - url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-windows.zip" info "Fetching cabal binary distribution from $url..." curl "$url" > "$TMP/cabal.zip" unzip "$TMP/cabal.zip" ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -24,7 +24,7 @@ let }; ghc = pkgs.stdenv.mkDerivation rec { - version = "9.2.2"; + version = "9.4.3"; name = "ghc"; src = ghcBindists.${pkgs.stdenv.hostPlatform.system}; configureFlags = [ ===================================== .gitlab/gen_ci.hs ===================================== @@ -342,7 +342,7 @@ opsysVariables _ FreeBSD13 = mconcat -- [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) "CONFIGURE_ARGS" =: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" , "HADRIAN_ARGS" =: "--docs=no-sphinx" - , "GHC_VERSION" =: "9.2.2" + , "GHC_VERSION" =: "9.4.3" , "CABAL_INSTALL_VERSION" =: "3.6.2.0" ] opsysVariables _ (Linux distro) = distroVariables distro @@ -371,8 +371,8 @@ opsysVariables _ (Windows {}) = mconcat [ "MSYSTEM" =: "MINGW64" , "HADRIAN_ARGS" =: "--docs=no-sphinx" , "LANG" =: "en_US.UTF-8" - , "CABAL_INSTALL_VERSION" =: "3.2.0.0" - , "GHC_VERSION" =: "9.2.2" ] + , "CABAL_INSTALL_VERSION" =: "3.8.1.0" + , "GHC_VERSION" =: "9.4.3" ] opsysVariables _ _ = mempty ===================================== .gitlab/jobs.yaml ===================================== @@ -479,7 +479,7 @@ "BUILD_FLAVOUR": "validate", "CABAL_INSTALL_VERSION": "3.6.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib ", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "TEST_ENV": "x86_64-freebsd13-validate", "XZ_OPT": "-9" @@ -1676,9 +1676,9 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", @@ -1735,9 +1735,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", @@ -2050,7 +2050,7 @@ "BUILD_FLAVOUR": "release", "CABAL_INSTALL_VERSION": "3.6.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib ", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", "TEST_ENV": "x86_64-freebsd13-release", @@ -2780,9 +2780,9 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", @@ -2840,9 +2840,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", @@ -2970,7 +2970,7 @@ "BUILD_FLAVOUR": "validate", "CABAL_INSTALL_VERSION": "3.6.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib ", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "TEST_ENV": "x86_64-freebsd13-validate" } @@ -4149,9 +4149,9 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", @@ -4207,9 +4207,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33d0fa9fc2f5ec28d68c62a9cc1359cf6251fbdf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33d0fa9fc2f5ec28d68c62a9cc1359cf6251fbdf You're receiving 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 Dec 12 18:08:13 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Mon, 12 Dec 2022 13:08:13 -0500 Subject: [Git][ghc/ghc][wip/mp-9.4-backports] 14 commits: Add a missing varToCoreExpr in etaBodyForJoinPoint Message-ID: <63976e0d4bca2_389fe252724889d8@gitlab.mail> Matthew Pickering pushed to branch wip/mp-9.4-backports at Glasgow Haskell Compiler / GHC Commits: 5d0c7315 by Simon Peyton Jones at 2022-12-12T18:08:00+00:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! (cherry picked from commit afc2540daf6ca6baa09ab147b792da08d66d878c) - - - - - 8ef75eb2 by sheaf at 2022-12-12T18:08:00+00:00 Fix @since annotations on WithDict and Coercible Fixes #22453 (cherry picked from commit 68c966cd3c9d581bac4573807e433fe8d063445f) - - - - - 2a4dec43 by Ben Gamari at 2022-12-12T18:08:00+00:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. (cherry picked from commit 268a3ce952f6be00a1dd164dc4d7acb346045e90) - - - - - 108c8fb6 by Matthew Pickering at 2022-12-12T18:08:00+00:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 (cherry picked from commit 6dab0046b575e102bf3245fd63d5ac6bc6f4204d) - - - - - 2fea3370 by Ben Gamari at 2022-12-12T18:08:00+00:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. (cherry picked from commit a4dbd102af1989526ca87f4dd949f72231284e68) - - - - - 9ff0c95e by Ben Gamari at 2022-12-12T18:08:00+00:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. (cherry picked from commit 30f0d9a9ded55a822e094847d5ac8087262fb8da) - - - - - 2d3d5993 by Andreas Klebinger at 2022-12-12T18:08:00+00:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. (cherry picked from commit 31462d98c31e3ef48af2f6c6f2d379d74ccc63f5) - - - - - 1be63947 by Dai at 2022-12-12T18:08:00+00:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 (cherry picked from commit 5b3a992f5d166007c3c5a22f120ed08e0a27f01a) - - - - - 9cd8671b by sheaf at 2022-12-12T18:08:00+00:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 (cherry picked from commit 6d7d91817795d7ee7f45557411368a1738daa488) - - - - - edbb9a1e by sheaf at 2022-12-12T18:08:00+00:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. (cherry picked from commit 3be48877e204fca8e5d5ab984186e0d20d81f262) - - - - - 7d31204c by sheaf at 2022-12-12T18:08:00+00:00 Disable some SIMD tests on non-X86 architectures (cherry picked from commit f7b7a3122185222d5059e37315991afcf319e43c) - - - - - 33cde78d by Andreas Klebinger at 2022-12-12T18:08:00+00:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. (cherry picked from commit 8d2dbe2db4cc7c8b6d39b1ea64b0508304a3273c) - - - - - b733d6c4 by Simon Peyton Jones at 2022-12-12T18:08:00+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 (cherry picked from commit 294f907370fadd3313f8c5e6aa87a93c8b86f139) - - - - - 62366a6a by Gabriella Gonzalez at 2022-12-12T18:08:00+00:00 Serialize builds of `rts` and `system-cxx-std-lib` Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/22099 I cannot say for sure that this will fix the linked issue, but I explained why I believe this fixes the root problem in: https://gitlab.haskell.org/ghc/ghc/-/issues/22099#note_461386 … and when we applied this patch internally the problem appeared to disappear for a few builds in a row with a large number of cores. The short summary of the above comment is that the `Makefile` serializes the package registrations using `ghc-pkgs`, with the exception of two packages (`rts` and `system-cxx-std-lib`) and we expect that this one instance of parallelism that was still left in the `Makefile` was the root cause of the flaky build failure. This fix would be consistent with two known things about the failure: - The build failure only occurs for parallel `Make` builds … and these are the only two `ghc-pkg` calls that run concurrently - The error first appeared in the GHC 9.4 branch and was absent in GHC 9.2 … and GHC 9.4 was the first release that included `system-cxx-std-lib` (as far as I know), which would explain why this problem didn't happen before. The change here forces the two packages to be registered in sequence. This problem will of course go away in GHC 9.6 by virtue of dropping the `make`-based build, but since the GHC 9.4 branch is supported and active we wanted to upstream this patch to the 9.4 development branch. - - - - - 30 changed files: - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Linker/Windows.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Process.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Utils/Outputable.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - ghc.mk - libraries/base/Data/Coerce.hs - libraries/base/GHC/Exts.hs - libraries/ghc-prim/GHC/Magic/Dict.hs - libraries/ghc-prim/GHC/Types.hs - rts/eventlog/EventLog.c - rts/include/rts/IPE.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bbb60c9c85e29586d2176fcb7368aa0e72a1556b...62366a6a1b751c820359d988eec1b2c2197e891f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bbb60c9c85e29586d2176fcb7368aa0e72a1556b...62366a6a1b751c820359d988eec1b2c2197e891f You're receiving 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 Dec 12 19:37:09 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 12 Dec 2022 14:37:09 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.6] 17 commits: Hadrian: fix ghcDebugAssertions off-by-one error Message-ID: <639782e516e82_389fe25271093812@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - f8f35dca by Ben Gamari at 2022-12-12T11:44:53-05:00 base: Bump version to 4.18 - - - - - 68ecd324 by Ben Gamari at 2022-12-12T11:44:53-05:00 configure: Bump GHC version to 9.6 - - - - - dd7d7b3d by Ben Gamari at 2022-12-12T11:44:53-05:00 ghc-boot: Fix bootstrapping - - - - - 9c7b2525 by Ben Gamari at 2022-12-12T11:44:54-05:00 rts/ipe: Fix unused lock warning - - - - - 3461eb5d by Ben Gamari at 2022-12-12T11:44:54-05:00 configure: Bump minimum bootstrap compiler version - - - - - 30 changed files: - compiler/GHC/Data/Graph/Directed.hs - + compiler/GHC/Driver/Config/Linker.hs - compiler/GHC/Driver/Session.hs - + compiler/GHC/Linker/Config.hs - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/MacOS.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/SysTools/Tasks.hs - compiler/ghc.cabal.in - configure.ac - hadrian/doc/user-settings.md - hadrian/src/Flavour/Type.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Flavours/Development.hs - hadrian/src/Settings/Packages.hs - libraries/array - libraries/base/Data/Array/Byte.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/Type/Reflection/Unsafe.hs - 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/Utils/Encoding/UTF8.hs - 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/a519b0001bd2f143f56ed5d043790bd4ce92cc12...3461eb5df39e16f59d1bde5fd857f8bffd7fb622 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a519b0001bd2f143f56ed5d043790bd4ce92cc12...3461eb5df39e16f59d1bde5fd857f8bffd7fb622 You're receiving 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 Dec 12 19:40:48 2022 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Mon, 12 Dec 2022 14:40:48 -0500 Subject: [Git][ghc/ghc][wip/az/epa-split-header-comments] 3 commits: Add heqT, a kind-heterogeneous variant of heq Message-ID: <639783c082134_389fe2526fc959b2@gitlab.mail> Alan Zimmerman pushed to branch wip/az/epa-split-header-comments at Glasgow Haskell Compiler / GHC Commits: b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 25724dca by Alan Zimmerman at 2022-12-12T19:40:08+00:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 8 changed files: - compiler/GHC/Parser/Lexer.x - libraries/base/Data/Bifunctor.hs - libraries/base/Data/Typeable.hs - libraries/base/changelog.md - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/parser/should_compile/DumpParsedAstComments.hs - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr - testsuite/tests/printer/Ppr031.hs Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3676,6 +3676,25 @@ allocateComments ss comment_q = in (comment_q', reverse newAnns) +-- Comments appearing without a line-break before the first +-- declaration are associated with the declaration +splitPriorComments + :: RealSrcSpan + -> [LEpaComment] + -> ([LEpaComment], [LEpaComment]) +splitPriorComments ss prior_comments = + let + -- True if there is only one line between the earlier and later span + cmp later earlier + = srcSpanStartLine later - srcSpanEndLine earlier == 1 + + go decl _ [] = ([],decl) + go decl r (c@(L l _):cs) = if cmp r (anchor l) + then go (c:decl) (anchor l) cs + else (reverse (c:cs), decl) + in + go [] ss prior_comments + allocatePriorComments :: RealSrcSpan -> [LEpaComment] @@ -3684,12 +3703,13 @@ allocatePriorComments allocatePriorComments ss comment_q mheader_comments = let cmp (L l _) = anchor l <= ss - (before,after) = partition cmp comment_q - newAnns = before + (newAnns,after) = partition cmp comment_q comment_q'= after + (prior_comments, decl_comments) = splitPriorComments ss newAnns in case mheader_comments of - Strict.Nothing -> (Strict.Just (reverse newAnns), comment_q', []) + Strict.Nothing -> (Strict.Just prior_comments, comment_q', decl_comments) + -- Strict.Nothing -> (Strict.Just [], comment_q', newAnns) Strict.Just _ -> (mheader_comments, comment_q', reverse newAnns) allocateFinalComments ===================================== libraries/base/Data/Bifunctor.hs ===================================== @@ -120,8 +120,17 @@ class (forall a. Functor (p a)) => Bifunctor p where second = bimap id - --- | @since 4.8.0.0 +-- | Class laws for tuples hold only up to laziness. Both +-- 'first' 'id' and 'second' 'id' are lazier than 'id' (and 'fmap' 'id'): +-- +-- >>> first id (undefined :: (Int, Word)) `seq` () +-- () +-- >>> second id (undefined :: (Int, Word)) `seq` () +-- () +-- >>> id (undefined :: (Int, Word)) `seq` () +-- *** Exception: Prelude.undefined +-- +-- @since 4.8.0.0 instance Bifunctor (,) where bimap f g ~(a, b) = (f a, g b) ===================================== libraries/base/Data/Typeable.hs ===================================== @@ -4,6 +4,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy #-} +{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} ----------------------------------------------------------------------------- @@ -56,6 +57,7 @@ module Data.Typeable -- * Type-safe cast , cast , eqT + , heqT , gcast -- a generalisation of cast -- * Generalized casts for higher-order kinds @@ -135,8 +137,14 @@ cast x -- @since 4.7.0.0 eqT :: forall a b. (Typeable a, Typeable b) => Maybe (a :~: b) eqT - | Just HRefl <- ta `I.eqTypeRep` tb = Just Refl - | otherwise = Nothing + | Just HRefl <- heqT @a @b = Just Refl + | otherwise = Nothing + +-- | Extract a witness of heterogeneous equality of two types +-- +-- @since 4.18.0.0 +heqT :: forall a b. (Typeable a, Typeable b) => Maybe (a :~~: b) +heqT = ta `I.eqTypeRep` tb where ta = I.typeRep :: I.TypeRep a tb = I.typeRep :: I.TypeRep b ===================================== libraries/base/changelog.md ===================================== @@ -57,6 +57,7 @@ of individually allocated pointers as well as freeing each one of them when freeing a `Pool`. (#14762) (#18338) * `Type.Reflection.Unsafe` is now marked as unsafe. + * Add `Data.Typeable.heqT`, a kind-heterogeneous version of `Data.Typeable.eqT`. ## 4.17.0.0 *August 2022* ===================================== testsuite/tests/ghc-api/exactprint/Test20239.stderr ===================================== @@ -19,14 +19,7 @@ [] [])) (EpaCommentsBalanced - [(L - (Anchor - { Test20239.hs:3:1-28 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- | Leading Haddock Comment") - { Test20239.hs:1:18-22 }))] + [] [(L (Anchor { Test20239.hs:8:1 } @@ -53,6 +46,14 @@ []) (EpaComments [(L + (Anchor + { Test20239.hs:3:1-28 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- | Leading Haddock Comment") + { Test20239.hs:1:18-22 })) + ,(L (Anchor { Test20239.hs:7:34-63 } (UnchangedAnchor)) ===================================== testsuite/tests/parser/should_compile/DumpParsedAstComments.hs ===================================== @@ -4,6 +4,10 @@ -} module DumpParsedAstComments where +-- Other comment + +-- comment 1 for foo +-- comment 2 for foo foo = do -- normal comment 1 ===================================== testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr ===================================== @@ -34,15 +34,23 @@ (UnchangedAnchor)) (EpaComment (EpaBlockComment - "{-\n Block comment at the beginning\n -}") - { DumpParsedAstComments.hs:1:1-28 }))] + "{-/n Block comment at the beginning/n -}") + { DumpParsedAstComments.hs:1:1-28 })) + ,(L + (Anchor + { DumpParsedAstComments.hs:7:1-16 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- Other comment") + { DumpParsedAstComments.hs:5:30-34 }))] [(L (Anchor - { DumpParsedAstComments.hs:13:1 } + { DumpParsedAstComments.hs:17:1 } (UnchangedAnchor)) (EpaComment (EpaEofComment) - { DumpParsedAstComments.hs:13:1 }))])) + { DumpParsedAstComments.hs:17:1 }))])) (VirtualBraces (1)) (Nothing) @@ -56,47 +64,63 @@ [(L (SrcSpanAnn (EpAnn (Anchor - { DumpParsedAstComments.hs:(7,1)-(9,3) } + { DumpParsedAstComments.hs:(11,1)-(13,3) } (UnchangedAnchor)) (AnnListItem []) (EpaComments [(L (Anchor - { DumpParsedAstComments.hs:11:1-20 } + { DumpParsedAstComments.hs:9:1-20 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- comment 1 for foo") + { DumpParsedAstComments.hs:7:1-16 })) + ,(L + (Anchor + { DumpParsedAstComments.hs:10:1-20 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- comment 2 for foo") + { DumpParsedAstComments.hs:9:1-20 })) + ,(L + (Anchor + { DumpParsedAstComments.hs:15:1-20 } (UnchangedAnchor)) (EpaComment (EpaLineComment "-- | Haddock comment") - { DumpParsedAstComments.hs:9:3 - }))])) { DumpParsedAstComments.hs:(7,1)-(9,3) }) + { DumpParsedAstComments.hs:13:3 + }))])) { DumpParsedAstComments.hs:(11,1)-(13,3) }) (ValD (NoExtField) (FunBind (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:7:1-3 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:11:1-3 }) (Unqual {OccName: foo})) (MG (FromSource) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(7,1)-(9,3) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(11,1)-(13,3) }) [(L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(7,1)-(9,3) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(11,1)-(13,3) }) (Match (EpAnn (Anchor - { DumpParsedAstComments.hs:(7,1)-(9,3) } + { DumpParsedAstComments.hs:(11,1)-(13,3) } (UnchangedAnchor)) [] (EpaComments [])) (FunRhs (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:7:1-3 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:11:1-3 }) (Unqual {OccName: foo})) (Prefix) @@ -108,72 +132,72 @@ [(L (SrcSpanAnn (EpAnnNotUsed) - { DumpParsedAstComments.hs:(7,5)-(9,3) }) + { DumpParsedAstComments.hs:(11,5)-(13,3) }) (GRHS (EpAnn (Anchor - { DumpParsedAstComments.hs:(7,5)-(9,3) } + { DumpParsedAstComments.hs:(11,5)-(13,3) } (UnchangedAnchor)) (GrhsAnn (Nothing) - (AddEpAnn AnnEqual (EpaSpan { DumpParsedAstComments.hs:7:5 }))) + (AddEpAnn AnnEqual (EpaSpan { DumpParsedAstComments.hs:11:5 }))) (EpaComments [])) [] (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(7,7)-(9,3) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(11,7)-(13,3) }) (HsDo (EpAnn (Anchor - { DumpParsedAstComments.hs:(7,7)-(9,3) } + { DumpParsedAstComments.hs:(11,7)-(13,3) } (UnchangedAnchor)) (AnnList (Just (Anchor - { DumpParsedAstComments.hs:9:3 } + { DumpParsedAstComments.hs:13:3 } (UnchangedAnchor))) (Nothing) (Nothing) - [(AddEpAnn AnnDo (EpaSpan { DumpParsedAstComments.hs:7:7-8 }))] + [(AddEpAnn AnnDo (EpaSpan { DumpParsedAstComments.hs:11:7-8 }))] []) (EpaComments [(L (Anchor - { DumpParsedAstComments.hs:8:3-19 } + { DumpParsedAstComments.hs:12:3-19 } (UnchangedAnchor)) (EpaComment (EpaLineComment "-- normal comment") - { DumpParsedAstComments.hs:7:7-8 }))])) + { DumpParsedAstComments.hs:11:7-8 }))])) (DoExpr (Nothing)) (L (SrcSpanAnn (EpAnn (Anchor - { DumpParsedAstComments.hs:9:3 } + { DumpParsedAstComments.hs:13:3 } (UnchangedAnchor)) (AnnList (Just (Anchor - { DumpParsedAstComments.hs:9:3 } + { DumpParsedAstComments.hs:13:3 } (UnchangedAnchor))) (Nothing) (Nothing) [] []) (EpaComments - [])) { DumpParsedAstComments.hs:9:3 }) + [])) { DumpParsedAstComments.hs:13:3 }) [(L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:9:3 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:13:3 }) (BodyStmt (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:9:3 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:13:3 }) (HsOverLit (EpAnn (Anchor - { DumpParsedAstComments.hs:9:3 } + { DumpParsedAstComments.hs:13:3 } (UnchangedAnchor)) (NoEpAnns) (EpaComments @@ -192,37 +216,37 @@ ,(L (SrcSpanAnn (EpAnn (Anchor - { DumpParsedAstComments.hs:12:1-23 } + { DumpParsedAstComments.hs:16:1-23 } (UnchangedAnchor)) (AnnListItem []) (EpaComments - [])) { DumpParsedAstComments.hs:12:1-23 }) + [])) { DumpParsedAstComments.hs:16:1-23 }) (ValD (NoExtField) (FunBind (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:1-4 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:1-4 }) (Unqual {OccName: main})) (MG (FromSource) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:1-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:1-23 }) [(L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:1-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:1-23 }) (Match (EpAnn (Anchor - { DumpParsedAstComments.hs:12:1-23 } + { DumpParsedAstComments.hs:16:1-23 } (UnchangedAnchor)) [] (EpaComments [])) (FunRhs (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:1-4 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:1-4 }) (Unqual {OccName: main})) (Prefix) @@ -234,42 +258,42 @@ [(L (SrcSpanAnn (EpAnnNotUsed) - { DumpParsedAstComments.hs:12:6-23 }) + { DumpParsedAstComments.hs:16:6-23 }) (GRHS (EpAnn (Anchor - { DumpParsedAstComments.hs:12:6-23 } + { DumpParsedAstComments.hs:16:6-23 } (UnchangedAnchor)) (GrhsAnn (Nothing) - (AddEpAnn AnnEqual (EpaSpan { DumpParsedAstComments.hs:12:6 }))) + (AddEpAnn AnnEqual (EpaSpan { DumpParsedAstComments.hs:16:6 }))) (EpaComments [])) [] (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:8-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:8-23 }) (HsApp (EpAnn (Anchor - { DumpParsedAstComments.hs:12:8-23 } + { DumpParsedAstComments.hs:16:8-23 } (UnchangedAnchor)) (NoEpAnns) (EpaComments [])) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:8-15 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:8-15 }) (HsVar (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:8-15 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:8-15 }) (Unqual {OccName: putStrLn})))) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:17-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:17-23 }) (HsLit (EpAnn (Anchor - { DumpParsedAstComments.hs:12:17-23 } + { DumpParsedAstComments.hs:16:17-23 } (UnchangedAnchor)) (NoEpAnns) (EpaComments ===================================== testsuite/tests/printer/Ppr031.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE ImplicitParams, NamedFieldPuns, ParallelListComp, PatternGuards #-} + spec :: Spec spec = do describe "split4'8" $ do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1775cef810d20917eda7eeca1e7c5f50eca2c95e...25724dcaa5c3d38e72912c83f0d86a4b07f39b4d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1775cef810d20917eda7eeca1e7c5f50eca2c95e...25724dcaa5c3d38e72912c83f0d86a4b07f39b4d You're receiving 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 Dec 12 21:22:52 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Dec 2022 16:22:52 -0500 Subject: [Git][ghc/ghc][master] Mark T21336a fragile Message-ID: <63979bac332d5_389fe2526981213ed@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - 1 changed file: - libraries/base/tests/IO/T21336/all.T Changes: ===================================== libraries/base/tests/IO/T21336/all.T ===================================== @@ -1,6 +1,9 @@ # N.B. /dev/full exists on Darwin but cannot be opened, failing with -EPERM test('T21336a', - [unless(opsys('linux') or opsys('freebsd'), skip), js_broken(22261)], + [ unless(opsys('linux') or opsys('freebsd'), skip) + , js_broken(22261) + , fragile(22022) + ], compile_and_run, ['']) test('T21336b', [unless(opsys('linux') or opsys('freebsd'), skip), js_broken(22352)], View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5d1a18812f7f91a947e5d14c0ebf1ae2a0627c55 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5d1a18812f7f91a947e5d14c0ebf1ae2a0627c55 You're receiving 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 Dec 12 21:23:35 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 12 Dec 2022 16:23:35 -0500 Subject: [Git][ghc/ghc][master] Add test for #21476 Message-ID: <63979bd7ab836_389fe22d051f4126798@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - 2 changed files: - + testsuite/tests/simplCore/should_compile/T21476.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== testsuite/tests/simplCore/should_compile/T21476.hs ===================================== @@ -0,0 +1,4 @@ +{-# LANGUAGE MagicHash #-} +module T21476 where +import GHC.Exts +f = keepAlive# ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -456,3 +456,4 @@ test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m - test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T22491', normal, compile, ['-O2']) +test('T21476', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c30accc2f8a0585c76cb534beda04fba624bce1c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c30accc2f8a0585c76cb534beda04fba624bce1c You're receiving 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 Dec 13 00:08:25 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 12 Dec 2022 19:08:25 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22538 Message-ID: <6397c27948388_389fe252710141477@gitlab.mail> Ben Gamari pushed new branch wip/T22538 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22538 You're receiving 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 Dec 13 00:21:00 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 12 Dec 2022 19:21:00 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22527 Message-ID: <6397c56c97a34_389fe252684148510@gitlab.mail> Ben Gamari pushed new branch wip/T22527 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22527 You're receiving 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 Dec 13 01:11:04 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Mon, 12 Dec 2022 20:11:04 -0500 Subject: [Git][ghc/ghc][wip/T22570] checkValidInst: Don't expand synonyms when splitting sigma types Message-ID: <6397d128cb0fe_389fe22d051f4152992@gitlab.mail> Ryan Scott pushed to branch wip/T22570 at Glasgow Haskell Compiler / GHC Commits: ae1beb1b by Ryan Scott at 2022-12-12T20:09:58-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 4 changed files: - compiler/GHC/Tc/Validity.hs - + testsuite/tests/typecheck/should_fail/T22570.hs - + testsuite/tests/typecheck/should_fail/T22570.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -61,7 +61,7 @@ import GHC.Types.Basic ( UnboxedTupleOrSum(..), unboxedTupleOrSumExtension ) import GHC.Types.Name import GHC.Types.Var.Env import GHC.Types.Var.Set -import GHC.Types.Var ( VarBndr(..), mkTyVar ) +import GHC.Types.Var ( VarBndr(..), isInvisibleFunArg, mkTyVar ) import GHC.Utils.FV import GHC.Utils.Error import GHC.Driver.Session @@ -1731,6 +1731,13 @@ the instance head, we'll expand the synonym on fly, and it'll look like instance (%,%) (Show Int, Show Int) and we /really/ don't want that. So we carefully do /not/ expand synonyms, by matching on TyConApp directly. + +For similar reasons, we do not use tcSplitSigmaTy when decomposing the instance +context, as the looks through type synonyms. If we looked through type +synonyms, then it could be possible to write an instance for a type synonym +involving a quantified constraint (see #22570). Instead, we define +splitInstTyForValidity, a specialized version of tcSplitSigmaTy (local to +GHC.Tc.Validity) that does not expand type synonyms. -} checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM () @@ -1774,11 +1781,43 @@ checkValidInstance ctxt hs_type ty = case tau of ; return () } _ -> failWithTc (TcRnNoClassInstHead tau) where - (_tvs, theta, tau) = tcSplitSigmaTy ty + (theta, tau) = splitInstTyForValidity ty -- The location of the "head" of the instance head_loc = getLoc (getLHsInstDeclHead hs_type) +-- | Split an instance type of the form @forall tvbs. inst_ctxt => inst_head@ +-- and return @(inst_ctxt, inst_head)@. This function makes no attempt to look +-- through type synonyms. See @Note [Instances and constraint synonyms]@. +splitInstTyForValidity :: Type -> (ThetaType, Type) +splitInstTyForValidity = split_context . drop_foralls + where + -- This is like 'dropForAlls', except that it does not look through type + -- synonyms. + drop_foralls :: Type -> Type + drop_foralls (ForAllTy (Bndr _tv argf) ty) + | isInvisibleForAllTyFlag argf = drop_foralls ty + drop_foralls ty = ty + + -- This is like 'tcSplitPhiTy', except that it does not look through type + -- synonyms. + split_context :: Type -> (ThetaType, Type) + split_context = split [] + where + split preds ty = + case split_pred_ty_maybe ty of + Just (pred, tau) -> split (pred:preds) tau + Nothing -> (reverse preds, ty) + + -- This is like 'tcSplitPredFunTy_maybe', except that it does not look + -- through type synonyms. + split_pred_ty_maybe :: Type -> Maybe (PredType, Type) + split_pred_ty_maybe (FunTy { ft_af = af, ft_arg = arg, ft_res = res }) + | isInvisibleFunArg af + = Just (arg, res) + split_pred_ty_maybe _ + = Nothing + {- Note [Paterson conditions] ~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== testsuite/tests/typecheck/should_fail/T22570.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module T22570 where + +import Data.Kind + +class SomeClass a +class OtherClass + +type SomeClassUnit = OtherClass => SomeClass () :: Constraint + +instance SomeClassUnit + +type SomeClassSyn a = OtherClass => SomeClass a :: Constraint + +instance SomeClassSyn () ===================================== testsuite/tests/typecheck/should_fail/T22570.stderr ===================================== @@ -0,0 +1,10 @@ + +T22570.hs:11:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassUnit’ + +T22570.hs:15:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassSyn ()’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -665,3 +665,4 @@ test('MissingDefaultMethodBinding', normal, compile_fail, ['']) test('T21447', normal, compile_fail, ['']) test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) +test('T22570', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae1beb1b1a4d006f4f8ab9fd8a972b1fac61ceb2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ae1beb1b1a4d006f4f8ab9fd8a972b1fac61ceb2 You're receiving 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 Dec 13 08:57:57 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 13 Dec 2022 03:57:57 -0500 Subject: [Git][ghc/ghc][wip/T22272] 3 commits: Mark T21336a fragile Message-ID: <63983e95cab9_389fe25273819937f@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22272 at Glasgow Haskell Compiler / GHC Commits: 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - dfe222cc by Gergő Érdi at 2022-12-13T08:57:41+00:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 25 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - libraries/base/tests/IO/T21336/all.T - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/simplCore/should_compile/T21476.hs - + testsuite/tests/simplCore/should_compile/T22272.hs - + testsuite/tests/simplCore/should_compile/T22272.stderr - + testsuite/tests/simplCore/should_compile/T22272_A.hs - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -52,7 +52,7 @@ module GHC.Core ( isRuntimeArg, isRuntimeVar, -- * Unfolding data types - Unfolding(..), UnfoldingGuidance(..), UnfoldingSource(..), + Unfolding(..), UnfoldingCache(..), UnfoldingGuidance(..), UnfoldingSource(..), -- ** Constructing 'Unfolding's noUnfolding, bootUnfolding, evaldUnfolding, mkOtherCon, @@ -1277,15 +1277,8 @@ data Unfolding uf_tmpl :: CoreExpr, -- Template; occurrence info is correct uf_src :: UnfoldingSource, -- Where the unfolding came from uf_is_top :: Bool, -- True <=> top level binding - uf_is_value :: Bool, -- exprIsHNF template (cached); it is ok to discard - -- a `seq` on this variable - uf_is_conlike :: Bool, -- True <=> applicn of constructor or CONLIKE function - -- Cached version of exprIsConLike - uf_is_work_free :: Bool, -- True <=> doesn't waste (much) work to expand - -- inside an inlining - -- Cached version of exprIsCheap - uf_expandable :: Bool, -- True <=> can expand in RULE matching - -- Cached version of exprIsExpandable + uf_cache :: UnfoldingCache, -- Cache of flags computable from the expr + -- See Note [Tying the 'CoreUnfolding' knot] uf_guidance :: UnfoldingGuidance -- Tells about the *size* of the template. } -- ^ An unfolding with redundant cached information. Parameters: @@ -1305,7 +1298,22 @@ data Unfolding -- uf_guidance: Tells us about the /size/ of the unfolding template ------------------------------------------------- +-- | Properties of a 'CoreUnfolding' that could be computed on-demand from its template. +-- See Note [UnfoldingCache] +data UnfoldingCache + = UnfoldingCache { + uf_is_value :: !Bool, -- exprIsHNF template (cached); it is ok to discard + -- a `seq` on this variable + uf_is_conlike :: !Bool, -- True <=> applicn of constructor or CONLIKE function + -- Cached version of exprIsConLike + uf_is_work_free :: !Bool, -- True <=> doesn't waste (much) work to expand + -- inside an inlining + -- Cached version of exprIsCheap + uf_expandable :: !Bool -- True <=> can expand in RULE matching + -- Cached version of exprIsExpandable + } + deriving (Eq) + -- | 'UnfoldingGuidance' says when unfolding should take place data UnfoldingGuidance = UnfWhen { -- Inline without thinking about the *size* of the uf_tmpl @@ -1335,7 +1343,23 @@ data UnfoldingGuidance | UnfNever -- The RHS is big, so don't inline it deriving (Eq) -{- +{- Note [UnfoldingCache] +~~~~~~~~~~~~~~~~~~~~~~~~ +The UnfoldingCache field of an Unfolding holds four (strict) booleans, +all derived from the uf_tmpl field of the unfolding. + +* We serialise the UnfoldingCache to and from interface files, for + reasons described in Note [Tying the 'CoreUnfolding' knot] in + GHC.IfaceToCore + +* Because it is a strict data type, we must be careful not to + pattern-match on it until we actually want its values. E.g + GHC.Core.Unfold.callSiteInline/tryUnfolding are careful not to force + it unnecessarily. Just saves a bit of work. + +* When `seq`ing Core to eliminate space leaks, to suffices to `seq` on + the cache, but not its fields, because it is strict in all fields. + Note [Historical note: unfoldings for wrappers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to have a nice clever scheme in interface files for @@ -1436,42 +1460,44 @@ otherCons _ = [] -- yield a value (something in HNF): returns @False@ if unsure isValueUnfolding :: Unfolding -> Bool -- Returns False for OtherCon -isValueUnfolding (CoreUnfolding { uf_is_value = is_evald }) = is_evald -isValueUnfolding (DFunUnfolding {}) = True -isValueUnfolding _ = False +isValueUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_value cache +isValueUnfolding (DFunUnfolding {}) = True +isValueUnfolding _ = False -- | Determines if it possibly the case that the unfolding will -- yield a value. Unlike 'isValueUnfolding' it returns @True@ -- for 'OtherCon' isEvaldUnfolding :: Unfolding -> Bool -- Returns True for OtherCon -isEvaldUnfolding (OtherCon _) = True -isEvaldUnfolding (DFunUnfolding {}) = True -isEvaldUnfolding (CoreUnfolding { uf_is_value = is_evald }) = is_evald -isEvaldUnfolding _ = False +isEvaldUnfolding (OtherCon _) = True +isEvaldUnfolding (DFunUnfolding {}) = True +isEvaldUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_value cache +isEvaldUnfolding _ = False -- | @True@ if the unfolding is a constructor application, the application -- of a CONLIKE function or 'OtherCon' isConLikeUnfolding :: Unfolding -> Bool -isConLikeUnfolding (OtherCon _) = True -isConLikeUnfolding (CoreUnfolding { uf_is_conlike = con }) = con -isConLikeUnfolding _ = False +isConLikeUnfolding (OtherCon _) = True +isConLikeUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_conlike cache +isConLikeUnfolding _ = False -- | Is the thing we will unfold into certainly cheap? isCheapUnfolding :: Unfolding -> Bool -isCheapUnfolding (CoreUnfolding { uf_is_work_free = is_wf }) = is_wf -isCheapUnfolding _ = False +isCheapUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_work_free cache +isCheapUnfolding _ = False isExpandableUnfolding :: Unfolding -> Bool -isExpandableUnfolding (CoreUnfolding { uf_expandable = is_expable }) = is_expable -isExpandableUnfolding _ = False +isExpandableUnfolding (CoreUnfolding { uf_cache = cache }) = uf_expandable cache +isExpandableUnfolding _ = False expandUnfolding_maybe :: Unfolding -> Maybe CoreExpr -- Expand an expandable unfolding; this is used in rule matching -- See Note [Expanding variables] in GHC.Core.Rules -- The key point here is that CONLIKE things can be expanded -expandUnfolding_maybe (CoreUnfolding { uf_expandable = True, uf_tmpl = rhs }) = Just rhs -expandUnfolding_maybe _ = Nothing +expandUnfolding_maybe (CoreUnfolding { uf_cache = cache, uf_tmpl = rhs }) + | uf_expandable cache + = Just rhs +expandUnfolding_maybe _ = Nothing isCompulsoryUnfolding :: Unfolding -> Bool isCompulsoryUnfolding (CoreUnfolding { uf_src = src }) = isCompulsorySource src ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -4210,7 +4210,7 @@ simplLetUnfolding env bind_cxt id new_rhs rhs_ty arity unf mkLetUnfolding :: UnfoldingOpts -> TopLevelFlag -> UnfoldingSource -> InId -> OutExpr -> SimplM Unfolding mkLetUnfolding !uf_opts top_lvl src id new_rhs - = return (mkUnfolding uf_opts src is_top_lvl is_bottoming new_rhs) + = return (mkUnfolding uf_opts src is_top_lvl is_bottoming new_rhs Nothing) -- We make an unfolding *even for loop-breakers*. -- Reason: (a) It might be useful to know that they are WHNF -- (b) In GHC.Iface.Tidy we currently assume that, if we want to @@ -4270,7 +4270,7 @@ simplStableUnfolding env bind_cxt id rhs_ty id_arity unf -- A test case is #4138 -- But retain a previous boring_ok of True; e.g. see -- the way it is set in calcUnfoldingGuidanceWithArity - in return (mkCoreUnfolding src is_top_lvl expr' guide') + in return (mkCoreUnfolding src is_top_lvl expr' Nothing guide') -- See Note [Top-level flag on inline rules] in GHC.Core.Unfold _other -- Happens for INLINABLE things ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -2169,7 +2169,7 @@ abstractFloats uf_opts top_lvl main_tvs floats body = (poly_id `setIdUnfolding` unf, poly_rhs) where poly_rhs = mkLams tvs_here rhs - unf = mkUnfolding uf_opts VanillaSrc is_top_lvl False poly_rhs + unf = mkUnfolding uf_opts VanillaSrc is_top_lvl False poly_rhs Nothing -- We want the unfolding. Consider -- let ===================================== compiler/GHC/Core/Ppr.hs ===================================== @@ -627,18 +627,14 @@ instance Outputable Unfolding where <+> sep (map (pprBndr LambdaBind) bndrs) <+> arrow) 2 (ppr con <+> sep (map ppr args)) ppr (CoreUnfolding { uf_src = src - , uf_tmpl=rhs, uf_is_top=top, uf_is_value=hnf - , uf_is_conlike=conlike, uf_is_work_free=wf - , uf_expandable=exp, uf_guidance=g }) + , uf_tmpl=rhs, uf_is_top=top + , uf_cache=cache, uf_guidance=g }) = text "Unf" <> braces (pp_info $$ pp_rhs) where pp_info = fsep $ punctuate comma [ text "Src=" <> ppr src , text "TopLvl=" <> ppr top - , text "Value=" <> ppr hnf - , text "ConLike=" <> ppr conlike - , text "WorkFree=" <> ppr wf - , text "Expandable=" <> ppr exp + , ppr cache , text "Guidance=" <> ppr g ] pp_tmpl = ppUnlessOption sdocSuppressUnfoldings (text "Tmpl=" <+> ppr rhs) @@ -647,6 +643,15 @@ instance Outputable Unfolding where -- Don't print the RHS or we get a quadratic -- blowup in the size of the printout! +instance Outputable UnfoldingCache where + ppr (UnfoldingCache { uf_is_value = hnf, uf_is_conlike = conlike + , uf_is_work_free = wf, uf_expandable = exp }) + = fsep $ punctuate comma + [ text "Value=" <> ppr hnf + , text "ConLike=" <> ppr conlike + , text "WorkFree=" <> ppr wf + , text "Expandable=" <> ppr exp ] + {- ----------------------------------------------------- -- Rules ===================================== compiler/GHC/Core/Seq.hs ===================================== @@ -104,10 +104,11 @@ seqAlts (Alt c bs e:alts) = c `seq` seqBndrs bs `seq` seqExpr e `seq` seqAlts al seqUnfolding :: Unfolding -> () seqUnfolding (CoreUnfolding { uf_tmpl = e, uf_is_top = top, - uf_is_value = b1, uf_is_work_free = b2, - uf_expandable = b3, uf_is_conlike = b4, - uf_guidance = g}) - = seqExpr e `seq` top `seq` b1 `seq` b2 `seq` b3 `seq` b4 `seq` seqGuidance g + uf_cache = cache, uf_guidance = g}) + = seqExpr e `seq` top `seq` cache `seq` seqGuidance g + -- The unf_cache :: UnfoldingCache field is a strict data type, + -- so it is sufficient to use plain `seq` for this field + -- See Note [UnfoldingCache] in GHC.Core seqUnfolding _ = () ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -759,7 +759,7 @@ add_info env old_bndr top_level new_rhs new_bndr unfolding_from_rhs = mkUnfolding uf_opts VanillaSrc (isTopLevel top_level) False -- may be bottom or not - new_rhs + new_rhs Nothing simpleUnfoldingFun :: IdUnfoldingFun simpleUnfoldingFun id ===================================== compiler/GHC/Core/Tidy.hs ===================================== @@ -375,15 +375,16 @@ tidyNestedUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = arg (tidy_env', bndrs') = tidyBndrs tidy_env bndrs tidyNestedUnfolding tidy_env - unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_is_value = is_value }) + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_cache = cache }) | isStableSource src = seqIt $ unf { uf_tmpl = tidyExpr tidy_env unf_rhs } -- Preserves OccInfo - -- This seqIt avoids a space leak: otherwise the uf_is_value, - -- uf_is_conlike, ... fields may retain a reference to the - -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) + -- This seqIt avoids a space leak: otherwise the uf_cache + -- field may retain a reference to the pre-tidied + -- expression forever (GHC.CoreToIface doesn't look at + -- them) -- Discard unstable unfoldings, but see Note [Preserve evaluatedness] - | is_value = evaldUnfolding + | uf_is_value cache = evaldUnfolding | otherwise = noUnfolding where ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -1036,11 +1036,11 @@ callSiteInline logger opts !case_depth id active_unfolding lone_variable arg_inf -- Things with an INLINE pragma may have an unfolding *and* -- be a loop breaker (maybe the knot is not yet untied) CoreUnfolding { uf_tmpl = unf_template - , uf_is_work_free = is_wf - , uf_guidance = guidance, uf_expandable = is_exp } + , uf_cache = unf_cache + , uf_guidance = guidance } | active_unfolding -> tryUnfolding logger opts case_depth id lone_variable arg_infos cont_info unf_template - is_wf is_exp guidance + unf_cache guidance | otherwise -> traceInline logger opts id "Inactive unfolding:" (ppr id) Nothing NoUnfolding -> Nothing BootUnfolding -> Nothing @@ -1162,11 +1162,10 @@ needed on a per-module basis. -} tryUnfolding :: Logger -> UnfoldingOpts -> Int -> Id -> Bool -> [ArgSummary] -> CallCtxt - -> CoreExpr -> Bool -> Bool -> UnfoldingGuidance + -> CoreExpr -> UnfoldingCache -> UnfoldingGuidance -> Maybe CoreExpr -tryUnfolding logger opts !case_depth id lone_variable - arg_infos cont_info unf_template - is_wf is_exp guidance +tryUnfolding logger opts !case_depth id lone_variable arg_infos + cont_info unf_template unf_cache guidance = case guidance of UnfNever -> traceInline logger opts id str (text "UnfNever") Nothing @@ -1178,7 +1177,7 @@ tryUnfolding logger opts !case_depth id lone_variable -> traceInline logger opts id str (mk_doc some_benefit empty False) Nothing where some_benefit = calc_some_benefit uf_arity - enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) + enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) UnfIfGoodArgs { ug_args = arg_discounts, ug_res = res_discount, ug_size = size } | unfoldingVeryAggressive opts @@ -1189,9 +1188,6 @@ tryUnfolding logger opts !case_depth id lone_variable -> traceInline logger opts id str (mk_doc some_benefit extra_doc False) Nothing where some_benefit = calc_some_benefit (length arg_discounts) - extra_doc = vcat [ text "case depth =" <+> int case_depth - , text "depth based penalty =" <+> int depth_penalty - , text "discounted size =" <+> int adjusted_size ] -- See Note [Avoid inlining into deeply nested cases] depth_treshold = unfoldingCaseThreshold opts depth_scaling = unfoldingCaseScaling opts @@ -1201,7 +1197,18 @@ tryUnfolding logger opts !case_depth id lone_variable small_enough = adjusted_size <= unfoldingUseThreshold opts discount = computeDiscount arg_discounts res_discount arg_infos cont_info + extra_doc = vcat [ text "case depth =" <+> int case_depth + , text "depth based penalty =" <+> int depth_penalty + , text "discounted size =" <+> int adjusted_size ] + where + -- Unpack the UnfoldingCache lazily because it may not be needed, and all + -- its fields are strict; so evaluating unf_cache at all forces all the + -- isWorkFree etc computations to take place. That risks wasting effort for + -- Ids that are never going to inline anyway. + -- See Note [UnfoldingCache] in GHC.Core + UnfoldingCache{ uf_is_work_free = is_wf, uf_expandable = is_exp } = unf_cache + mk_doc some_benefit extra_doc yes_or_no = vcat [ text "arg infos" <+> ppr arg_infos , text "interesting continuation" <+> ppr cont_info ===================================== compiler/GHC/Core/Unfold/Make.hs ===================================== @@ -6,6 +6,7 @@ module GHC.Core.Unfold.Make , mkUnfolding , mkCoreUnfolding , mkFinalUnfolding + , mkFinalUnfolding' , mkSimpleUnfolding , mkWorkerUnfolding , mkInlineUnfoldingWithArity, mkInlineUnfoldingNoArity @@ -35,6 +36,8 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Panic +import Data.Maybe ( fromMaybe ) + -- the very simple optimiser is used to optimise unfoldings import {-# SOURCE #-} GHC.Core.SimpleOpt @@ -43,7 +46,14 @@ import {-# SOURCE #-} GHC.Core.SimpleOpt mkFinalUnfolding :: UnfoldingOpts -> UnfoldingSource -> DmdSig -> CoreExpr -> Unfolding -- "Final" in the sense that this is a GlobalId that will not be further -- simplified; so the unfolding should be occurrence-analysed -mkFinalUnfolding opts src strict_sig expr +mkFinalUnfolding opts src strict_sig expr = mkFinalUnfolding' opts src strict_sig expr Nothing + +-- See Note [Tying the 'CoreUnfolding' knot] for why interfaces need +-- to pass a precomputed 'UnfoldingCache' +mkFinalUnfolding' :: UnfoldingOpts -> UnfoldingSource -> DmdSig -> CoreExpr -> Maybe UnfoldingCache -> Unfolding +-- "Final" in the sense that this is a GlobalId that will not be further +-- simplified; so the unfolding should be occurrence-analysed +mkFinalUnfolding' opts src strict_sig expr = mkUnfolding opts src True {- Top level -} (isDeadEndSig strict_sig) @@ -57,7 +67,7 @@ mkCompulsoryUnfolding' opts expr = mkCompulsoryUnfolding (simpleOptExpr opts exp mkCompulsoryUnfolding :: CoreExpr -> Unfolding mkCompulsoryUnfolding expr = mkCoreUnfolding CompulsorySrc True - expr + expr Nothing (UnfWhen { ug_arity = 0 -- Arity of unfolding doesn't matter , ug_unsat_ok = unSaturatedOk, ug_boring_ok = boringCxtOk }) @@ -69,7 +79,7 @@ mkCompulsoryUnfolding expr mkSimpleUnfolding :: UnfoldingOpts -> CoreExpr -> Unfolding mkSimpleUnfolding !opts rhs - = mkUnfolding opts VanillaSrc False False rhs + = mkUnfolding opts VanillaSrc False False rhs Nothing mkDFunUnfolding :: [Var] -> DataCon -> [CoreExpr] -> Unfolding mkDFunUnfolding bndrs con ops @@ -81,7 +91,7 @@ mkDFunUnfolding bndrs con ops mkDataConUnfolding :: CoreExpr -> Unfolding -- Used for non-newtype data constructors with non-trivial wrappers mkDataConUnfolding expr - = mkCoreUnfolding StableSystemSrc True expr guide + = mkCoreUnfolding StableSystemSrc True expr Nothing guide -- No need to simplify the expression where guide = UnfWhen { ug_arity = manifestArity expr @@ -93,7 +103,7 @@ mkWrapperUnfolding :: SimpleOpts -> CoreExpr -> Arity -> Unfolding -- after demand/CPR analysis mkWrapperUnfolding opts expr arity = mkCoreUnfolding StableSystemSrc True - (simpleOptExpr opts expr) + (simpleOptExpr opts expr) Nothing (UnfWhen { ug_arity = arity , ug_unsat_ok = unSaturatedOk , ug_boring_ok = boringCxtNotOk }) @@ -104,7 +114,7 @@ mkWorkerUnfolding opts work_fn (CoreUnfolding { uf_src = src, uf_tmpl = tmpl , uf_is_top = top_lvl }) | isStableSource src - = mkCoreUnfolding src top_lvl new_tmpl guidance + = mkCoreUnfolding src top_lvl new_tmpl Nothing guidance where new_tmpl = simpleOptExpr opts (work_fn tmpl) guidance = calcUnfoldingGuidance (so_uf_opts opts) False new_tmpl @@ -119,7 +129,7 @@ mkInlineUnfoldingNoArity :: SimpleOpts -> UnfoldingSource -> CoreExpr -> Unfoldi mkInlineUnfoldingNoArity opts src expr = mkCoreUnfolding src True -- Note [Top-level flag on inline rules] - expr' guide + expr' Nothing guide where expr' = simpleOptExpr opts expr guide = UnfWhen { ug_arity = manifestArity expr' @@ -133,7 +143,7 @@ mkInlineUnfoldingWithArity :: SimpleOpts -> UnfoldingSource -> Arity -> CoreExpr mkInlineUnfoldingWithArity opts src arity expr = mkCoreUnfolding src True -- Note [Top-level flag on inline rules] - expr' guide + expr' Nothing guide where expr' = simpleOptExpr opts expr guide = UnfWhen { ug_arity = arity @@ -146,7 +156,7 @@ mkInlineUnfoldingWithArity opts src arity expr mkInlinableUnfolding :: SimpleOpts -> UnfoldingSource -> CoreExpr -> Unfolding mkInlinableUnfolding opts src expr - = mkUnfolding (so_uf_opts opts) src False False expr' + = mkUnfolding (so_uf_opts opts) src False False expr' Nothing where expr' = simpleOptExpr opts expr @@ -180,7 +190,7 @@ specUnfolding opts spec_bndrs spec_app rule_lhs_args , uf_guidance = old_guidance }) | isStableSource src -- See Note [Specialising unfoldings] , UnfWhen { ug_arity = old_arity } <- old_guidance - = mkCoreUnfolding src top_lvl new_tmpl + = mkCoreUnfolding src top_lvl new_tmpl Nothing (old_guidance { ug_arity = old_arity - arity_decrease }) where new_tmpl = simpleOptExpr opts $ @@ -310,11 +320,12 @@ mkUnfolding :: UnfoldingOpts -> Bool -- Definitely a bottoming binding -- (only relevant for top-level bindings) -> CoreExpr + -> Maybe UnfoldingCache -> Unfolding -- Calculates unfolding guidance -- Occurrence-analyses the expression before capturing it -mkUnfolding opts src top_lvl is_bottoming expr - = mkCoreUnfolding src top_lvl expr guidance +mkUnfolding opts src top_lvl is_bottoming expr cache + = mkCoreUnfolding src top_lvl expr cache guidance where is_top_bottoming = top_lvl && is_bottoming guidance = calcUnfoldingGuidance opts is_top_bottoming expr @@ -322,26 +333,20 @@ mkUnfolding opts src top_lvl is_bottoming expr -- See Note [Calculate unfolding guidance on the non-occ-anal'd expression] mkCoreUnfolding :: UnfoldingSource -> Bool -> CoreExpr - -> UnfoldingGuidance -> Unfolding + -> Maybe UnfoldingCache -> UnfoldingGuidance -> Unfolding -- Occurrence-analyses the expression before capturing it -mkCoreUnfolding src top_lvl expr guidance - = CoreUnfolding { uf_tmpl = is_value `seq` - is_conlike `seq` - is_work_free `seq` - is_expandable `seq` +mkCoreUnfolding src top_lvl expr precomputed_cache guidance + = CoreUnfolding { uf_tmpl = cache `seq` occurAnalyseExpr expr -- occAnalyseExpr: see Note [Occurrence analysis of unfoldings] - -- See #20905 for what a discussion of these 'seq's + -- See #20905 for what a discussion of this 'seq'. -- We are careful to make sure we only -- have one copy of an unfolding around at once. -- Note [Thoughtful forcing in mkCoreUnfolding] , uf_src = src , uf_is_top = top_lvl - , uf_is_value = is_value - , uf_is_conlike = is_conlike - , uf_is_work_free = is_work_free - , uf_expandable = is_expandable + , uf_cache = cache , uf_guidance = guidance } where is_value = exprIsHNF expr @@ -349,6 +354,13 @@ mkCoreUnfolding src top_lvl expr guidance is_work_free = exprIsWorkFree expr is_expandable = exprIsExpandable expr + recomputed_cache = UnfoldingCache { uf_is_value = is_value + , uf_is_conlike = is_conlike + , uf_is_work_free = is_work_free + , uf_expandable = is_expandable } + + cache = fromMaybe recomputed_cache precomputed_cache + ---------------- certainlyWillInline :: UnfoldingOpts -> IdInfo -> CoreExpr -> Maybe Unfolding -- ^ Sees if the unfolding is pretty certain to inline. @@ -476,4 +488,3 @@ reducing memory pressure. The result of fixing this led to a 1G reduction in peak memory usage (12G -> 11G) when compiling a very large module (peak 3 million terms). For more discussion see #20905. -} - ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -2253,10 +2253,9 @@ diffUnfold env (DFunUnfolding bs1 c1 a1) | c1 == c2 && equalLength bs1 bs2 = concatMap (uncurry (diffExpr False env')) (zip a1 a2) where env' = rnBndrs2 env bs1 bs2 -diffUnfold env (CoreUnfolding t1 _ _ v1 cl1 wf1 x1 g1) - (CoreUnfolding t2 _ _ v2 cl2 wf2 x2 g2) - | v1 == v2 && cl1 == cl2 - && wf1 == wf2 && x1 == x2 && g1 == g2 +diffUnfold env (CoreUnfolding t1 _ _ c1 g1) + (CoreUnfolding t2 _ _ c2 g2) + | c1 == c2 && g1 == g2 = diffExpr False env t1 t2 diffUnfold _ uf1 uf2 = [fsep [ppr uf1, text "/=", ppr uf2]] ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -508,9 +508,10 @@ toIfaceJoinInfo Nothing = IfaceNotJoinPoint toIfUnfolding :: Bool -> Unfolding -> Maybe IfaceInfoItem toIfUnfolding lb (CoreUnfolding { uf_tmpl = rhs , uf_src = src + , uf_cache = cache , uf_guidance = guidance }) = Just $ HsUnfold lb $ - IfCoreUnfold src (toIfGuidance src guidance) (toIfaceExpr rhs) + IfCoreUnfold src cache (toIfGuidance src guidance) (toIfaceExpr rhs) -- Yes, even if guidance is UnfNever, expose the unfolding -- If we didn't want to expose the unfolding, GHC.Iface.Tidy would -- have stuck in NoUnfolding. For supercompilation we want ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -596,8 +596,8 @@ rnIfaceInfoItem i = pure i rnIfaceUnfolding :: Rename IfaceUnfolding -rnIfaceUnfolding (IfCoreUnfold src guide if_expr) - = IfCoreUnfold src guide <$> rnIfaceExpr if_expr +rnIfaceUnfolding (IfCoreUnfold src cache guide if_expr) + = IfCoreUnfold src cache guide <$> rnIfaceExpr if_expr rnIfaceUnfolding (IfDFunUnfold bs ops) = IfDFunUnfold <$> rnIfaceBndrs bs <*> mapM rnIfaceExpr ops ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -49,7 +49,7 @@ import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey, import GHC.Types.Unique ( hasKey ) import GHC.Iface.Type import GHC.Iface.Recomp.Binary -import GHC.Core( IsOrphan, isOrphan ) +import GHC.Core( IsOrphan, isOrphan, UnfoldingCache(..) ) import GHC.Types.Demand import GHC.Types.Cpr import GHC.Core.Class @@ -365,9 +365,14 @@ data IfaceInfoItem -- only later attached to the Id. Partial reason: some are orphans. data IfaceUnfolding - = IfCoreUnfold UnfoldingSource IfGuidance IfaceExpr + = IfCoreUnfold UnfoldingSource + IfUnfoldingCache -- See Note [Tying the 'CoreUnfolding' knot] + IfGuidance + IfaceExpr | IfDFunUnfold [IfaceBndr] [IfaceExpr] +type IfUnfoldingCache = UnfoldingCache + data IfGuidance = IfNoGuidance -- Compute it from the IfaceExpr | IfWhen Arity Bool Bool -- Just like UnfWhen in Core.UnfoldingGuidance @@ -1522,7 +1527,7 @@ instance Outputable IfaceJoinInfo where ppr (IfaceJoinPoint ar) = angleBrackets (text "join" <+> ppr ar) instance Outputable IfaceUnfolding where - ppr (IfCoreUnfold src guide e) + ppr (IfCoreUnfold src _ guide e) = sep [ text "Core:" <+> ppr src <+> ppr guide, ppr e ] ppr (IfDFunUnfold bs es) = hang (text "DFun:" <+> sep (map ppr bs) <> dot) 2 (sep (map pprParendIfaceExpr es)) @@ -1774,7 +1779,7 @@ freeNamesItem (HsLFInfo (IfLFCon n)) = unitNameSet n freeNamesItem _ = emptyNameSet freeNamesIfUnfold :: IfaceUnfolding -> NameSet -freeNamesIfUnfold (IfCoreUnfold _ _ e) = freeNamesIfExpr e +freeNamesIfUnfold (IfCoreUnfold _ _ _ e) = freeNamesIfExpr e freeNamesIfUnfold (IfDFunUnfold bs es) = freeNamesIfBndrs bs &&& fnList freeNamesIfExpr es freeNamesIfExpr :: IfaceExpr -> NameSet @@ -2296,9 +2301,10 @@ instance Binary IfaceInfoItem where _ -> HsTagSig <$> get bh instance Binary IfaceUnfolding where - put_ bh (IfCoreUnfold s g e) = do + put_ bh (IfCoreUnfold s c g e) = do putByte bh 0 put_ bh s + putUnfoldingCache bh c put_ bh g put_ bh e put_ bh (IfDFunUnfold as bs) = do @@ -2309,9 +2315,10 @@ instance Binary IfaceUnfolding where h <- getByte bh case h of 0 -> do s <- get bh + c <- getUnfoldingCache bh g <- get bh e <- get bh - return (IfCoreUnfold s g e) + return (IfCoreUnfold s c g e) _ -> do as <- get bh bs <- get bh return (IfDFunUnfold as bs) @@ -2332,6 +2339,26 @@ instance Binary IfGuidance where c <- get bh return (IfWhen a b c) +putUnfoldingCache :: BinHandle -> IfUnfoldingCache -> IO () +putUnfoldingCache bh (UnfoldingCache { uf_is_value = hnf, uf_is_conlike = conlike + , uf_is_work_free = wf, uf_expandable = exp }) = do + let b = zeroBits .<<|. hnf .<<|. conlike .<<|. wf .<<|. exp + putByte bh b + +getUnfoldingCache :: BinHandle -> IO IfUnfoldingCache +getUnfoldingCache bh = do + b <- getByte bh + let hnf = testBit b 3 + conlike = testBit b 2 + wf = testBit b 1 + exp = testBit b 0 + return (UnfoldingCache { uf_is_value = hnf, uf_is_conlike = conlike + , uf_is_work_free = wf, uf_expandable = exp }) + +infixl 9 .<<|. +(.<<|.) :: (Bits a) => a -> Bool -> a +x .<<|. b = (if b then (`setBit` 0) else id) (x `shiftL` 1) + instance Binary IfaceAlt where put_ bh (IfaceAlt a b c) = do put_ bh a @@ -2688,8 +2715,9 @@ instance NFData IfGuidance where instance NFData IfaceUnfolding where rnf = \case - IfCoreUnfold src guidance expr -> src `seq` rnf guidance `seq` rnf expr - IfDFunUnfold bndrs exprs -> rnf bndrs `seq` rnf exprs + IfCoreUnfold src cache guidance expr -> src `seq` cache `seq` rnf guidance `seq` rnf expr + IfDFunUnfold bndrs exprs -> rnf bndrs `seq` rnf exprs + -- See Note [UnfoldingCache] in GHC.Core for why it suffices to merely `seq` on cache instance NFData IfaceExpr where rnf = \case ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1715,7 +1715,7 @@ tcIdInfo ignore_prags toplvl name ty info = do need_prag :: IfaceInfoItem -> Bool -- Always read in compulsory unfoldings -- See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy - need_prag (HsUnfold _ (IfCoreUnfold src _ _)) = isCompulsorySource src + need_prag (HsUnfold _ (IfCoreUnfold src _ _ _)) = isCompulsorySource src need_prag _ = False tcPrag :: IdInfo -> IfaceInfoItem -> IfL IdInfo @@ -1776,13 +1776,14 @@ tcLFInfo lfi = case lfi of tcUnfolding :: TopLevelFlag -> Name -> Type -> IdInfo -> IfaceUnfolding -> IfL Unfolding -- See Note [Lazily checking Unfoldings] -tcUnfolding toplvl name _ info (IfCoreUnfold src if_guidance if_expr) +tcUnfolding toplvl name _ info (IfCoreUnfold src cache if_guidance if_expr) = do { uf_opts <- unfoldingOpts <$> getDynFlags ; expr <- tcUnfoldingRhs (isCompulsorySource src) toplvl name if_expr ; let guidance = case if_guidance of IfWhen arity unsat_ok boring_ok -> UnfWhen arity unsat_ok boring_ok IfNoGuidance -> calcUnfoldingGuidance uf_opts is_top_bottoming expr - ; return $ mkCoreUnfolding src True expr guidance } + -- See Note [Tying the 'CoreUnfolding' knot] + ; return $ mkCoreUnfolding src True expr (Just cache) guidance } where -- Strictness should occur before unfolding! is_top_bottoming = isTopLevel toplvl && isDeadEndSig (dmdSigInfo info) @@ -1795,6 +1796,49 @@ tcUnfolding _toplvl name dfun_ty _ (IfDFunUnfold bs ops) doc = text "Class ops for dfun" <+> ppr name (_, _, cls, _) = tcSplitDFunTy dfun_ty +{- Note [Tying the 'CoreUnfolding' knot] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The unfolding of recursive definitions can contain references to the +Id being defined. Consider the following example: + + foo :: () + foo = foo + +The unfolding template of 'foo' is, of course, 'foo'; so the interface +file for this module contains: + + foo :: (); Unfolding = foo + +When rehydrating the interface file we are going to make an Id for +'foo' (in GHC.IfaceToCore), with an 'Unfolding'. We used to make this +'Unfolding' by calling 'mkFinalUnfolding', but that needs to populate, +among other fields, the 'uf_is_value' field, by computing +'exprIsValue' of the template (in this case, 'foo'). + +'exprIsValue e' looks at the unfoldings of variables in 'e' to see if +they are evaluated; so it consults the `uf_is_value` field of +variables in `e`. Now we can see the problem: to set the `uf_is_value` +field of `foo`'s unfolding, we look at its unfolding (in this case +just `foo` itself!). Loop. This is the root cause of ticket #22272. + +The simple solution we chose is to serialise the various auxiliary +fields of `CoreUnfolding` so that we don't need to recreate them when +rehydrating. Specifically, the following fields are moved to the +'UnfoldingCache', which is persisted in the interface file: + +* 'uf_is_conlike' +* 'uf_is_value' +* 'uf_is_work_free' +* 'uf_expandable' + +These four bits make the interface files only one byte larger per +unfolding; on the other hand, this does save calls to 'exprIsValue', +'exprIsExpandable' etc for every imported Id. + +We could choose to do this only for loop breakers. But that's a bit +more complicated and it seems good all round. +-} + {- Note [Lazily checking Unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For unfoldings, we try to do the job lazily, so that we never typecheck ===================================== libraries/base/tests/IO/T21336/all.T ===================================== @@ -1,6 +1,9 @@ # N.B. /dev/full exists on Darwin but cannot be opened, failing with -EPERM test('T21336a', - [unless(opsys('linux') or opsys('freebsd'), skip), js_broken(22261)], + [ unless(opsys('linux') or opsys('freebsd'), skip) + , js_broken(22261) + , fragile(22022) + ], compile_and_run, ['']) test('T21336b', [unless(opsys('linux') or opsys('freebsd'), skip), js_broken(22352)], ===================================== testsuite/tests/deSugar/should_compile/T13208.stdout ===================================== @@ -1,6 +1,6 @@ - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}] f = \ (@p) _ [Occ=Dead] -> GHC.Types.True - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/numeric/should_compile/T14170.stdout ===================================== @@ -6,44 +6,50 @@ Result size of Tidy Core -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] NatVal.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] NatVal.$trModule3 = GHC.Types.TrNameS NatVal.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] NatVal.$trModule2 = "NatVal"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] NatVal.$trModule1 = GHC.Types.TrNameS NatVal.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] NatVal.$trModule = GHC.Types.Module NatVal.$trModule3 NatVal.$trModule1 -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} foo :: Integer [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] foo = GHC.Num.Integer.IS 0# ===================================== testsuite/tests/numeric/should_compile/T14465.stdout ===================================== @@ -6,43 +6,49 @@ Result size of Tidy Core -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} ten :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] ten = GHC.Num.Natural.NS 10## -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} M.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] M.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.$trModule3 = GHC.Types.TrNameS M.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} M.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] M.$trModule2 = "M"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.$trModule1 = GHC.Types.TrNameS M.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} M.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.$trModule = GHC.Types.Module M.$trModule3 M.$trModule1 -- RHS size: {terms: 1, types: 1, coercions: 0, joins: 0/0} @@ -50,23 +56,25 @@ minusOne :: Natural [GblId, Str=b, Cpr=b, - Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=False, ConLike=False, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] minusOne = GHC.Prim.Exception.raiseUnderflow @Natural -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} twoTimesTwo :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] twoTimesTwo = GHC.Num.Natural.NS 4## -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.one1 :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.one1 = GHC.Num.Natural.NS 1## -- RHS size: {terms: 4, types: 1, coercions: 0, joins: 0/0} @@ -74,15 +82,16 @@ plusOne :: Natural -> Natural [GblId, Arity=1, Str=<1L>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [0] 30 0}] plusOne = \ (n :: Natural) -> naturalAdd n M.one1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} one :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] one = M.one1 ===================================== testsuite/tests/numeric/should_compile/T7116.stdout ===================================== @@ -6,36 +6,41 @@ Result size of Tidy Core -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T7116.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] T7116.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T7116.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T7116.$trModule3 = GHC.Types.TrNameS T7116.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T7116.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] T7116.$trModule2 = "T7116"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T7116.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T7116.$trModule1 = GHC.Types.TrNameS T7116.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7116.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T7116.$trModule = GHC.Types.Module T7116.$trModule3 T7116.$trModule1 @@ -45,8 +50,8 @@ dr :: Double -> Double Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (x [Occ=Once1!] :: Double) -> case x of { GHC.Types.D# x1 -> @@ -62,8 +67,8 @@ dl :: Double -> Double Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] dl = dr @@ -73,8 +78,8 @@ fr :: Float -> Float Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (x [Occ=Once1!] :: Float) -> case x of { GHC.Types.F# x1 -> @@ -92,8 +97,8 @@ fl :: Float -> Float Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] fl = fr ===================================== testsuite/tests/simplCore/should_compile/T21476.hs ===================================== @@ -0,0 +1,4 @@ +{-# LANGUAGE MagicHash #-} +module T21476 where +import GHC.Exts +f = keepAlive# ===================================== testsuite/tests/simplCore/should_compile/T22272.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module T22272 where + +import T22272_A + +bar :: () +bar = foo ===================================== testsuite/tests/simplCore/should_compile/T22272.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling T22272_A ( T22272_A.hs, T22272_A.o ) +[2 of 2] Compiling T22272 ( T22272.hs, T22272.o ) ===================================== testsuite/tests/simplCore/should_compile/T22272_A.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module T22272_A where + +foo :: () +foo = foo ===================================== testsuite/tests/simplCore/should_compile/T3772.stdout ===================================== @@ -6,36 +6,41 @@ Result size of Tidy Core -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T3772.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] T3772.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T3772.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T3772.$trModule3 = GHC.Types.TrNameS T3772.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T3772.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] T3772.$trModule2 = "T3772"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T3772.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T3772.$trModule1 = GHC.Types.TrNameS T3772.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3772.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T3772.$trModule = GHC.Types.Module T3772.$trModule3 T3772.$trModule1 @@ -67,8 +72,8 @@ foo [InlPrag=NOINLINE[final]] :: Int -> () Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (n [Occ=Once1!] :: Int) -> case n of { GHC.Types.I# ww [Occ=Once1] -> ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -456,3 +456,5 @@ test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m - test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T22491', normal, compile, ['-O2']) +test('T21476', normal, compile, ['']) +test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings -fno-omit-interface-pragmas -fno-ignore-interface-pragmas']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2ce35a4bb732dc37e77597ca47b1d7579c92bb0f...dfe222ccfb999b2ffce782972137b28c3e2152a0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2ce35a4bb732dc37e77597ca47b1d7579c92bb0f...dfe222ccfb999b2ffce782972137b28c3e2152a0 You're receiving 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 Dec 13 09:13:32 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 13 Dec 2022 04:13:32 -0500 Subject: [Git][ghc/ghc][wip/t22599] ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Message-ID: <6398423c3223f_389fe25265c208451@gitlab.mail> Matthew Pickering pushed to branch wip/t22599 at Glasgow Haskell Compiler / GHC Commits: 5b8e9a2e by Matthew Pickering at 2022-12-13T09:13:21+00:00 ci: Upgrade darwin, windows and freebsd CI to use GHC-9.4.3 Fixes #22599 - - - - - 4 changed files: - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/ci.sh ===================================== @@ -320,7 +320,7 @@ function fetch_cabal() { MINGW64) cabal_arch="x86_64" ;; *) fail "unknown MSYSTEM $MSYSTEM" ;; esac - url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-unknown-mingw32.zip" + url="https://downloads.haskell.org/~cabal/cabal-install-$v/cabal-install-$v-$cabal_arch-windows.zip" info "Fetching cabal binary distribution from $url..." curl "$url" > "$TMP/cabal.zip" unzip "$TMP/cabal.zip" ===================================== .gitlab/darwin/toolchain.nix ===================================== @@ -15,16 +15,16 @@ let ghcBindists = let version = ghc.version; in { aarch64-darwin = pkgs.fetchurl { url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz"; - sha256 = "sha256:0p2f35pihlnmkm7x73b5xm3dyhiczrywc19khr7i7vb2q1y4zw6i"; + sha256 = "sha256:10pby1idpxhkjqsi56jivkymhnabsdr8m2x8gdqchnv5113hl72k"; }; x86_64-darwin = pkgs.fetchurl { url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; - sha256 = "sha256:0gzq0vfjbhr9n8z63capvdwrw7bisy15d5c1y1gynfix13bbnjlk"; + sha256 = "sha256:012yzyangk26sdapnz4226prgb8jgpf6k5bd9qxsdykk5x7jc7ah"; }; }; ghc = pkgs.stdenv.mkDerivation rec { - version = "9.2.2"; + version = "9.4.3"; name = "ghc"; src = ghcBindists.${pkgs.stdenv.hostPlatform.system}; configureFlags = [ ===================================== .gitlab/gen_ci.hs ===================================== @@ -342,7 +342,7 @@ opsysVariables _ FreeBSD13 = mconcat -- [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html) "CONFIGURE_ARGS" =: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib" , "HADRIAN_ARGS" =: "--docs=no-sphinx" - , "GHC_VERSION" =: "9.2.2" + , "GHC_VERSION" =: "9.4.3" , "CABAL_INSTALL_VERSION" =: "3.6.2.0" ] opsysVariables _ (Linux distro) = distroVariables distro @@ -371,8 +371,8 @@ opsysVariables _ (Windows {}) = mconcat [ "MSYSTEM" =: "MINGW64" , "HADRIAN_ARGS" =: "--docs=no-sphinx" , "LANG" =: "en_US.UTF-8" - , "CABAL_INSTALL_VERSION" =: "3.2.0.0" - , "GHC_VERSION" =: "9.2.2" ] + , "CABAL_INSTALL_VERSION" =: "3.8.1.0" + , "GHC_VERSION" =: "9.4.3" ] opsysVariables _ _ = mempty ===================================== .gitlab/jobs.yaml ===================================== @@ -479,7 +479,7 @@ "BUILD_FLAVOUR": "validate", "CABAL_INSTALL_VERSION": "3.6.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib ", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "TEST_ENV": "x86_64-freebsd13-validate", "XZ_OPT": "-9" @@ -1676,9 +1676,9 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", @@ -1735,9 +1735,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", @@ -2050,7 +2050,7 @@ "BUILD_FLAVOUR": "release", "CABAL_INSTALL_VERSION": "3.6.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib ", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", "TEST_ENV": "x86_64-freebsd13-release", @@ -2780,9 +2780,9 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", @@ -2840,9 +2840,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-release", "BUILD_FLAVOUR": "release", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", @@ -2970,7 +2970,7 @@ "BUILD_FLAVOUR": "validate", "CABAL_INSTALL_VERSION": "3.6.2.0", "CONFIGURE_ARGS": "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib ", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "TEST_ENV": "x86_64-freebsd13-validate" } @@ -4149,9 +4149,9 @@ "BIGNUM_BACKEND": "native", "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", @@ -4207,9 +4207,9 @@ "BIGNUM_BACKEND": "gmp", "BIN_DIST_NAME": "ghc-x86_64-windows-validate", "BUILD_FLAVOUR": "validate", - "CABAL_INSTALL_VERSION": "3.2.0.0", + "CABAL_INSTALL_VERSION": "3.8.1.0", "CONFIGURE_ARGS": "", - "GHC_VERSION": "9.2.2", + "GHC_VERSION": "9.4.3", "HADRIAN_ARGS": "--docs=no-sphinx", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5b8e9a2eb6b854ed9d9f2c4fda0bf2b3fe7fb5f0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5b8e9a2eb6b854ed9d9f2c4fda0bf2b3fe7fb5f0 You're receiving 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 Dec 13 09:25:10 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 13 Dec 2022 04:25:10 -0500 Subject: [Git][ghc/ghc][wip/T22317] 2 commits: Simplifier: Fix `conSize` estimate (#22317) Message-ID: <639844f677a82_389fe25267021496b@gitlab.mail> Sebastian Graf pushed to branch wip/T22317 at Glasgow Haskell Compiler / GHC Commits: 1b10aad1 by Sebastian Graf at 2022-12-13T10:20:50+01:00 Simplifier: Fix `conSize` estimate (#22317) The estimate we used to have was far too optimistic (#22317). We now size up constructor applications like we do function applications. See the changes to `Note [Constructor size and result discount]`. I also changed `Note [Inlining small things to avoid creating a thunk]` so that it is clear that "thing" includes join points. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- atom +0.0% -2.3% cacheprof -0.0% -3.0% calendar +1.1% +1.1% cichelli 0.0% -0.5% comp_lab_zift +0.8% +0.5% dom-lt +0.6% +0.4% fasta +0.0% -0.4% fibheaps -1.3% -1.8% gamteb -2.4% -1.4% hidden +0.0% -0.9% last-piece -1.5% -2.4% life +2.1% +1.0% linear 0.0% -1.8% para -2.8% -1.7% pic 0.0% -0.6% solid -4.0% -1.2% sphere 0.0% -1.0% transform +0.0% -0.8% wave4main +0.8% +0.2% -------------------------------------------------------------------------------- Min -4.0% -3.0% Max +2.1% +1.1% Geometric Mean -0.1% -0.2% ``` Binary sizes go down by 0.1%, ever so slightly. Fixes #22317. Regression test in T22317b. - - - - - dc021331 by Sebastian Graf at 2022-12-13T10:24:46+01:00 Fix warnings in ExactPrint (#22555) - - - - - 22 changed files: - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Unfold.hs - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/deSugar/should_compile/T16615.stderr - testsuite/tests/numeric/should_compile/T14170.stdout - 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/T18013.stderr - + testsuite/tests/simplCore/should_compile/T22317b.hs - + testsuite/tests/simplCore/should_compile/T22317b.stderr - 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/all.T - testsuite/tests/simplCore/should_compile/spec-inline.stderr - testsuite/tests/stranal/should_compile/T20510.stderr - testsuite/tests/stranal/should_compile/T21128.stderr - testsuite/tests/typecheck/should_compile/T13032.stderr - utils/check-exact/ExactPrint.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1550,10 +1550,12 @@ postInlineUnconditionally env bind_cxt bndr occ_info rhs = case occ_info of OneOcc { occ_in_lam = in_lam, occ_int_cxt = int_cxt, occ_n_br = n_br } -- See Note [Inline small things to avoid creating a thunk] + --- | BC_Let{} <- bind_cxt -- No! "thing" also includes join points + -- See the Note. - -> n_br < 100 -- See Note [Suppress exponential blowup] + | n_br < 100 -- See Note [Suppress exponential blowup] - && smallEnoughToInline uf_opts unfolding -- Small enough to dup + , smallEnoughToInline uf_opts unfolding -- Small enough to dup -- ToDo: consider discount on smallEnoughToInline if int_cxt is true -- -- NB: Do NOT inline arbitrarily big things, even if occ_n_br=1 @@ -1564,7 +1566,7 @@ postInlineUnconditionally env bind_cxt bndr occ_info rhs -- PRINCIPLE: when we've already simplified an expression once, -- make sure that we only inline it if it's reasonably small. - && (in_lam == NotInsideLam || + , in_lam == NotInsideLam || -- Outside a lambda, we want to be reasonably aggressive -- about inlining into multiple branches of case -- e.g. let x = @@ -1573,10 +1575,11 @@ postInlineUnconditionally env bind_cxt bndr occ_info rhs -- the uses in C1, C2 are not 'interesting' -- An example that gets worse if you add int_cxt here is 'clausify' - (isCheapUnfolding unfolding && int_cxt == IsInteresting)) + (isCheapUnfolding unfolding && int_cxt == IsInteresting) -- isCheap => acceptable work duplication; in_lam may be true -- int_cxt to prevent us inlining inside a lambda without some -- good reason. See the notes on int_cxt in preInlineUnconditionally + -> True IAmDead -> True -- This happens; for example, the case_bndr during case of -- known constructor: case (a,b) of x { (p,q) -> ... } @@ -1610,17 +1613,39 @@ The point of examining occ_info here is that for *non-values* that occur outside a lambda, the call-site inliner won't have a chance (because it doesn't know that the thing only occurs once). The pre-inliner won't have gotten it either, if the thing occurs in more -than one branch So the main target is things like - - let x = f y in - case v of - True -> case x of ... - False -> case x of ... - -This is very important in practice; e.g. wheel-seive1 doubles -in allocation if you miss this out. And bits of GHC itself start -to allocate more. An egregious example is test perf/compiler/T14697, -where GHC.Driver.CmdLine.$wprocessArgs allocated hugely more. +than one branch. So the main target is things like $ssieve from wheel-sieve1 + + let ds1 = in + let ds2 = case x of I# x# -> case y of I# y# -> I# (x# +# y#) in + join $j = ds2 : ds1 in + if z > 2 + then jump $j + else if $wnotDivBy ... (unI# ds2) ... + then ds1 + else jump $j + +Here, we want to inline the small join point $j. By itself, that is not an +improvement, but after inlining, we see that `ds1` and `ds2` become OneOcc, too: + + let ds1 = in + let ds2 = case x of I# x# -> case y of I# y# -> I# (x# +# y#) in + if z > 2 + then ds2 : ds1 + else if $wnotDivBy ... (unI# ds2) ... + then ds1 + else ds2 : ds1 + +And now we can inline `ds1` and `ds2`. The latter can even be unboxed in the hot +path when z <= 2! + +So by inlining the join point, we have greatly improved clarity for occurrence +analysis. This is very important in practice; e.g. wheel-sieve1 doubles +in allocation if you miss this out. And bits of GHC itself start to +allocate more. An egregious example is test perf/compiler/T14697, where +GHC.Driver.CmdLine.$wprocessArgs allocated hugely more. + +Ideally, occurrence analysis would simply look through $j without the Simplifier +needing to inline $j; that's discussed in #22404. Note [Suppress exponential blowup] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -669,7 +669,7 @@ jumpSize n_val_args voids = 2 * (1 + n_val_args - voids) -- better solution? funSize :: UnfoldingOpts -> [Id] -> Id -> Int -> Int -> ExprSize --- Size for functions that are not constructors or primops +-- Size for function calls that are not constructors or primops -- Note [Function applications] funSize opts top_args fun n_val_args voids | fun `hasKey` buildIdKey = buildSize @@ -698,21 +698,25 @@ funSize opts top_args fun n_val_args voids conSize :: DataCon -> Int -> ExprSize conSize dc n_val_args - | n_val_args == 0 = SizeIs 0 emptyBag 10 -- Like variables - -- See Note [Unboxed tuple size and result discount] | isUnboxedTupleDataCon dc = SizeIs 0 emptyBag 10 -- See Note [Constructor size and result discount] - | otherwise = SizeIs 10 emptyBag 10 + | otherwise = SizeIs (6 * n_val_args) emptyBag 10 {- Note [Constructor size and result discount] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Treat a constructors application as size 10, regardless of how many -arguments it has; we are keen to expose them (and we charge separately -for their args). We can't treat them as size zero, else we find that -(Just x) has size 0, which is the same as a lone variable; and hence -'v' will always be replaced by (Just x), where v is bound to Just x. +Constructor applications are generally a bit smaller than function calls, but +we have to ensure that we don't duplicate a lot of big record updates. +So every value argument contributes a size of 6, but SG's experiments concluded +that any factor between 6 and 9 would work: + * A factor of 10 means we don't inline eftWord anymore (undesirable for + T15263) + * But a factor of 5 means we get too much inlining in T22317b. +Picking 6 seems to have the lowest potential for breaking performance changes, +so that's what we go with. +A side effect of the formula is that a nullary constructor application is +treated the same as a lone variable. The "result discount" is applied if the result of the call is scrutinised (say by a case). For a constructor application that will @@ -744,6 +748,14 @@ win", but its terribly dangerous because a function with many many case branches, each finishing with a constructor, can have an arbitrarily large discount. This led to terrible code bloat: see #6099. +Historical note 3: Until Dec 22 we used to give all DataCon apps had size 10. +(We can't treat them as size zero, else we find that (Just x) has size 0, +which is the same as a lone variable; and hence 'v' will always be replaced by +(Just x), where v is bound to Just x.) +But constant size 10 turned out to cause unnecessary code bloat in #22317 +(T22317b). The higher the number of fields, the more code we generate for each +DataCon app, so we should really treat a DataCon app more like a function app. + Note [Unboxed tuple size and result discount] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ However, unboxed tuples count as size zero. I found occasions where we had ===================================== testsuite/tests/deSugar/should_compile/T13208.stdout ===================================== @@ -3,4 +3,4 @@ Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}] f = \ (@p) _ [Occ=Dead] -> GHC.Types.True Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 120 10}] ===================================== testsuite/tests/deSugar/should_compile/T16615.stderr ===================================== @@ -7,7 +7,7 @@ Result size of Desugar (after optimization) T16615.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 120 10}] T16615.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T16615"#) @@ -17,7 +17,7 @@ Rec { g :: Int -> Bool [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 120 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 130 10}] g = \ (i :: Int) -> case == @Int GHC.Classes.$fEqInt i (GHC.Types.I# 0#) of { False -> f (pred @Int GHC.Enum.$fEnumInt i); @@ -28,7 +28,7 @@ g = \ (i :: Int) -> f [Occ=LoopBreaker] :: Int -> Bool [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 120 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 130 10}] f = \ (i :: Int) -> case == @Int GHC.Classes.$fEqInt i (GHC.Types.I# 0#) of { False -> g (pred @Int GHC.Enum.$fEnumInt i); ===================================== testsuite/tests/numeric/should_compile/T14170.stdout ===================================== @@ -14,7 +14,7 @@ NatVal.$trModule4 = "main"# NatVal.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] NatVal.$trModule3 = GHC.Types.TrNameS NatVal.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ NatVal.$trModule2 = "NatVal"# NatVal.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] NatVal.$trModule1 = GHC.Types.TrNameS NatVal.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] NatVal.$trModule = GHC.Types.Module NatVal.$trModule3 NatVal.$trModule1 @@ -43,7 +43,7 @@ NatVal.$trModule foo :: Integer [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] foo = GHC.Num.Integer.IS 0# ===================================== testsuite/tests/numeric/should_compile/T14465.stdout ===================================== @@ -7,7 +7,7 @@ Result size of Tidy Core ten :: Natural [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] ten = GHC.Num.Natural.NS 10## -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -21,7 +21,7 @@ M.$trModule4 = "main"# M.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] M.$trModule3 = GHC.Types.TrNameS M.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -35,14 +35,14 @@ M.$trModule2 = "M"# M.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] M.$trModule1 = GHC.Types.TrNameS M.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} M.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] M.$trModule = GHC.Types.Module M.$trModule3 M.$trModule1 -- RHS size: {terms: 1, types: 1, coercions: 0, joins: 0/0} @@ -59,14 +59,14 @@ minusOne = GHC.Prim.Exception.raiseUnderflow @Natural twoTimesTwo :: Natural [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] twoTimesTwo = GHC.Num.Natural.NS 4## -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.one1 :: Natural [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] M.one1 = GHC.Num.Natural.NS 1## -- RHS size: {terms: 4, types: 1, coercions: 0, joins: 0/0} ===================================== testsuite/tests/numeric/should_compile/T7116.stdout ===================================== @@ -14,7 +14,7 @@ T7116.$trModule4 = "main"# T7116.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7116.$trModule3 = GHC.Types.TrNameS T7116.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T7116.$trModule2 = "T7116"# T7116.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7116.$trModule1 = GHC.Types.TrNameS T7116.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7116.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T7116.$trModule = GHC.Types.Module T7116.$trModule3 T7116.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -34,7 +34,7 @@ T13143.$trModule4 = "main"# T13143.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T13143.$trModule3 = GHC.Types.TrNameS T13143.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -48,14 +48,14 @@ T13143.$trModule2 = "T13143"# T13143.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T13143.$trModule1 = GHC.Types.TrNameS T13143.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T13143.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T13143.$trModule = GHC.Types.Module T13143.$trModule3 T13143.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T18013.stderr ===================================== @@ -131,65 +131,30 @@ Rule fired: Class op fmap (BUILTIN) ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 52, types: 95, coercions: 17, joins: 0/1} + = {terms: 64, types: 125, coercions: 17, joins: 0/1} --- RHS size: {terms: 37, types: 78, coercions: 17, joins: 0/1} -mapMaybeRule [InlPrag=[2]] - :: forall a b. Rule IO a b -> Rule IO (Maybe a) (Maybe b) -[GblId, - Arity=1, - Str=<1!P(L,LC(S,C(1,C(1,P(L,1L)))))>, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (@a) (@b) (f [Occ=Once1!] :: Rule IO a b) -> - case f of { Rule @s ww ww1 [Occ=OnceL1!] -> - T18013a.Rule - @IO - @(Maybe a) - @(Maybe b) - @s - ww - ((\ (s2 [Occ=Once1] :: s) - (a1 [Occ=Once1!] :: Maybe a) - (s1 [Occ=Once2] :: GHC.Prim.State# GHC.Prim.RealWorld) -> - case a1 of { - Nothing -> - (# s1, T18013a.Result @s @(Maybe b) ww (GHC.Maybe.Nothing @b) #); - Just x [Occ=Once1] -> - case ((ww1 s2 x) - `cast` :: IO (Result s b) - ~R# (GHC.Prim.State# GHC.Prim.RealWorld - -> (# GHC.Prim.State# GHC.Prim.RealWorld, - Result s b #))) - s1 - of - { (# ipv [Occ=Once1], ipv1 [Occ=Once1!] #) -> - case ipv1 of { Result t2 [Occ=Once1] c1 [Occ=Once1] -> - (# ipv, T18013a.Result @s @(Maybe b) t2 (GHC.Maybe.Just @b c1) #) - } - } - }) - `cast` :: (s - -> Maybe a - -> GHC.Prim.State# GHC.Prim.RealWorld - -> (# GHC.Prim.State# GHC.Prim.RealWorld, - Result s (Maybe b) #)) - ~R# (s -> Maybe a -> IO (Result s (Maybe b)))) - }}] -mapMaybeRule - = \ (@a) (@b) (f :: Rule IO a b) -> - case f of { Rule @s ww ww1 -> +-- RHS size: {terms: 39, types: 71, coercions: 17, joins: 0/1} +T18013.$wmapMaybeRule [InlPrag=[2]] + :: forall {a} {b} {s}. + s -> (s -> a -> IO (Result s b)) -> Rule IO (Maybe a) (Maybe b) +[GblId[StrictWorker([!])], + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [20 60] 220 10}] +T18013.$wmapMaybeRule + = \ (@a) (@b) (@s) (ww :: s) (ww1 :: s -> a -> IO (Result s b)) -> + case ww of ww2 { __DEFAULT -> let { lvl :: Result s (Maybe b) [LclId, Unf=OtherCon []] - lvl = T18013a.Result @s @(Maybe b) ww (GHC.Maybe.Nothing @b) } in + lvl = T18013a.Result @s @(Maybe b) ww2 (GHC.Maybe.Nothing @b) } in T18013a.Rule @IO @(Maybe a) @(Maybe b) @s - ww + ww2 ((\ (s2 :: s) (a1 :: Maybe a) (s1 :: GHC.Prim.State# GHC.Prim.RealWorld) -> @@ -216,6 +181,25 @@ mapMaybeRule ~R# (s -> Maybe a -> IO (Result s (Maybe b)))) } +-- RHS size: {terms: 9, types: 21, coercions: 0, joins: 0/0} +mapMaybeRule [InlPrag=[2]] + :: forall a b. Rule IO a b -> Rule IO (Maybe a) (Maybe b) +[GblId, + Arity=1, + Str=<1!P(1L,LC(S,C(1,C(1,P(L,1L)))))>, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (@a) (@b) (f [Occ=Once1!] :: Rule IO a b) -> + case f of { Rule @s ww [Occ=Once1] ww1 [Occ=Once1] -> + T18013.$wmapMaybeRule @a @b @s ww ww1 + }}] +mapMaybeRule + = \ (@a) (@b) (f :: Rule IO a b) -> + case f of { Rule @s ww ww1 -> + T18013.$wmapMaybeRule @a @b @s ww ww1 + } + -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18013.$trModule4 :: GHC.Prim.Addr# [GblId, @@ -227,7 +211,7 @@ T18013.$trModule4 = "main"# T18013.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T18013.$trModule3 = GHC.Types.TrNameS T18013.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -241,14 +225,14 @@ T18013.$trModule2 = "T18013"# T18013.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T18013.$trModule1 = GHC.Types.TrNameS T18013.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18013.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T18013.$trModule = GHC.Types.Module T18013.$trModule3 T18013.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T22317b.hs ===================================== @@ -0,0 +1,22 @@ +{-# LANGUAGE BangPatterns #-} + +module T22317b where + +import GHC.Exts + +data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool) + + +m :: Maybe a -> Maybe a -> Maybe a +m (Just v1) Nothing = Just v1 +m _ mb = mb +{-# INLINE m #-} + +f :: T -> T -> T +f (T a1 b1 c1 d1) (T a2 b2 c2 d2) + = let j1 !a = let j2 !b = let j3 !c = let j4 !d = T a b c d + in j4 (inline m d1 d2) + in j3 (inline m c1 c2) + in j2 (inline m b1 b2) + in j1 (inline m a1 a2) +{-# OPAQUE f #-} ===================================== testsuite/tests/simplCore/should_compile/T22317b.stderr ===================================== @@ -0,0 +1,825 @@ +Considering inlining: $j_sEl + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 60 10 + case depth = 1 + depth based penalty = 0 + discounted size = 20 + ANSWER = YES +Considering inlining: $j_sEl + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 60 10 + case depth = 2 + depth based penalty = 0 + discounted size = 20 + ANSWER = YES +Considering inlining: $j_sEl + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 60 10 + case depth = 2 + depth based penalty = 0 + discounted size = 20 + ANSWER = YES +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 290 30 + case depth = 1 + depth based penalty = 0 + discounted size = 250 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 290 30 + case depth = 2 + depth based penalty = 0 + discounted size = 250 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 290 30 + case depth = 2 + depth based penalty = 0 + discounted size = 250 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 382 0 + case depth = 1 + depth based penalty = 0 + discounted size = 342 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 382 0 + case depth = 2 + depth based penalty = 0 + discounted size = 342 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 382 0 + case depth = 2 + depth based penalty = 0 + discounted size = 342 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 474 0 + case depth = 1 + depth based penalty = 0 + discounted size = 434 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 474 0 + case depth = 2 + depth based penalty = 0 + discounted size = 434 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 474 0 + case depth = 2 + depth based penalty = 0 + discounted size = 434 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 1 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 1 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 2 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 2 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 1 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 2 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 2 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 1 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 1 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 2 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 2 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 1 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 2 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 2 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 1 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 1 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 2 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 2 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 1 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 2 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 2 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 1 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 1 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 2 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 322 0 + case depth = 2 + depth based penalty = 0 + discounted size = 282 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 1 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 2 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 414 0 + case depth = 2 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 1 + depth based penalty = 0 + discounted size = 210 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance IF_ARGS [20] 312 0 + case depth = 1 + depth based penalty = 0 + discounted size = 292 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 312 0 + case depth = 2 + depth based penalty = 0 + discounted size = 272 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 312 0 + case depth = 2 + depth based penalty = 0 + discounted size = 272 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance IF_ARGS [20] 394 0 + case depth = 1 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 394 0 + case depth = 2 + depth based penalty = 0 + discounted size = 354 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 394 0 + case depth = 2 + depth based penalty = 0 + discounted size = 354 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 1 + depth based penalty = 0 + discounted size = 210 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 230 30 + case depth = 2 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance IF_ARGS [20] 312 0 + case depth = 1 + depth based penalty = 0 + discounted size = 292 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 312 0 + case depth = 2 + depth based penalty = 0 + discounted size = 272 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 312 0 + case depth = 2 + depth based penalty = 0 + discounted size = 272 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance IF_ARGS [20] 394 0 + case depth = 1 + depth based penalty = 0 + discounted size = 374 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 394 0 + case depth = 2 + depth based penalty = 0 + discounted size = 354 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 394 0 + case depth = 2 + depth based penalty = 0 + discounted size = 354 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance IF_ARGS [20] 210 30 + case depth = 1 + depth based penalty = 0 + discounted size = 190 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 210 30 + case depth = 2 + depth based penalty = 0 + discounted size = 170 + ANSWER = NO +Considering inlining: $j_sEm + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 210 30 + case depth = 2 + depth based penalty = 0 + discounted size = 170 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance IF_ARGS [20] 272 0 + case depth = 1 + depth based penalty = 0 + discounted size = 252 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 272 0 + case depth = 2 + depth based penalty = 0 + discounted size = 232 + ANSWER = NO +Considering inlining: $j_sEn + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 272 0 + case depth = 2 + depth based penalty = 0 + discounted size = 232 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance IF_ARGS [20] 334 0 + case depth = 1 + depth based penalty = 0 + discounted size = 314 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 334 0 + case depth = 2 + depth based penalty = 0 + discounted size = 294 + ANSWER = NO +Considering inlining: $j_sEo + arg infos [ValueArg] + interesting continuation BoringCtxt + some_benefit True + is exp: True + is work-free: True + guidance IF_ARGS [20] 334 0 + case depth = 2 + depth based penalty = 0 + discounted size = 294 + ANSWER = NO ===================================== testsuite/tests/simplCore/should_compile/T3717.stderr ===================================== @@ -14,7 +14,7 @@ T3717.$trModule4 = "main"# T3717.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T3717.$trModule3 = GHC.Types.TrNameS T3717.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T3717.$trModule2 = "T3717"# T3717.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T3717.$trModule1 = GHC.Types.TrNameS T3717.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3717.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T3717.$trModule = GHC.Types.Module T3717.$trModule3 T3717.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T3772.stdout ===================================== @@ -14,7 +14,7 @@ T3772.$trModule4 = "main"# T3772.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T3772.$trModule3 = GHC.Types.TrNameS T3772.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T3772.$trModule2 = "T3772"# T3772.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T3772.$trModule1 = GHC.Types.TrNameS T3772.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3772.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T3772.$trModule = GHC.Types.Module T3772.$trModule3 T3772.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T4908.stderr ===================================== @@ -14,7 +14,7 @@ T4908.$trModule4 = "main"# T4908.$trModule3 :: TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T4908.$trModule3 = GHC.Types.TrNameS T4908.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T4908.$trModule2 = "T4908"# T4908.$trModule1 :: TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T4908.$trModule1 = GHC.Types.TrNameS T4908.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T4908.$trModule :: Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T4908.$trModule = GHC.Types.Module T4908.$trModule3 T4908.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T4930.stderr ===================================== @@ -14,7 +14,7 @@ T4930.$trModule4 = "main"# T4930.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T4930.$trModule3 = GHC.Types.TrNameS T4930.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ T4930.$trModule2 = "T4930"# T4930.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T4930.$trModule1 = GHC.Types.TrNameS T4930.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T4930.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T4930.$trModule = GHC.Types.Module T4930.$trModule3 T4930.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -80,7 +80,7 @@ T7360.$trModule4 = "main"# T7360.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$trModule3 = GHC.Types.TrNameS T7360.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -94,14 +94,14 @@ T7360.$trModule2 = "T7360"# T7360.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$trModule1 = GHC.Types.TrNameS T7360.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7360.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T7360.$trModule = GHC.Types.Module T7360.$trModule3 T7360.$trModule1 @@ -123,14 +123,14 @@ T7360.$tcFoo2 = "Foo"# T7360.$tcFoo1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$tcFoo1 = GHC.Types.TrNameS T7360.$tcFoo2 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tcFoo :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}] T7360.$tcFoo = GHC.Types.TyCon 1581370841583180512#Word64 @@ -158,14 +158,14 @@ T7360.$tc'Foo6 = "'Foo1"# T7360.$tc'Foo5 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$tc'Foo5 = GHC.Types.TrNameS T7360.$tc'Foo6 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo1 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}] T7360.$tc'Foo1 = GHC.Types.TyCon 3986951253261644518#Word64 @@ -186,14 +186,14 @@ T7360.$tc'Foo8 = "'Foo2"# T7360.$tc'Foo7 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$tc'Foo7 = GHC.Types.TrNameS T7360.$tc'Foo8 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo2 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}] T7360.$tc'Foo2 = GHC.Types.TyCon 17325079864060690428#Word64 @@ -219,14 +219,14 @@ T7360.$tc'Foo11 = "'Foo3"# T7360.$tc'Foo10 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] T7360.$tc'Foo10 = GHC.Types.TrNameS T7360.$tc'Foo11 -- RHS size: {terms: 7, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo3 :: GHC.Types.TyCon [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 70 10}] T7360.$tc'Foo3 = GHC.Types.TyCon 3674231676522181654#Word64 ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -453,6 +453,10 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) # Should not inline m, so there shouldn't be a single YES test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m -ddebug-output']) +# Should not inline *any* join point, but after #22317 we still fail to come up +# with a good argument discount for the inner-most join point and hence inline it. +# It's important that we don't inline more, though! So 3 times YES is expected, but not more often +test('T22317b', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check \$j -ddebug-output']) test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T22491', normal, compile, ['-O2']) ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -14,7 +14,7 @@ Roman.$trModule4 = "main"# Roman.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] Roman.$trModule3 = GHC.Types.TrNameS Roman.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -28,14 +28,14 @@ Roman.$trModule2 = "Roman"# Roman.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] Roman.$trModule1 = GHC.Types.TrNameS Roman.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} Roman.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] Roman.$trModule = GHC.Types.Module Roman.$trModule3 Roman.$trModule1 @@ -129,14 +129,14 @@ Roman.foo_go Roman.foo2 :: Int [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] Roman.foo2 = GHC.Types.I# 6# -- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} Roman.foo1 :: Maybe Int [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 -- RHS size: {terms: 11, types: 4, coercions: 0, joins: 0/0} ===================================== testsuite/tests/stranal/should_compile/T20510.stderr ===================================== @@ -1,90 +1,55 @@ ==================== Exitification transformation ==================== Result size of Exitification transformation - = {terms: 50, types: 22, coercions: 0, joins: 2/2} + = {terms: 51, types: 23, coercions: 0, joins: 2/2} --- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} -lvl :: Int -[LclId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] -lvl = GHC.Types.I# 0# - --- RHS size: {terms: 32, types: 14, coercions: 0, joins: 2/2} -small :: Int -> Int -[LclIdX, +-- RHS size: {terms: 25, types: 10, coercions: 0, joins: 2/2} +$wsmall [InlPrag=[2]] :: GHC.Prim.Int# -> GHC.Prim.Int# +[LclId[StrictWorker([])], Arity=1, - Str=, - Cpr=1, - 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= \ (x [Dmd=SP(SL)] :: Int) -> - joinrec { - go [InlPrag=[2], Occ=T[2]] :: Int -> Int -> Int - [LclId[JoinId(2)], - Arity=2, - Str=, - Unf=Unf{Src=InlineStable, TopLvl=False, Value=True, ConLike=True, - WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (z [Occ=Once1!, Dmd=SP(L)] :: Int) - (ds [Occ=Once1!, Dmd=SP(SL)] :: Int) -> - case z of { GHC.Types.I# ww [Occ=Once1] -> - case ds of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> - jump $wgo ww ww - } - }}] - go (z [Occ=Once1!, Dmd=SP(L)] :: Int) - (ds [Occ=Once1!, Dmd=SP(SL)] :: Int) - = case z of { GHC.Types.I# ww [Occ=Once1] -> - case ds of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> - jump $wgo ww ww - } - }; - $wgo [InlPrag=[2], Occ=LoopBreakerT[2]] - :: GHC.Prim.Int# -> GHC.Prim.Int# -> Int - [LclId[JoinId(2)], - Arity=2, - Str=, - Unf=Unf{Src=, TopLvl=False, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 51] 69 10}] - $wgo (ww [Occ=Once2] :: GHC.Prim.Int#) - (ww [Occ=Once1!, Dmd=SL] :: GHC.Prim.Int#) - = case ww of ds { - __DEFAULT -> - jump go - (GHC.Types.I# (GHC.Prim.+# ww ds)) - (GHC.Types.I# (GHC.Prim.-# ds 1#)); - 0# -> - case x of { GHC.Types.I# y [Occ=Once1] -> - GHC.Types.I# (GHC.Prim.*# ww y) - } - }; } in - jump go lvl x}] -small - = \ (x [Dmd=SP(SL)] :: Int) -> + Str=, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 35 0}] +$wsmall + = \ (ww [Dmd=SL] :: GHC.Prim.Int#) -> join { - exit :: GHC.Prim.Int# -> Int - [LclId[JoinId(1)]] - exit (ww :: GHC.Prim.Int#) - = case x of { GHC.Types.I# y -> - GHC.Types.I# (GHC.Prim.*# ww y) - } } in + exit :: GHC.Prim.Int# -> GHC.Prim.Int# + [LclId[JoinId(1)(Nothing)]] + exit (ww :: GHC.Prim.Int#) = GHC.Prim.*# ww ww } in joinrec { $wgo [InlPrag=[2], Occ=LoopBreaker] - :: GHC.Prim.Int# -> GHC.Prim.Int# -> Int - [LclId[JoinId(2)], + :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# + [LclId[JoinId(2)(Just [])], Arity=2, Str=, Unf=Unf{Src=, TopLvl=False, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 38] 49 10}] + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=True)}] $wgo (ww :: GHC.Prim.Int#) (ww [Dmd=SL] :: GHC.Prim.Int#) = case ww of ds { __DEFAULT -> jump $wgo (GHC.Prim.+# ww ds) (GHC.Prim.-# ds 1#); 0# -> jump exit ww }; } in - case x of { GHC.Types.I# ww [Dmd=SL] -> jump $wgo 0# ww } + jump $wgo 0# ww + +-- RHS size: {terms: 10, types: 4, coercions: 0, joins: 0/0} +small [InlPrag=[2]] :: Int -> Int +[LclIdX, + Arity=1, + Str=, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (x [Occ=Once1!, Dmd=S!P(SL)] :: Int) -> + case x of { GHC.Types.I# ww [Occ=Once1, Dmd=SL] -> + case $wsmall ww of ww [Occ=Once1] { __DEFAULT -> GHC.Types.I# ww } + }}] +small + = \ (x [Dmd=S!P(SL)] :: Int) -> + case x of { GHC.Types.I# ww [Dmd=SL] -> + case $wsmall ww of ww { __DEFAULT -> GHC.Types.I# ww } + } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} $trModule :: GHC.Prim.Addr# @@ -97,7 +62,7 @@ $trModule = "main"# $trModule :: GHC.Types.TrName [LclId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] $trModule = GHC.Types.TrNameS $trModule -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -111,14 +76,14 @@ $trModule = "T20510"# $trModule :: GHC.Types.TrName [LclId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 10}] $trModule = GHC.Types.TrNameS $trModule -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T20510.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 10}] T20510.$trModule = GHC.Types.Module $trModule $trModule ===================================== testsuite/tests/stranal/should_compile/T21128.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 125, types: 68, coercions: 4, joins: 0/0} + = {terms: 124, types: 69, coercions: 4, joins: 1/1} lvl = "error"# @@ -48,12 +48,13 @@ index = \ l u i -> case l of { I# x -> case i of { I# y -> + join { $j = case u of { I# ww -> $wlvl y ww x } } in case <=# x y of { - __DEFAULT -> case u of { I# ww -> $wlvl y ww x }; + __DEFAULT -> jump $j; 1# -> case u of { I# y1 -> case <# y y1 of { - __DEFAULT -> $wlvl y y1 x; + __DEFAULT -> jump $j; 1# -> I# (-# y x) } } @@ -66,7 +67,7 @@ index ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 108, types: 46, coercions: 0, joins: 3/3} + = {terms: 107, types: 47, coercions: 0, joins: 4/5} $trModule4 = "main"# @@ -82,25 +83,27 @@ i = I# 1# l = I# 0# -lvl = \ x ww -> indexError $fShowInt x (I# ww) i +lvl = \ x y -> indexError $fShowInt x y i -lvl1 = \ ww -> indexError $fShowInt l (I# ww) l +lvl1 = \ y -> indexError $fShowInt l y l $wtheresCrud = \ ww ww1 -> + let { y = I# ww1 } in join { exit = case <# 0# ww1 of { - __DEFAULT -> case lvl1 ww1 of wild { }; + __DEFAULT -> case lvl1 y of wild { }; 1# -> 0# } } in join { exit1 - = case <=# ww 1# of { - __DEFAULT -> case lvl (I# ww) ww1 of wild { }; + = join { $j = case lvl (I# ww) y of wild { } } in + case <=# ww 1# of { + __DEFAULT -> jump $j; 1# -> case <# 1# ww1 of { - __DEFAULT -> case lvl (I# ww) ww1 of wild { }; + __DEFAULT -> jump $j; 1# -> -# 1# ww } } } in ===================================== testsuite/tests/typecheck/should_compile/T13032.stderr ===================================== @@ -16,7 +16,7 @@ f = \ (@a) (@b) _ [Occ=Dead] _ [Occ=Dead] _ [Occ=Dead] -> T13032.$trModule :: GHC.Types.Module [LclIdX, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 120 10}] T13032.$trModule = GHC.Types.Module (GHC.Types.TrNameS "main"#) (GHC.Types.TrNameS "T13032"#) ===================================== utils/check-exact/ExactPrint.hs ===================================== @@ -15,6 +15,7 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE BlockArguments #-} {-# LANGUAGE UndecidableInstances #-} -- For the (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ExactPrint instance +{-# OPTIONS_GHC -Wno-unused-matches -Wno-incomplete-uni-patterns #-} module ExactPrint ( View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e8398e79655fa8e82da7244796a2ed9ddfdb0e8...dc021331f99ee4b3e699350312f0aef27f4c6a47 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e8398e79655fa8e82da7244796a2ed9ddfdb0e8...dc021331f99ee4b3e699350312f0aef27f4c6a47 You're receiving 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 Dec 13 09:27:58 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Dec 2022 04:27:58 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Mark T21336a fragile Message-ID: <6398459e38066_389fe22d051f4221567@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - 44c55d64 by Sylvain Henry at 2022-12-13T04:27:51-05:00 JS: fix object file name comparison (#22578) - - - - - c974b14a by Bryan Richter at 2022-12-13T04:27:52-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 5 changed files: - compiler/GHC/Driver/Pipeline/Execute.hs - configure.ac - libraries/base/tests/IO/T21336/all.T - + testsuite/tests/simplCore/should_compile/T21476.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -388,7 +388,14 @@ runJsPhase pipe_env hsc_env input_fn = do -- ensure the timestamp is refreshed, see Note [JS Backend .o file procedure]. If -- they are not the same then we embed the .js file into a .o file with the -- addition of a header - if (input_fn /= output_fn) + -- + -- We need to canonicalize the paths, otherwise the comparison can return + -- wrong results (e.g. with Cabal using paths containing "build/./Foo/..." + -- that are compared to "build/Foo/..."). + -- + cin <- canonicalizePath input_fn + cout <- canonicalizePath output_fn + if (not (equalFilePath cin cout)) then embedJsFile logger dflags tmpfs unit_env input_fn output_fn else touchObjectFile logger dflags output_fn ===================================== configure.ac ===================================== @@ -224,7 +224,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.0" +MinBootGhcVersion="9.2" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) ===================================== libraries/base/tests/IO/T21336/all.T ===================================== @@ -1,6 +1,9 @@ # N.B. /dev/full exists on Darwin but cannot be opened, failing with -EPERM test('T21336a', - [unless(opsys('linux') or opsys('freebsd'), skip), js_broken(22261)], + [ unless(opsys('linux') or opsys('freebsd'), skip) + , js_broken(22261) + , fragile(22022) + ], compile_and_run, ['']) test('T21336b', [unless(opsys('linux') or opsys('freebsd'), skip), js_broken(22352)], ===================================== testsuite/tests/simplCore/should_compile/T21476.hs ===================================== @@ -0,0 +1,4 @@ +{-# LANGUAGE MagicHash #-} +module T21476 where +import GHC.Exts +f = keepAlive# ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -456,3 +456,4 @@ test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m - test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T22491', normal, compile, ['-O2']) +test('T21476', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/26edef7bde915be5481b1b42a1cbd1414538e57c...c974b14a92de0982a51c984433663e194fbfdc53 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/26edef7bde915be5481b1b42a1cbd1414538e57c...c974b14a92de0982a51c984433663e194fbfdc53 You're receiving 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 Dec 13 09:31:01 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 13 Dec 2022 04:31:01 -0500 Subject: [Git][ghc/ghc][wip/mp-9.4-backports] 17 commits: ApplicativeDo: Set pattern location before running exhaustiveness checker Message-ID: <63984655ef69e_389fe22d051f42269f9@gitlab.mail> Matthew Pickering pushed to branch wip/mp-9.4-backports at Glasgow Haskell Compiler / GHC Commits: 51c6051b by Matthew Pickering at 2022-12-13T09:30:47+00:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 (cherry picked from commit 74c767df770766d8d52e87b9ff7da10f94620a91) - - - - - 13040bf0 by Matthew Pickering at 2022-12-13T09:30:47+00:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 (cherry picked from commit 1d3a8b8ec98e6eedf8943e19780ec374c2491e7f) - - - - - 127dcc49 by Ian-Woo Kim at 2022-12-13T09:30:47+00:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. (cherry picked from commit 2057c77d08cb8422857d182a3691f98dccd0c7d6) - - - - - f84d7562 by Simon Peyton Jones at 2022-12-13T09:30:47+00:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! (cherry picked from commit afc2540daf6ca6baa09ab147b792da08d66d878c) - - - - - 8c85afe3 by sheaf at 2022-12-13T09:30:47+00:00 Fix @since annotations on WithDict and Coercible Fixes #22453 (cherry picked from commit 68c966cd3c9d581bac4573807e433fe8d063445f) - - - - - 7fbcb2c6 by Ben Gamari at 2022-12-13T09:30:47+00:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. (cherry picked from commit 268a3ce952f6be00a1dd164dc4d7acb346045e90) - - - - - ea7fb64d by Matthew Pickering at 2022-12-13T09:30:47+00:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 (cherry picked from commit 6dab0046b575e102bf3245fd63d5ac6bc6f4204d) - - - - - 5912ca80 by Ben Gamari at 2022-12-13T09:30:47+00:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. (cherry picked from commit a4dbd102af1989526ca87f4dd949f72231284e68) - - - - - f34261f3 by Ben Gamari at 2022-12-13T09:30:47+00:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. (cherry picked from commit 30f0d9a9ded55a822e094847d5ac8087262fb8da) - - - - - 3e648642 by Andreas Klebinger at 2022-12-13T09:30:47+00:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. (cherry picked from commit 31462d98c31e3ef48af2f6c6f2d379d74ccc63f5) - - - - - 7a40261f by Dai at 2022-12-13T09:30:47+00:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 (cherry picked from commit 5b3a992f5d166007c3c5a22f120ed08e0a27f01a) - - - - - 19d7a5fc by sheaf at 2022-12-13T09:30:47+00:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 (cherry picked from commit 6d7d91817795d7ee7f45557411368a1738daa488) - - - - - 2e778abc by sheaf at 2022-12-13T09:30:48+00:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. (cherry picked from commit 3be48877e204fca8e5d5ab984186e0d20d81f262) - - - - - 052dc022 by sheaf at 2022-12-13T09:30:48+00:00 Disable some SIMD tests on non-X86 architectures (cherry picked from commit f7b7a3122185222d5059e37315991afcf319e43c) - - - - - 3cc20a1a by Andreas Klebinger at 2022-12-13T09:30:48+00:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. (cherry picked from commit 8d2dbe2db4cc7c8b6d39b1ea64b0508304a3273c) - - - - - fcce6b7e by Simon Peyton Jones at 2022-12-13T09:30:48+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 (cherry picked from commit 294f907370fadd3313f8c5e6aa87a93c8b86f139) - - - - - c43e5681 by Gabriella Gonzalez at 2022-12-13T09:30:48+00:00 Serialize builds of `rts` and `system-cxx-std-lib` Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/22099 I cannot say for sure that this will fix the linked issue, but I explained why I believe this fixes the root problem in: https://gitlab.haskell.org/ghc/ghc/-/issues/22099#note_461386 … and when we applied this patch internally the problem appeared to disappear for a few builds in a row with a large number of cores. The short summary of the above comment is that the `Makefile` serializes the package registrations using `ghc-pkgs`, with the exception of two packages (`rts` and `system-cxx-std-lib`) and we expect that this one instance of parallelism that was still left in the `Makefile` was the root cause of the flaky build failure. This fix would be consistent with two known things about the failure: - The build failure only occurs for parallel `Make` builds … and these are the only two `ghc-pkg` calls that run concurrently - The error first appeared in the GHC 9.4 branch and was absent in GHC 9.2 … and GHC 9.4 was the first release that included `system-cxx-std-lib` (as far as I know), which would explain why this problem didn't happen before. The change here forces the two packages to be registered in sequence. This problem will of course go away in GHC 9.6 by virtue of dropping the `make`-based build, but since the GHC 9.4 branch is supported and active we wanted to upstream this patch to the 9.4 development branch. - - - - - 30 changed files: - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Linker/Windows.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Process.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Utils/Outputable.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - ghc.mk - libraries/base/Data/Coerce.hs - libraries/base/GHC/Exts.hs - libraries/ghc-prim/GHC/Magic/Dict.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/-/compare/62366a6a1b751c820359d988eec1b2c2197e891f...c43e56810a8a2b43a8947221ee1e3d50d638fc9a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62366a6a1b751c820359d988eec1b2c2197e891f...c43e56810a8a2b43a8947221ee1e3d50d638fc9a You're receiving 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 Dec 13 11:33:21 2022 From: gitlab at gitlab.haskell.org (Ryan Scott (@RyanGlScott)) Date: Tue, 13 Dec 2022 06:33:21 -0500 Subject: [Git][ghc/ghc][wip/T22570] checkValidInst: Don't expand synonyms when splitting sigma types Message-ID: <63986301871e8_389fe25267025534a@gitlab.mail> Ryan Scott pushed to branch wip/T22570 at Glasgow Haskell Compiler / GHC Commits: 21a7d83f by Ryan Scott at 2022-12-13T06:32:59-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 4 changed files: - compiler/GHC/Tc/Validity.hs - + testsuite/tests/typecheck/should_fail/T22570.hs - + testsuite/tests/typecheck/should_fail/T22570.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -61,7 +61,7 @@ import GHC.Types.Basic ( UnboxedTupleOrSum(..), unboxedTupleOrSumExtension ) import GHC.Types.Name import GHC.Types.Var.Env import GHC.Types.Var.Set -import GHC.Types.Var ( VarBndr(..), mkTyVar ) +import GHC.Types.Var ( VarBndr(..), isInvisibleFunArg, mkTyVar ) import GHC.Utils.FV import GHC.Utils.Error import GHC.Driver.Session @@ -1731,6 +1731,13 @@ the instance head, we'll expand the synonym on fly, and it'll look like instance (%,%) (Show Int, Show Int) and we /really/ don't want that. So we carefully do /not/ expand synonyms, by matching on TyConApp directly. + +For similar reasons, we do not use tcSplitSigmaTy when decomposing the instance +context, as the looks through type synonyms. If we looked through type +synonyms, then it could be possible to write an instance for a type synonym +involving a quantified constraint (see #22570). Instead, we define +splitInstTyForValidity, a specialized version of tcSplitSigmaTy (local to +GHC.Tc.Validity) that does not expand type synonyms. -} checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM () @@ -1774,11 +1781,31 @@ checkValidInstance ctxt hs_type ty = case tau of ; return () } _ -> failWithTc (TcRnNoClassInstHead tau) where - (_tvs, theta, tau) = tcSplitSigmaTy ty + (theta, tau) = splitInstTyForValidity ty -- The location of the "head" of the instance head_loc = getLoc (getLHsInstDeclHead hs_type) +-- | Split an instance type of the form @forall tvbs. inst_ctxt => inst_head@ +-- and return @(inst_ctxt, inst_head)@. This function makes no attempt to look +-- through type synonyms. See @Note [Instances and constraint synonyms]@. +splitInstTyForValidity :: Type -> (ThetaType, Type) +splitInstTyForValidity = split_context [] . drop_foralls + where + -- This is like 'dropForAlls', except that it does not look through type + -- synonyms. + drop_foralls :: Type -> Type + drop_foralls (ForAllTy (Bndr _tv argf) ty) + | isInvisibleForAllTyFlag argf = drop_foralls ty + drop_foralls ty = ty + + -- This is like 'tcSplitPhiTy', except that it does not look through type + -- synonyms. + split_context :: ThetaType -> Type -> (ThetaType, Type) + split_context preds (FunTy { ft_af = af, ft_arg = pred, ft_res = tau }) + | isInvisibleFunArg af = split_context (pred:preds) tau + split_context preds ty = (reverse preds, ty) + {- Note [Paterson conditions] ~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== testsuite/tests/typecheck/should_fail/T22570.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module T22570 where + +import Data.Kind + +class SomeClass a +class OtherClass + +type SomeClassUnit = OtherClass => SomeClass () :: Constraint + +instance SomeClassUnit + +type SomeClassSyn a = OtherClass => SomeClass a :: Constraint + +instance SomeClassSyn () ===================================== testsuite/tests/typecheck/should_fail/T22570.stderr ===================================== @@ -0,0 +1,10 @@ + +T22570.hs:11:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassUnit’ + +T22570.hs:15:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassSyn ()’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -665,3 +665,4 @@ test('MissingDefaultMethodBinding', normal, compile_fail, ['']) test('T21447', normal, compile_fail, ['']) test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) +test('T22570', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21a7d83f6d48d970cb823730bc89561494d3e5af -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21a7d83f6d48d970cb823730bc89561494d3e5af You're receiving 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 Dec 13 11:42:06 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 13 Dec 2022 06:42:06 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/t22371 Message-ID: <6398650edceab_389fe2ec1afd026479d@gitlab.mail> Matthew Pickering pushed new branch wip/t22371 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t22371 You're receiving 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 Dec 13 12:27:06 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 13 Dec 2022 07:27:06 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22459 Message-ID: <63986f9a5a91a_389fe21069f4f02845c5@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22459 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22459 You're receiving 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 Dec 13 13:33:23 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 13 Dec 2022 08:33:23 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/break-leak Message-ID: <63987f2382a86_389fe211e622e0295521@gitlab.mail> Zubin pushed new branch wip/break-leak at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/break-leak You're receiving 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 Dec 13 14:57:25 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 13 Dec 2022 09:57:25 -0500 Subject: [Git][ghc/ghc][wip/T22547] 34 commits: Add test for #22162 Message-ID: <639892d5ae5b2_389fe213cfc98031734c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22547 at Glasgow Haskell Compiler / GHC Commits: 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - 5a547a40 by Simon Peyton Jones at 2022-12-13T14:57:16+00:00 Fix bogus test in Lint The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.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/Opt/DmdAnal.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Lit.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Platform.hs - + compiler/GHC/Platform/LoongArch64.hs - compiler/GHC/Platform/Regs.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Types/SourceText.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c45f5dd6017059037b7f2db33f75a3a16cc59f5...5a547a406ba5021e51125fa165dc961c3a6ad727 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c45f5dd6017059037b7f2db33f75a3a16cc59f5...5a547a406ba5021e51125fa165dc961c3a6ad727 You're receiving 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 Dec 13 18:48:32 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Dec 2022 13:48:32 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Respect -XStrict in the pattern-match checker (#21761) Message-ID: <6398c900c04e2_389fe2161ceccc40688d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: abffa776 by Sebastian Graf at 2022-12-13T13:48:16-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - f85fe645 by Gergő Érdi at 2022-12-13T13:48:17-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 36f8b134 by Alan Zimmerman at 2022-12-13T13:48:17-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - ae463075 by Sylvain Henry at 2022-12-13T13:48:25-05:00 JS: fix object file name comparison (#22578) - - - - - 71da8293 by Bryan Richter at 2022-12-13T13:48:25-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser/Lexer.x - configure.ac - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - testsuite/tests/parser/should_compile/DumpParsedAstComments.hs - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr - + testsuite/tests/pmcheck/should_compile/T21761.hs - + testsuite/tests/pmcheck/should_compile/T21761.stderr - testsuite/tests/pmcheck/should_compile/all.T - testsuite/tests/printer/Ppr031.hs - + testsuite/tests/simplCore/should_compile/T22272.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c974b14a92de0982a51c984433663e194fbfdc53...71da829377c50062b2499910be7d219036ad6adc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c974b14a92de0982a51c984433663e194fbfdc53...71da829377c50062b2499910be7d219036ad6adc You're receiving 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 Dec 13 23:31:39 2022 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 13 Dec 2022 18:31:39 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/az/epa-eof-annsmodule Message-ID: <63990b5b14a92_389fe25265c450083@gitlab.mail> Alan Zimmerman pushed new branch wip/az/epa-eof-annsmodule at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/epa-eof-annsmodule You're receiving 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 Dec 14 00:09:30 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 13 Dec 2022 19:09:30 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.6] 38 commits: Add test for #22162 Message-ID: <6399143ad3770_389fe218b96e4c452612@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - ec092181 by Ben Gamari at 2022-12-13T19:09:18-05:00 base: Bump version to 4.18 - - - - - 429afd3b by Ben Gamari at 2022-12-13T19:09:18-05:00 configure: Bump GHC version to 9.6 - - - - - 4365ba4c by Ben Gamari at 2022-12-13T19:09:18-05:00 ghc-boot: Fix bootstrapping - - - - - b0dab09f by Ben Gamari at 2022-12-13T19:09:18-05:00 rts/ipe: Fix unused lock warning - - - - - 6999248a by Ben Gamari at 2022-12-13T19:09:18-05:00 configure: Bump minimum bootstrap compiler version - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Hs/Lit.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Platform.hs - + compiler/GHC/Platform/LoongArch64.hs - compiler/GHC/Platform/Regs.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Types/SourceText.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/exts/misc.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3461eb5df39e16f59d1bde5fd857f8bffd7fb622...6999248ae6c19508070a2f794ef626914cd2c67f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3461eb5df39e16f59d1bde5fd857f8bffd7fb622...6999248ae6c19508070a2f794ef626914cd2c67f You're receiving 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 Dec 14 00:15:02 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 13 Dec 2022 19:15:02 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.6] 5 commits: base: Bump version to 4.18 Message-ID: <63991586aa9c6_389fe2527104532a2@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: a967983f by Ben Gamari at 2022-12-13T19:14:47-05:00 base: Bump version to 4.18 - - - - - af9dc283 by Ben Gamari at 2022-12-13T19:14:47-05:00 configure: Bump GHC version to 9.6 - - - - - 1843139e by Ben Gamari at 2022-12-13T19:14:48-05:00 ghc-boot: Fix bootstrapping - - - - - 2f9591e8 by Ben Gamari at 2022-12-13T19:14:48-05:00 rts/ipe: Fix unused lock warning - - - - - c204d14d by Ben Gamari at 2022-12-13T19:14:48-05:00 configure: Bump minimum bootstrap compiler version - - - - - 25 changed files: - compiler/ghc.cabal.in - configure.ac - libraries/array - libraries/base/base.cabal - libraries/deepseq - libraries/directory - libraries/filepath - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/GHC/Utils/Encoding/UTF8.hs - 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 - rts/IPE.c - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - testsuite/tests/cabal/t18567/T18567.stderr - utils/haddock - utils/hsc2hs Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -76,7 +76,7 @@ Library if flag(build-tool-depends) build-tool-depends: alex:alex >= 3.2.6, happy:happy >= 1.20.0, genprimopcode:genprimopcode, deriveConstants:deriveConstants - Build-Depends: base >= 4.11 && < 4.18, + Build-Depends: base >= 4.11 && < 4.19, deepseq >= 1.4 && < 1.5, directory >= 1 && < 1.4, process >= 1 && < 1.7, ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.5], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.6], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are @@ -224,7 +224,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.0" +MinBootGhcVersion="9.2" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) ===================================== libraries/array ===================================== @@ -1 +1 @@ -Subproject commit acd92ba77c205a039d9c6eaabb3e35d09e330160 +Subproject commit f7a498b880a1fff833699d8417bac155d58ed59e ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.0.0 +version: 4.18.0.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/deepseq ===================================== @@ -1 +1 @@ -Subproject commit 28f4d5b00448239581ead0de9140ff4a6847c806 +Subproject commit 7e77698d6a78981bc2649df78021a6c33a5d3913 ===================================== libraries/directory ===================================== @@ -1 +1 @@ -Subproject commit b33c1087d746389a687be42aa1fb73c12e3885d3 +Subproject commit 7f9066137c694ab7cef9a4ebd8c19a281fad42e4 ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit 872e19fce06ddd40bd0771dbd3cad2c3c6ed5e7d +Subproject commit 62c589aaaf731cb5a0274dbf2060c37a5c13cecc ===================================== 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.18 + build-depends: base >= 4.7 && < 4.19 ===================================== libraries/ghc-boot/GHC/Utils/Encoding/UTF8.hs ===================================== @@ -44,17 +44,20 @@ module GHC.Utils.Encoding.UTF8 import Prelude import Foreign +import GHC.IO +#if MIN_VERSION_base(4,18,0) +import GHC.Encoding.UTF8 +#else import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) import Data.Char -import GHC.IO +import GHC.Exts import GHC.ST +#endif import Data.ByteString (ByteString) import qualified Data.ByteString.Internal as BS import Data.ByteString.Short.Internal (ShortByteString(..)) -import GHC.Exts - -- | Find the start of the codepoint preceding the codepoint at the given -- 'Ptr'. This is undefined if there is no previous valid codepoint. utf8PrevChar :: Ptr Word8 -> IO (Ptr Word8) ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -70,7 +70,7 @@ Library GHC.Version GHC.Platform.Host - build-depends: base >= 4.7 && < 4.18, + build-depends: base >= 4.7 && < 4.19, binary == 0.8.*, bytestring >= 0.10 && < 0.12, containers >= 0.5 && < 0.7, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -40,7 +40,7 @@ library CPP build-depends: ghc-prim >= 0.5.3 && < 0.11, - base >= 4.9.0 && < 4.18, + base >= 4.9.0 && < 4.19, bytestring >= 0.10.6.0 && <0.12 ghc-options: -Wall ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -70,7 +70,7 @@ library Build-Depends: rts, array == 0.5.*, - base >= 4.8 && < 4.18, + base >= 4.8 && < 4.19, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, bytestring >= 0.10 && < 0.12, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit d4f343509e905a717ea463ad84462c126d8990d8 +Subproject commit 3b9f9260239f88309c78096cae3018f87d68a1f1 ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 76d1a0473d405e194d0c92a1cbeb6c019bbb57cd +Subproject commit 622595962acc1b07eaba4574c21375927579d189 ===================================== libraries/parsec ===================================== @@ -1 +1 @@ -Subproject commit f1171a4b212070bb0299b636aeee7d0534a6c76c +Subproject commit 0e23b3246fd7f6d125129316dcbedd609e6d2dca ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit cb89d5079d29c38683bcb6feec7dc53ad3836ed0 +Subproject commit 7c6871d89bd87875b4e402de26d7267c11e617a9 ===================================== libraries/stm ===================================== @@ -1 +1 @@ -Subproject commit f4eb5a85c2732f8f5a03ef8af88d6aff90945415 +Subproject commit 4ac6ead642829c9c983ee3c96ba13fa0308891ff ===================================== libraries/template-haskell/template-haskell.cabal.in ===================================== @@ -55,7 +55,7 @@ Library Language.Haskell.TH.Lib.Map build-depends: - base >= 4.11 && < 4.18, + base >= 4.11 && < 4.19, ghc-boot-th == @ProjectVersionMunged@, ghc-prim, pretty == 1.1.* ===================================== libraries/terminfo ===================================== @@ -1 +1 @@ -Subproject commit a21cc7e2d58f3e35a4ac3fb386738d9b448eaf13 +Subproject commit 0a05f06bc8a56c43578ce06d4ef1339ee70fb3fc ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 3be0223cee7395410915a127eba3acae5ff0b2f2 +Subproject commit 7d961bbfd60b27e6d893ded80d9eff354729556a ===================================== rts/IPE.c ===================================== @@ -57,7 +57,10 @@ this all IPE lists of all IpeBufferListNode are traversed to insert all IPEs. After the content of a IpeBufferListNode has been inserted, it's freed. */ +#if defined(THREADED_RTS) static Mutex ipeMapLock; +#endif +// Protected by ipeMapLock static HashTable *ipeMap = NULL; // Accessed atomically ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-4ArNecmPyDqFgQMPsq5SEg-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-3A0ecVFOxAgF5zqWrGYPfn-p ===================================== testsuite/tests/cabal/t18567/T18567.stderr ===================================== @@ -2,4 +2,4 @@ : warning: [GHC-42258] [-Wunused-packages] The following packages were specified via -package or -package-id flags, but were not needed for compilation: - - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-Dq740EWYmHcKhGKUMfjfaX-sublib-unused) + - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-1v10MAkotpbGWvaODnEeBc-sublib-unused) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit edc72530978d8a9ec92f51d288484986ec0051e3 +Subproject commit 37e3c3683ac70735ab211f59210c9abea8ae2c69 ===================================== utils/hsc2hs ===================================== @@ -1 +1 @@ -Subproject commit ac11465d9aadbe24be4832a3775fbd4344484402 +Subproject commit 219bba062e804db0bea4bf3ffcaaba2df46334f8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6999248ae6c19508070a2f794ef626914cd2c67f...c204d14dfe190d0f9a4d4dba3ffb1951587f8da0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6999248ae6c19508070a2f794ef626914cd2c67f...c204d14dfe190d0f9a4d4dba3ffb1951587f8da0 You're receiving 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 Dec 14 00:18:37 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 13 Dec 2022 19:18:37 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.6] 5 commits: base: Bump version to 4.18 Message-ID: <6399165dbd226_389fe2161ceccc454015@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: c1581944 by Ben Gamari at 2022-12-13T19:18:22-05:00 base: Bump version to 4.18 - - - - - beebd902 by Ben Gamari at 2022-12-13T19:18:22-05:00 configure: Bump GHC version to 9.6 - - - - - acb35e00 by Ben Gamari at 2022-12-13T19:18:22-05:00 ghc-boot: Fix bootstrapping - - - - - 475341dd by Ben Gamari at 2022-12-13T19:18:22-05:00 rts/ipe: Fix unused lock warning - - - - - bcac39ce by Ben Gamari at 2022-12-13T19:18:22-05:00 configure: Bump minimum bootstrap compiler version - - - - - 24 changed files: - compiler/ghc.cabal.in - configure.ac - libraries/array - libraries/base/base.cabal - libraries/deepseq - libraries/directory - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/GHC/Utils/Encoding/UTF8.hs - 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 - rts/IPE.c - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - testsuite/tests/cabal/t18567/T18567.stderr - utils/haddock - utils/hsc2hs Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -76,7 +76,7 @@ Library if flag(build-tool-depends) build-tool-depends: alex:alex >= 3.2.6, happy:happy >= 1.20.0, genprimopcode:genprimopcode, deriveConstants:deriveConstants - Build-Depends: base >= 4.11 && < 4.18, + Build-Depends: base >= 4.11 && < 4.19, deepseq >= 1.4 && < 1.5, directory >= 1 && < 1.4, process >= 1 && < 1.7, ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.5], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.6], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are @@ -224,7 +224,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.0" +MinBootGhcVersion="9.2" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) ===================================== libraries/array ===================================== @@ -1 +1 @@ -Subproject commit acd92ba77c205a039d9c6eaabb3e35d09e330160 +Subproject commit f7a498b880a1fff833699d8417bac155d58ed59e ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.0.0 +version: 4.18.0.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/deepseq ===================================== @@ -1 +1 @@ -Subproject commit 28f4d5b00448239581ead0de9140ff4a6847c806 +Subproject commit 7e77698d6a78981bc2649df78021a6c33a5d3913 ===================================== libraries/directory ===================================== @@ -1 +1 @@ -Subproject commit b33c1087d746389a687be42aa1fb73c12e3885d3 +Subproject commit 7f9066137c694ab7cef9a4ebd8c19a281fad42e4 ===================================== 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.18 + build-depends: base >= 4.7 && < 4.19 ===================================== libraries/ghc-boot/GHC/Utils/Encoding/UTF8.hs ===================================== @@ -44,17 +44,20 @@ module GHC.Utils.Encoding.UTF8 import Prelude import Foreign +import GHC.IO +#if MIN_VERSION_base(4,18,0) +import GHC.Encoding.UTF8 +#else import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) import Data.Char -import GHC.IO +import GHC.Exts import GHC.ST +#endif import Data.ByteString (ByteString) import qualified Data.ByteString.Internal as BS import Data.ByteString.Short.Internal (ShortByteString(..)) -import GHC.Exts - -- | Find the start of the codepoint preceding the codepoint at the given -- 'Ptr'. This is undefined if there is no previous valid codepoint. utf8PrevChar :: Ptr Word8 -> IO (Ptr Word8) ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -70,7 +70,7 @@ Library GHC.Version GHC.Platform.Host - build-depends: base >= 4.7 && < 4.18, + build-depends: base >= 4.7 && < 4.19, binary == 0.8.*, bytestring >= 0.10 && < 0.12, containers >= 0.5 && < 0.7, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -40,7 +40,7 @@ library CPP build-depends: ghc-prim >= 0.5.3 && < 0.11, - base >= 4.9.0 && < 4.18, + base >= 4.9.0 && < 4.19, bytestring >= 0.10.6.0 && <0.12 ghc-options: -Wall ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -70,7 +70,7 @@ library Build-Depends: rts, array == 0.5.*, - base >= 4.8 && < 4.18, + base >= 4.8 && < 4.19, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, bytestring >= 0.10 && < 0.12, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit d4f343509e905a717ea463ad84462c126d8990d8 +Subproject commit 3b9f9260239f88309c78096cae3018f87d68a1f1 ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 76d1a0473d405e194d0c92a1cbeb6c019bbb57cd +Subproject commit 622595962acc1b07eaba4574c21375927579d189 ===================================== libraries/parsec ===================================== @@ -1 +1 @@ -Subproject commit f1171a4b212070bb0299b636aeee7d0534a6c76c +Subproject commit 0e23b3246fd7f6d125129316dcbedd609e6d2dca ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit cb89d5079d29c38683bcb6feec7dc53ad3836ed0 +Subproject commit 7c6871d89bd87875b4e402de26d7267c11e617a9 ===================================== libraries/stm ===================================== @@ -1 +1 @@ -Subproject commit f4eb5a85c2732f8f5a03ef8af88d6aff90945415 +Subproject commit 4ac6ead642829c9c983ee3c96ba13fa0308891ff ===================================== libraries/template-haskell/template-haskell.cabal.in ===================================== @@ -55,7 +55,7 @@ Library Language.Haskell.TH.Lib.Map build-depends: - base >= 4.11 && < 4.18, + base >= 4.11 && < 4.19, ghc-boot-th == @ProjectVersionMunged@, ghc-prim, pretty == 1.1.* ===================================== libraries/terminfo ===================================== @@ -1 +1 @@ -Subproject commit a21cc7e2d58f3e35a4ac3fb386738d9b448eaf13 +Subproject commit 0a05f06bc8a56c43578ce06d4ef1339ee70fb3fc ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 3be0223cee7395410915a127eba3acae5ff0b2f2 +Subproject commit 7d961bbfd60b27e6d893ded80d9eff354729556a ===================================== rts/IPE.c ===================================== @@ -57,7 +57,10 @@ this all IPE lists of all IpeBufferListNode are traversed to insert all IPEs. After the content of a IpeBufferListNode has been inserted, it's freed. */ +#if defined(THREADED_RTS) static Mutex ipeMapLock; +#endif +// Protected by ipeMapLock static HashTable *ipeMap = NULL; // Accessed atomically ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-4ArNecmPyDqFgQMPsq5SEg-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-3A0ecVFOxAgF5zqWrGYPfn-p ===================================== testsuite/tests/cabal/t18567/T18567.stderr ===================================== @@ -2,4 +2,4 @@ : warning: [GHC-42258] [-Wunused-packages] The following packages were specified via -package or -package-id flags, but were not needed for compilation: - - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-Dq740EWYmHcKhGKUMfjfaX-sublib-unused) + - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-1v10MAkotpbGWvaODnEeBc-sublib-unused) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit edc72530978d8a9ec92f51d288484986ec0051e3 +Subproject commit 37e3c3683ac70735ab211f59210c9abea8ae2c69 ===================================== utils/hsc2hs ===================================== @@ -1 +1 @@ -Subproject commit ac11465d9aadbe24be4832a3775fbd4344484402 +Subproject commit 219bba062e804db0bea4bf3ffcaaba2df46334f8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c204d14dfe190d0f9a4d4dba3ffb1951587f8da0...bcac39ce4685325613807746832ea972f5f51885 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c204d14dfe190d0f9a4d4dba3ffb1951587f8da0...bcac39ce4685325613807746832ea972f5f51885 You're receiving 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 Dec 14 00:26:32 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 13 Dec 2022 19:26:32 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.6] 5 commits: base: Bump version to 4.18 Message-ID: <6399183890903_389fe218b96e4c454891@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 120abb78 by Ben Gamari at 2022-12-13T19:26:18-05:00 base: Bump version to 4.18 - - - - - 13442c35 by Ben Gamari at 2022-12-13T19:26:18-05:00 configure: Bump GHC version to 9.6 - - - - - fdb3ae79 by Ben Gamari at 2022-12-13T19:26:18-05:00 ghc-boot: Fix bootstrapping - - - - - af5b7173 by Ben Gamari at 2022-12-13T19:26:18-05:00 rts/ipe: Fix unused lock warning - - - - - c97b2a26 by Ben Gamari at 2022-12-13T19:26:18-05:00 configure: Bump minimum bootstrap compiler version - - - - - 24 changed files: - compiler/ghc.cabal.in - configure.ac - libraries/array - libraries/base/base.cabal - libraries/deepseq - libraries/directory - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/GHC/Utils/Encoding/UTF8.hs - 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 - rts/IPE.c - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - testsuite/tests/cabal/t18567/T18567.stderr - utils/haddock - utils/hsc2hs Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -76,7 +76,7 @@ Library if flag(build-tool-depends) build-tool-depends: alex:alex >= 3.2.6, happy:happy >= 1.20.0, genprimopcode:genprimopcode, deriveConstants:deriveConstants - Build-Depends: base >= 4.11 && < 4.18, + Build-Depends: base >= 4.11 && < 4.19, deepseq >= 1.4 && < 1.5, directory >= 1 && < 1.4, process >= 1 && < 1.7, ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.5], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.6], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are @@ -224,7 +224,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.0" +MinBootGhcVersion="9.2" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) ===================================== libraries/array ===================================== @@ -1 +1 @@ -Subproject commit acd92ba77c205a039d9c6eaabb3e35d09e330160 +Subproject commit f7a498b880a1fff833699d8417bac155d58ed59e ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.0.0 +version: 4.18.0.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/deepseq ===================================== @@ -1 +1 @@ -Subproject commit 28f4d5b00448239581ead0de9140ff4a6847c806 +Subproject commit 7e77698d6a78981bc2649df78021a6c33a5d3913 ===================================== libraries/directory ===================================== @@ -1 +1 @@ -Subproject commit b33c1087d746389a687be42aa1fb73c12e3885d3 +Subproject commit 7f9066137c694ab7cef9a4ebd8c19a281fad42e4 ===================================== 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.18 + build-depends: base >= 4.7 && < 4.19 ===================================== libraries/ghc-boot/GHC/Utils/Encoding/UTF8.hs ===================================== @@ -44,17 +44,20 @@ module GHC.Utils.Encoding.UTF8 import Prelude import Foreign +import GHC.IO +#if MIN_VERSION_base(4,18,0) +import GHC.Encoding.UTF8 +#else import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) import Data.Char -import GHC.IO +import GHC.Exts import GHC.ST +#endif import Data.ByteString (ByteString) import qualified Data.ByteString.Internal as BS import Data.ByteString.Short.Internal (ShortByteString(..)) -import GHC.Exts - -- | Find the start of the codepoint preceding the codepoint at the given -- 'Ptr'. This is undefined if there is no previous valid codepoint. utf8PrevChar :: Ptr Word8 -> IO (Ptr Word8) ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -70,7 +70,7 @@ Library GHC.Version GHC.Platform.Host - build-depends: base >= 4.7 && < 4.18, + build-depends: base >= 4.7 && < 4.19, binary == 0.8.*, bytestring >= 0.10 && < 0.12, containers >= 0.5 && < 0.7, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -40,7 +40,7 @@ library CPP build-depends: ghc-prim >= 0.5.3 && < 0.11, - base >= 4.9.0 && < 4.18, + base >= 4.9.0 && < 4.19, bytestring >= 0.10.6.0 && <0.12 ghc-options: -Wall ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -70,7 +70,7 @@ library Build-Depends: rts, array == 0.5.*, - base >= 4.8 && < 4.18, + base >= 4.8 && < 4.19, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, bytestring >= 0.10 && < 0.12, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit d4f343509e905a717ea463ad84462c126d8990d8 +Subproject commit 3b9f9260239f88309c78096cae3018f87d68a1f1 ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 76d1a0473d405e194d0c92a1cbeb6c019bbb57cd +Subproject commit 622595962acc1b07eaba4574c21375927579d189 ===================================== libraries/parsec ===================================== @@ -1 +1 @@ -Subproject commit f1171a4b212070bb0299b636aeee7d0534a6c76c +Subproject commit 0e23b3246fd7f6d125129316dcbedd609e6d2dca ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit cb89d5079d29c38683bcb6feec7dc53ad3836ed0 +Subproject commit 7c6871d89bd87875b4e402de26d7267c11e617a9 ===================================== libraries/stm ===================================== @@ -1 +1 @@ -Subproject commit f4eb5a85c2732f8f5a03ef8af88d6aff90945415 +Subproject commit 4ac6ead642829c9c983ee3c96ba13fa0308891ff ===================================== libraries/template-haskell/template-haskell.cabal.in ===================================== @@ -55,7 +55,7 @@ Library Language.Haskell.TH.Lib.Map build-depends: - base >= 4.11 && < 4.18, + base >= 4.11 && < 4.19, ghc-boot-th == @ProjectVersionMunged@, ghc-prim, pretty == 1.1.* ===================================== libraries/terminfo ===================================== @@ -1 +1 @@ -Subproject commit a21cc7e2d58f3e35a4ac3fb386738d9b448eaf13 +Subproject commit 0a05f06bc8a56c43578ce06d4ef1339ee70fb3fc ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 3be0223cee7395410915a127eba3acae5ff0b2f2 +Subproject commit 98adc732bfbfca4fef945d546ecbaae13952a950 ===================================== rts/IPE.c ===================================== @@ -57,7 +57,10 @@ this all IPE lists of all IpeBufferListNode are traversed to insert all IPEs. After the content of a IpeBufferListNode has been inserted, it's freed. */ +#if defined(THREADED_RTS) static Mutex ipeMapLock; +#endif +// Protected by ipeMapLock static HashTable *ipeMap = NULL; // Accessed atomically ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-4ArNecmPyDqFgQMPsq5SEg-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-3A0ecVFOxAgF5zqWrGYPfn-p ===================================== testsuite/tests/cabal/t18567/T18567.stderr ===================================== @@ -2,4 +2,4 @@ : warning: [GHC-42258] [-Wunused-packages] The following packages were specified via -package or -package-id flags, but were not needed for compilation: - - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-Dq740EWYmHcKhGKUMfjfaX-sublib-unused) + - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-1v10MAkotpbGWvaODnEeBc-sublib-unused) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit edc72530978d8a9ec92f51d288484986ec0051e3 +Subproject commit 37e3c3683ac70735ab211f59210c9abea8ae2c69 ===================================== utils/hsc2hs ===================================== @@ -1 +1 @@ -Subproject commit ac11465d9aadbe24be4832a3775fbd4344484402 +Subproject commit 219bba062e804db0bea4bf3ffcaaba2df46334f8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bcac39ce4685325613807746832ea972f5f51885...c97b2a2655ff6a454f78289883f73412c2e74152 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bcac39ce4685325613807746832ea972f5f51885...c97b2a2655ff6a454f78289883f73412c2e74152 You're receiving 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 Dec 14 01:52:48 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 13 Dec 2022 20:52:48 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.6] 5 commits: base: Bump version to 4.18 Message-ID: <63992c709f24d_389fe25267046223d@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 097aa31c by Ben Gamari at 2022-12-13T20:52:33-05:00 base: Bump version to 4.18 - - - - - 9fba5471 by Ben Gamari at 2022-12-13T20:52:33-05:00 configure: Bump GHC version to 9.6 - - - - - fddba717 by Ben Gamari at 2022-12-13T20:52:33-05:00 ghc-boot: Fix bootstrapping - - - - - cffd13c5 by Ben Gamari at 2022-12-13T20:52:33-05:00 rts/ipe: Fix unused lock warning - - - - - 7e400d46 by Ben Gamari at 2022-12-13T20:52:33-05:00 configure: Bump minimum bootstrap compiler version - - - - - 25 changed files: - compiler/ghc.cabal.in - configure.ac - libraries/array - libraries/base/base.cabal - libraries/deepseq - libraries/directory - libraries/filepath - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/GHC/Utils/Encoding/UTF8.hs - 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 - rts/IPE.c - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - testsuite/tests/cabal/t18567/T18567.stderr - utils/haddock - utils/hsc2hs Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -76,7 +76,7 @@ Library if flag(build-tool-depends) build-tool-depends: alex:alex >= 3.2.6, happy:happy >= 1.20.0, genprimopcode:genprimopcode, deriveConstants:deriveConstants - Build-Depends: base >= 4.11 && < 4.18, + Build-Depends: base >= 4.11 && < 4.19, deepseq >= 1.4 && < 1.5, directory >= 1 && < 1.4, process >= 1 && < 1.7, ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.5], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.6], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are @@ -224,7 +224,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.0" +MinBootGhcVersion="9.2" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) ===================================== libraries/array ===================================== @@ -1 +1 @@ -Subproject commit acd92ba77c205a039d9c6eaabb3e35d09e330160 +Subproject commit f7a498b880a1fff833699d8417bac155d58ed59e ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.17.0.0 +version: 4.18.0.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/deepseq ===================================== @@ -1 +1 @@ -Subproject commit 28f4d5b00448239581ead0de9140ff4a6847c806 +Subproject commit 7e77698d6a78981bc2649df78021a6c33a5d3913 ===================================== libraries/directory ===================================== @@ -1 +1 @@ -Subproject commit b33c1087d746389a687be42aa1fb73c12e3885d3 +Subproject commit 7f9066137c694ab7cef9a4ebd8c19a281fad42e4 ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit 872e19fce06ddd40bd0771dbd3cad2c3c6ed5e7d +Subproject commit 7139cd3383a2aae440a57b5604a8182d9a983715 ===================================== 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.18 + build-depends: base >= 4.7 && < 4.19 ===================================== libraries/ghc-boot/GHC/Utils/Encoding/UTF8.hs ===================================== @@ -44,17 +44,20 @@ module GHC.Utils.Encoding.UTF8 import Prelude import Foreign +import GHC.IO +#if MIN_VERSION_base(4,18,0) +import GHC.Encoding.UTF8 +#else import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) import Data.Char -import GHC.IO +import GHC.Exts import GHC.ST +#endif import Data.ByteString (ByteString) import qualified Data.ByteString.Internal as BS import Data.ByteString.Short.Internal (ShortByteString(..)) -import GHC.Exts - -- | Find the start of the codepoint preceding the codepoint at the given -- 'Ptr'. This is undefined if there is no previous valid codepoint. utf8PrevChar :: Ptr Word8 -> IO (Ptr Word8) ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -70,7 +70,7 @@ Library GHC.Version GHC.Platform.Host - build-depends: base >= 4.7 && < 4.18, + build-depends: base >= 4.7 && < 4.19, binary == 0.8.*, bytestring >= 0.10 && < 0.12, containers >= 0.5 && < 0.7, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -40,7 +40,7 @@ library CPP build-depends: ghc-prim >= 0.5.3 && < 0.11, - base >= 4.9.0 && < 4.18, + base >= 4.9.0 && < 4.19, bytestring >= 0.10.6.0 && <0.12 ghc-options: -Wall ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -70,7 +70,7 @@ library Build-Depends: rts, array == 0.5.*, - base >= 4.8 && < 4.18, + base >= 4.8 && < 4.19, ghc-prim >= 0.5.0 && < 0.11, binary == 0.8.*, bytestring >= 0.10 && < 0.12, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit d4f343509e905a717ea463ad84462c126d8990d8 +Subproject commit 3b9f9260239f88309c78096cae3018f87d68a1f1 ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 76d1a0473d405e194d0c92a1cbeb6c019bbb57cd +Subproject commit 622595962acc1b07eaba4574c21375927579d189 ===================================== libraries/parsec ===================================== @@ -1 +1 @@ -Subproject commit f1171a4b212070bb0299b636aeee7d0534a6c76c +Subproject commit 0e23b3246fd7f6d125129316dcbedd609e6d2dca ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit cb89d5079d29c38683bcb6feec7dc53ad3836ed0 +Subproject commit 7c6871d89bd87875b4e402de26d7267c11e617a9 ===================================== libraries/stm ===================================== @@ -1 +1 @@ -Subproject commit f4eb5a85c2732f8f5a03ef8af88d6aff90945415 +Subproject commit 4ac6ead642829c9c983ee3c96ba13fa0308891ff ===================================== libraries/template-haskell/template-haskell.cabal.in ===================================== @@ -55,7 +55,7 @@ Library Language.Haskell.TH.Lib.Map build-depends: - base >= 4.11 && < 4.18, + base >= 4.11 && < 4.19, ghc-boot-th == @ProjectVersionMunged@, ghc-prim, pretty == 1.1.* ===================================== libraries/terminfo ===================================== @@ -1 +1 @@ -Subproject commit a21cc7e2d58f3e35a4ac3fb386738d9b448eaf13 +Subproject commit 0a05f06bc8a56c43578ce06d4ef1339ee70fb3fc ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 3be0223cee7395410915a127eba3acae5ff0b2f2 +Subproject commit 98adc732bfbfca4fef945d546ecbaae13952a950 ===================================== rts/IPE.c ===================================== @@ -57,7 +57,10 @@ this all IPE lists of all IpeBufferListNode are traversed to insert all IPEs. After the content of a IpeBufferListNode has been inserted, it's freed. */ +#if defined(THREADED_RTS) static Mutex ipeMapLock; +#endif +// Protected by ipeMapLock static HashTable *ipeMap = NULL; // Accessed atomically ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-4ArNecmPyDqFgQMPsq5SEg-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-3A0ecVFOxAgF5zqWrGYPfn-p ===================================== testsuite/tests/cabal/t18567/T18567.stderr ===================================== @@ -2,4 +2,4 @@ : warning: [GHC-42258] [-Wunused-packages] The following packages were specified via -package or -package-id flags, but were not needed for compilation: - - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-Dq740EWYmHcKhGKUMfjfaX-sublib-unused) + - internal-lib-0.1.0.0 (exposed by flag -package-id internal-lib-0.1.0.0-1v10MAkotpbGWvaODnEeBc-sublib-unused) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit edc72530978d8a9ec92f51d288484986ec0051e3 +Subproject commit 37e3c3683ac70735ab211f59210c9abea8ae2c69 ===================================== utils/hsc2hs ===================================== @@ -1 +1 @@ -Subproject commit ac11465d9aadbe24be4832a3775fbd4344484402 +Subproject commit 219bba062e804db0bea4bf3ffcaaba2df46334f8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c97b2a2655ff6a454f78289883f73412c2e74152...7e400d4608de29bf4b87bcf1aa158a0c5022be45 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c97b2a2655ff6a454f78289883f73412c2e74152...7e400d4608de29bf4b87bcf1aa158a0c5022be45 You're receiving 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 Dec 14 03:18:58 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Dec 2022 22:18:58 -0500 Subject: [Git][ghc/ghc][master] Respect -XStrict in the pattern-match checker (#21761) Message-ID: <639940a22c7a7_389fe213cfc98047004c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 4 changed files: - compiler/GHC/HsToCore/Pmc/Desugar.hs - + testsuite/tests/pmcheck/should_compile/T21761.hs - + testsuite/tests/pmcheck/should_compile/T21761.stderr - testsuite/tests/pmcheck/should_compile/all.T Changes: ===================================== compiler/GHC/HsToCore/Pmc/Desugar.hs ===================================== @@ -38,7 +38,7 @@ import GHC.Core.Coercion import GHC.Tc.Types.Evidence (HsWrapper(..), isIdHsWrapper) import {-# SOURCE #-} GHC.HsToCore.Expr (dsExpr, dsLExpr, dsSyntaxExpr) import {-# SOURCE #-} GHC.HsToCore.Binds (dsHsWrapper) -import GHC.HsToCore.Utils (isTrueLHsExpr, selectMatchVar) +import GHC.HsToCore.Utils (isTrueLHsExpr, selectMatchVar, decideBangHood) import GHC.HsToCore.Match.Literal (dsLit, dsOverLit) import GHC.HsToCore.Monad import GHC.Core.TyCo.Rep @@ -334,7 +334,10 @@ desugarMatches vars matches = -- Desugar a single match desugarMatch :: [Id] -> LMatch GhcTc (LHsExpr GhcTc) -> DsM (PmMatch Pre) desugarMatch vars (L match_loc (Match { m_pats = pats, m_grhss = grhss })) = do - pats' <- concat <$> zipWithM desugarLPat vars pats + dflags <- getDynFlags + -- decideBangHood: See Note [Desugaring -XStrict matches in Pmc] + let banged_pats = map (decideBangHood dflags) pats + pats' <- concat <$> zipWithM desugarLPat vars banged_pats grhss' <- desugarGRHSs (locA match_loc) (sep (map ppr pats)) grhss -- tracePm "desugarMatch" (vcat [ppr pats, ppr pats', ppr grhss']) return PmMatch { pm_pats = GrdVec pats', pm_grhss = grhss' } @@ -533,4 +536,30 @@ the whole point. The place to store the 'PmLet' guards for @where@ clauses (which are per 'GRHSs') is as a field of 'PmGRHSs'. For plain @let@ guards as in the guards of @x@, we can simply add them to the 'pg_grds' field of 'PmGRHS'. + +Note [Desugaring -XStrict matches in Pmc] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider (#21761) + + {-# LANGUAGE Strict #-} + idV :: Void -> Void + idV v = v + +Without -XStrict, we would not warn here. But with -XStrict, there is an +implicit bang on `v` and we should give an inaccessible warning for the RHS. +The way we account for that is by calling `decideBangHood` on patterns +in a `Match`, which inserts the implicit bang. + +Making the call here actually seems redundant with the call to `decideBangHood` +in `GHC.HsToCore.Match.matchWrapper`, which does it *after* it calls the +pattern-match checker on the Match's patterns. It would be great if we could expect +`matchWrapper` to pass the bang-adorned `Match` to the pattern-match checker, +but sadly then we get worse warning messages which would print `idV` as if the +user *had* written a bang: + + Pattern match has inaccessible right hand side +- In an equation for ‘idV’: idV v = ... ++ In an equation for ‘idV’: idV !v = ... + +So we live with the duplication. -} ===================================== testsuite/tests/pmcheck/should_compile/T21761.hs ===================================== @@ -0,0 +1,19 @@ +{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE Strict #-} + +module T21761 where + +data Void + +idV :: Void -> Void +idV v = v + +idV' :: Void -> Void +idV' v = case v of w -> w + +bangIdV :: Void -> Void +bangIdV !v = v + +bangIdV' :: Void -> Void +bangIdV' v = case v of !w -> w ===================================== testsuite/tests/pmcheck/should_compile/T21761.stderr ===================================== @@ -0,0 +1,24 @@ + +T21761.hs:10:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘idV’: idV v = ... + +T21761.hs:13:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘idV'’: idV' v = ... + +T21761.hs:13:20: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In a case alternative: w -> ... + +T21761.hs:16:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘bangIdV’: bangIdV !v = ... + +T21761.hs:19:1: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In an equation for ‘bangIdV'’: bangIdV' v = ... + +T21761.hs:19:24: warning: [GHC-94210] [-Woverlapping-patterns (in -Wdefault)] + Pattern match has inaccessible right hand side + In a case alternative: !w -> ... ===================================== testsuite/tests/pmcheck/should_compile/all.T ===================================== @@ -157,3 +157,4 @@ test('EmptyCase008', [], compile, [overlapping_incomplete]) test('EmptyCase009', [], compile, [overlapping_incomplete]) test('EmptyCase010', [], compile, [overlapping_incomplete]) test('T19271', [], compile, [overlapping_incomplete]) +test('T21761', [], compile, [overlapping_incomplete]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9d74a3e47a4709502d7c1923b8611c22183b777 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9d74a3e47a4709502d7c1923b8611c22183b777 You're receiving 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 Dec 14 03:19:52 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Dec 2022 22:19:52 -0500 Subject: [Git][ghc/ghc][master] Fix loop in the interface representation of some `Unfolding` fields Message-ID: <639940d8f2985_389fe252670475835@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 23 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - + testsuite/tests/simplCore/should_compile/T22272.hs - + testsuite/tests/simplCore/should_compile/T22272.stderr - + testsuite/tests/simplCore/should_compile/T22272_A.hs - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -52,7 +52,7 @@ module GHC.Core ( isRuntimeArg, isRuntimeVar, -- * Unfolding data types - Unfolding(..), UnfoldingGuidance(..), UnfoldingSource(..), + Unfolding(..), UnfoldingCache(..), UnfoldingGuidance(..), UnfoldingSource(..), -- ** Constructing 'Unfolding's noUnfolding, bootUnfolding, evaldUnfolding, mkOtherCon, @@ -1277,15 +1277,8 @@ data Unfolding uf_tmpl :: CoreExpr, -- Template; occurrence info is correct uf_src :: UnfoldingSource, -- Where the unfolding came from uf_is_top :: Bool, -- True <=> top level binding - uf_is_value :: Bool, -- exprIsHNF template (cached); it is ok to discard - -- a `seq` on this variable - uf_is_conlike :: Bool, -- True <=> applicn of constructor or CONLIKE function - -- Cached version of exprIsConLike - uf_is_work_free :: Bool, -- True <=> doesn't waste (much) work to expand - -- inside an inlining - -- Cached version of exprIsCheap - uf_expandable :: Bool, -- True <=> can expand in RULE matching - -- Cached version of exprIsExpandable + uf_cache :: UnfoldingCache, -- Cache of flags computable from the expr + -- See Note [Tying the 'CoreUnfolding' knot] uf_guidance :: UnfoldingGuidance -- Tells about the *size* of the template. } -- ^ An unfolding with redundant cached information. Parameters: @@ -1305,7 +1298,22 @@ data Unfolding -- uf_guidance: Tells us about the /size/ of the unfolding template ------------------------------------------------- +-- | Properties of a 'CoreUnfolding' that could be computed on-demand from its template. +-- See Note [UnfoldingCache] +data UnfoldingCache + = UnfoldingCache { + uf_is_value :: !Bool, -- exprIsHNF template (cached); it is ok to discard + -- a `seq` on this variable + uf_is_conlike :: !Bool, -- True <=> applicn of constructor or CONLIKE function + -- Cached version of exprIsConLike + uf_is_work_free :: !Bool, -- True <=> doesn't waste (much) work to expand + -- inside an inlining + -- Cached version of exprIsCheap + uf_expandable :: !Bool -- True <=> can expand in RULE matching + -- Cached version of exprIsExpandable + } + deriving (Eq) + -- | 'UnfoldingGuidance' says when unfolding should take place data UnfoldingGuidance = UnfWhen { -- Inline without thinking about the *size* of the uf_tmpl @@ -1335,7 +1343,23 @@ data UnfoldingGuidance | UnfNever -- The RHS is big, so don't inline it deriving (Eq) -{- +{- Note [UnfoldingCache] +~~~~~~~~~~~~~~~~~~~~~~~~ +The UnfoldingCache field of an Unfolding holds four (strict) booleans, +all derived from the uf_tmpl field of the unfolding. + +* We serialise the UnfoldingCache to and from interface files, for + reasons described in Note [Tying the 'CoreUnfolding' knot] in + GHC.IfaceToCore + +* Because it is a strict data type, we must be careful not to + pattern-match on it until we actually want its values. E.g + GHC.Core.Unfold.callSiteInline/tryUnfolding are careful not to force + it unnecessarily. Just saves a bit of work. + +* When `seq`ing Core to eliminate space leaks, to suffices to `seq` on + the cache, but not its fields, because it is strict in all fields. + Note [Historical note: unfoldings for wrappers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to have a nice clever scheme in interface files for @@ -1436,42 +1460,44 @@ otherCons _ = [] -- yield a value (something in HNF): returns @False@ if unsure isValueUnfolding :: Unfolding -> Bool -- Returns False for OtherCon -isValueUnfolding (CoreUnfolding { uf_is_value = is_evald }) = is_evald -isValueUnfolding (DFunUnfolding {}) = True -isValueUnfolding _ = False +isValueUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_value cache +isValueUnfolding (DFunUnfolding {}) = True +isValueUnfolding _ = False -- | Determines if it possibly the case that the unfolding will -- yield a value. Unlike 'isValueUnfolding' it returns @True@ -- for 'OtherCon' isEvaldUnfolding :: Unfolding -> Bool -- Returns True for OtherCon -isEvaldUnfolding (OtherCon _) = True -isEvaldUnfolding (DFunUnfolding {}) = True -isEvaldUnfolding (CoreUnfolding { uf_is_value = is_evald }) = is_evald -isEvaldUnfolding _ = False +isEvaldUnfolding (OtherCon _) = True +isEvaldUnfolding (DFunUnfolding {}) = True +isEvaldUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_value cache +isEvaldUnfolding _ = False -- | @True@ if the unfolding is a constructor application, the application -- of a CONLIKE function or 'OtherCon' isConLikeUnfolding :: Unfolding -> Bool -isConLikeUnfolding (OtherCon _) = True -isConLikeUnfolding (CoreUnfolding { uf_is_conlike = con }) = con -isConLikeUnfolding _ = False +isConLikeUnfolding (OtherCon _) = True +isConLikeUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_conlike cache +isConLikeUnfolding _ = False -- | Is the thing we will unfold into certainly cheap? isCheapUnfolding :: Unfolding -> Bool -isCheapUnfolding (CoreUnfolding { uf_is_work_free = is_wf }) = is_wf -isCheapUnfolding _ = False +isCheapUnfolding (CoreUnfolding { uf_cache = cache }) = uf_is_work_free cache +isCheapUnfolding _ = False isExpandableUnfolding :: Unfolding -> Bool -isExpandableUnfolding (CoreUnfolding { uf_expandable = is_expable }) = is_expable -isExpandableUnfolding _ = False +isExpandableUnfolding (CoreUnfolding { uf_cache = cache }) = uf_expandable cache +isExpandableUnfolding _ = False expandUnfolding_maybe :: Unfolding -> Maybe CoreExpr -- Expand an expandable unfolding; this is used in rule matching -- See Note [Expanding variables] in GHC.Core.Rules -- The key point here is that CONLIKE things can be expanded -expandUnfolding_maybe (CoreUnfolding { uf_expandable = True, uf_tmpl = rhs }) = Just rhs -expandUnfolding_maybe _ = Nothing +expandUnfolding_maybe (CoreUnfolding { uf_cache = cache, uf_tmpl = rhs }) + | uf_expandable cache + = Just rhs +expandUnfolding_maybe _ = Nothing isCompulsoryUnfolding :: Unfolding -> Bool isCompulsoryUnfolding (CoreUnfolding { uf_src = src }) = isCompulsorySource src ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -4210,7 +4210,7 @@ simplLetUnfolding env bind_cxt id new_rhs rhs_ty arity unf mkLetUnfolding :: UnfoldingOpts -> TopLevelFlag -> UnfoldingSource -> InId -> OutExpr -> SimplM Unfolding mkLetUnfolding !uf_opts top_lvl src id new_rhs - = return (mkUnfolding uf_opts src is_top_lvl is_bottoming new_rhs) + = return (mkUnfolding uf_opts src is_top_lvl is_bottoming new_rhs Nothing) -- We make an unfolding *even for loop-breakers*. -- Reason: (a) It might be useful to know that they are WHNF -- (b) In GHC.Iface.Tidy we currently assume that, if we want to @@ -4270,7 +4270,7 @@ simplStableUnfolding env bind_cxt id rhs_ty id_arity unf -- A test case is #4138 -- But retain a previous boring_ok of True; e.g. see -- the way it is set in calcUnfoldingGuidanceWithArity - in return (mkCoreUnfolding src is_top_lvl expr' guide') + in return (mkCoreUnfolding src is_top_lvl expr' Nothing guide') -- See Note [Top-level flag on inline rules] in GHC.Core.Unfold _other -- Happens for INLINABLE things ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -2169,7 +2169,7 @@ abstractFloats uf_opts top_lvl main_tvs floats body = (poly_id `setIdUnfolding` unf, poly_rhs) where poly_rhs = mkLams tvs_here rhs - unf = mkUnfolding uf_opts VanillaSrc is_top_lvl False poly_rhs + unf = mkUnfolding uf_opts VanillaSrc is_top_lvl False poly_rhs Nothing -- We want the unfolding. Consider -- let ===================================== compiler/GHC/Core/Ppr.hs ===================================== @@ -627,18 +627,14 @@ instance Outputable Unfolding where <+> sep (map (pprBndr LambdaBind) bndrs) <+> arrow) 2 (ppr con <+> sep (map ppr args)) ppr (CoreUnfolding { uf_src = src - , uf_tmpl=rhs, uf_is_top=top, uf_is_value=hnf - , uf_is_conlike=conlike, uf_is_work_free=wf - , uf_expandable=exp, uf_guidance=g }) + , uf_tmpl=rhs, uf_is_top=top + , uf_cache=cache, uf_guidance=g }) = text "Unf" <> braces (pp_info $$ pp_rhs) where pp_info = fsep $ punctuate comma [ text "Src=" <> ppr src , text "TopLvl=" <> ppr top - , text "Value=" <> ppr hnf - , text "ConLike=" <> ppr conlike - , text "WorkFree=" <> ppr wf - , text "Expandable=" <> ppr exp + , ppr cache , text "Guidance=" <> ppr g ] pp_tmpl = ppUnlessOption sdocSuppressUnfoldings (text "Tmpl=" <+> ppr rhs) @@ -647,6 +643,15 @@ instance Outputable Unfolding where -- Don't print the RHS or we get a quadratic -- blowup in the size of the printout! +instance Outputable UnfoldingCache where + ppr (UnfoldingCache { uf_is_value = hnf, uf_is_conlike = conlike + , uf_is_work_free = wf, uf_expandable = exp }) + = fsep $ punctuate comma + [ text "Value=" <> ppr hnf + , text "ConLike=" <> ppr conlike + , text "WorkFree=" <> ppr wf + , text "Expandable=" <> ppr exp ] + {- ----------------------------------------------------- -- Rules ===================================== compiler/GHC/Core/Seq.hs ===================================== @@ -104,10 +104,11 @@ seqAlts (Alt c bs e:alts) = c `seq` seqBndrs bs `seq` seqExpr e `seq` seqAlts al seqUnfolding :: Unfolding -> () seqUnfolding (CoreUnfolding { uf_tmpl = e, uf_is_top = top, - uf_is_value = b1, uf_is_work_free = b2, - uf_expandable = b3, uf_is_conlike = b4, - uf_guidance = g}) - = seqExpr e `seq` top `seq` b1 `seq` b2 `seq` b3 `seq` b4 `seq` seqGuidance g + uf_cache = cache, uf_guidance = g}) + = seqExpr e `seq` top `seq` cache `seq` seqGuidance g + -- The unf_cache :: UnfoldingCache field is a strict data type, + -- so it is sufficient to use plain `seq` for this field + -- See Note [UnfoldingCache] in GHC.Core seqUnfolding _ = () ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -759,7 +759,7 @@ add_info env old_bndr top_level new_rhs new_bndr unfolding_from_rhs = mkUnfolding uf_opts VanillaSrc (isTopLevel top_level) False -- may be bottom or not - new_rhs + new_rhs Nothing simpleUnfoldingFun :: IdUnfoldingFun simpleUnfoldingFun id ===================================== compiler/GHC/Core/Tidy.hs ===================================== @@ -375,15 +375,16 @@ tidyNestedUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = arg (tidy_env', bndrs') = tidyBndrs tidy_env bndrs tidyNestedUnfolding tidy_env - unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_is_value = is_value }) + unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src, uf_cache = cache }) | isStableSource src = seqIt $ unf { uf_tmpl = tidyExpr tidy_env unf_rhs } -- Preserves OccInfo - -- This seqIt avoids a space leak: otherwise the uf_is_value, - -- uf_is_conlike, ... fields may retain a reference to the - -- pre-tidied expression forever (GHC.CoreToIface doesn't look at them) + -- This seqIt avoids a space leak: otherwise the uf_cache + -- field may retain a reference to the pre-tidied + -- expression forever (GHC.CoreToIface doesn't look at + -- them) -- Discard unstable unfoldings, but see Note [Preserve evaluatedness] - | is_value = evaldUnfolding + | uf_is_value cache = evaldUnfolding | otherwise = noUnfolding where ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -1036,11 +1036,11 @@ callSiteInline logger opts !case_depth id active_unfolding lone_variable arg_inf -- Things with an INLINE pragma may have an unfolding *and* -- be a loop breaker (maybe the knot is not yet untied) CoreUnfolding { uf_tmpl = unf_template - , uf_is_work_free = is_wf - , uf_guidance = guidance, uf_expandable = is_exp } + , uf_cache = unf_cache + , uf_guidance = guidance } | active_unfolding -> tryUnfolding logger opts case_depth id lone_variable arg_infos cont_info unf_template - is_wf is_exp guidance + unf_cache guidance | otherwise -> traceInline logger opts id "Inactive unfolding:" (ppr id) Nothing NoUnfolding -> Nothing BootUnfolding -> Nothing @@ -1162,11 +1162,10 @@ needed on a per-module basis. -} tryUnfolding :: Logger -> UnfoldingOpts -> Int -> Id -> Bool -> [ArgSummary] -> CallCtxt - -> CoreExpr -> Bool -> Bool -> UnfoldingGuidance + -> CoreExpr -> UnfoldingCache -> UnfoldingGuidance -> Maybe CoreExpr -tryUnfolding logger opts !case_depth id lone_variable - arg_infos cont_info unf_template - is_wf is_exp guidance +tryUnfolding logger opts !case_depth id lone_variable arg_infos + cont_info unf_template unf_cache guidance = case guidance of UnfNever -> traceInline logger opts id str (text "UnfNever") Nothing @@ -1178,7 +1177,7 @@ tryUnfolding logger opts !case_depth id lone_variable -> traceInline logger opts id str (mk_doc some_benefit empty False) Nothing where some_benefit = calc_some_benefit uf_arity - enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) + enough_args = (n_val_args >= uf_arity) || (unsat_ok && n_val_args > 0) UnfIfGoodArgs { ug_args = arg_discounts, ug_res = res_discount, ug_size = size } | unfoldingVeryAggressive opts @@ -1189,9 +1188,6 @@ tryUnfolding logger opts !case_depth id lone_variable -> traceInline logger opts id str (mk_doc some_benefit extra_doc False) Nothing where some_benefit = calc_some_benefit (length arg_discounts) - extra_doc = vcat [ text "case depth =" <+> int case_depth - , text "depth based penalty =" <+> int depth_penalty - , text "discounted size =" <+> int adjusted_size ] -- See Note [Avoid inlining into deeply nested cases] depth_treshold = unfoldingCaseThreshold opts depth_scaling = unfoldingCaseScaling opts @@ -1201,7 +1197,18 @@ tryUnfolding logger opts !case_depth id lone_variable small_enough = adjusted_size <= unfoldingUseThreshold opts discount = computeDiscount arg_discounts res_discount arg_infos cont_info + extra_doc = vcat [ text "case depth =" <+> int case_depth + , text "depth based penalty =" <+> int depth_penalty + , text "discounted size =" <+> int adjusted_size ] + where + -- Unpack the UnfoldingCache lazily because it may not be needed, and all + -- its fields are strict; so evaluating unf_cache at all forces all the + -- isWorkFree etc computations to take place. That risks wasting effort for + -- Ids that are never going to inline anyway. + -- See Note [UnfoldingCache] in GHC.Core + UnfoldingCache{ uf_is_work_free = is_wf, uf_expandable = is_exp } = unf_cache + mk_doc some_benefit extra_doc yes_or_no = vcat [ text "arg infos" <+> ppr arg_infos , text "interesting continuation" <+> ppr cont_info ===================================== compiler/GHC/Core/Unfold/Make.hs ===================================== @@ -6,6 +6,7 @@ module GHC.Core.Unfold.Make , mkUnfolding , mkCoreUnfolding , mkFinalUnfolding + , mkFinalUnfolding' , mkSimpleUnfolding , mkWorkerUnfolding , mkInlineUnfoldingWithArity, mkInlineUnfoldingNoArity @@ -35,6 +36,8 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Panic +import Data.Maybe ( fromMaybe ) + -- the very simple optimiser is used to optimise unfoldings import {-# SOURCE #-} GHC.Core.SimpleOpt @@ -43,7 +46,14 @@ import {-# SOURCE #-} GHC.Core.SimpleOpt mkFinalUnfolding :: UnfoldingOpts -> UnfoldingSource -> DmdSig -> CoreExpr -> Unfolding -- "Final" in the sense that this is a GlobalId that will not be further -- simplified; so the unfolding should be occurrence-analysed -mkFinalUnfolding opts src strict_sig expr +mkFinalUnfolding opts src strict_sig expr = mkFinalUnfolding' opts src strict_sig expr Nothing + +-- See Note [Tying the 'CoreUnfolding' knot] for why interfaces need +-- to pass a precomputed 'UnfoldingCache' +mkFinalUnfolding' :: UnfoldingOpts -> UnfoldingSource -> DmdSig -> CoreExpr -> Maybe UnfoldingCache -> Unfolding +-- "Final" in the sense that this is a GlobalId that will not be further +-- simplified; so the unfolding should be occurrence-analysed +mkFinalUnfolding' opts src strict_sig expr = mkUnfolding opts src True {- Top level -} (isDeadEndSig strict_sig) @@ -57,7 +67,7 @@ mkCompulsoryUnfolding' opts expr = mkCompulsoryUnfolding (simpleOptExpr opts exp mkCompulsoryUnfolding :: CoreExpr -> Unfolding mkCompulsoryUnfolding expr = mkCoreUnfolding CompulsorySrc True - expr + expr Nothing (UnfWhen { ug_arity = 0 -- Arity of unfolding doesn't matter , ug_unsat_ok = unSaturatedOk, ug_boring_ok = boringCxtOk }) @@ -69,7 +79,7 @@ mkCompulsoryUnfolding expr mkSimpleUnfolding :: UnfoldingOpts -> CoreExpr -> Unfolding mkSimpleUnfolding !opts rhs - = mkUnfolding opts VanillaSrc False False rhs + = mkUnfolding opts VanillaSrc False False rhs Nothing mkDFunUnfolding :: [Var] -> DataCon -> [CoreExpr] -> Unfolding mkDFunUnfolding bndrs con ops @@ -81,7 +91,7 @@ mkDFunUnfolding bndrs con ops mkDataConUnfolding :: CoreExpr -> Unfolding -- Used for non-newtype data constructors with non-trivial wrappers mkDataConUnfolding expr - = mkCoreUnfolding StableSystemSrc True expr guide + = mkCoreUnfolding StableSystemSrc True expr Nothing guide -- No need to simplify the expression where guide = UnfWhen { ug_arity = manifestArity expr @@ -93,7 +103,7 @@ mkWrapperUnfolding :: SimpleOpts -> CoreExpr -> Arity -> Unfolding -- after demand/CPR analysis mkWrapperUnfolding opts expr arity = mkCoreUnfolding StableSystemSrc True - (simpleOptExpr opts expr) + (simpleOptExpr opts expr) Nothing (UnfWhen { ug_arity = arity , ug_unsat_ok = unSaturatedOk , ug_boring_ok = boringCxtNotOk }) @@ -104,7 +114,7 @@ mkWorkerUnfolding opts work_fn (CoreUnfolding { uf_src = src, uf_tmpl = tmpl , uf_is_top = top_lvl }) | isStableSource src - = mkCoreUnfolding src top_lvl new_tmpl guidance + = mkCoreUnfolding src top_lvl new_tmpl Nothing guidance where new_tmpl = simpleOptExpr opts (work_fn tmpl) guidance = calcUnfoldingGuidance (so_uf_opts opts) False new_tmpl @@ -119,7 +129,7 @@ mkInlineUnfoldingNoArity :: SimpleOpts -> UnfoldingSource -> CoreExpr -> Unfoldi mkInlineUnfoldingNoArity opts src expr = mkCoreUnfolding src True -- Note [Top-level flag on inline rules] - expr' guide + expr' Nothing guide where expr' = simpleOptExpr opts expr guide = UnfWhen { ug_arity = manifestArity expr' @@ -133,7 +143,7 @@ mkInlineUnfoldingWithArity :: SimpleOpts -> UnfoldingSource -> Arity -> CoreExpr mkInlineUnfoldingWithArity opts src arity expr = mkCoreUnfolding src True -- Note [Top-level flag on inline rules] - expr' guide + expr' Nothing guide where expr' = simpleOptExpr opts expr guide = UnfWhen { ug_arity = arity @@ -146,7 +156,7 @@ mkInlineUnfoldingWithArity opts src arity expr mkInlinableUnfolding :: SimpleOpts -> UnfoldingSource -> CoreExpr -> Unfolding mkInlinableUnfolding opts src expr - = mkUnfolding (so_uf_opts opts) src False False expr' + = mkUnfolding (so_uf_opts opts) src False False expr' Nothing where expr' = simpleOptExpr opts expr @@ -180,7 +190,7 @@ specUnfolding opts spec_bndrs spec_app rule_lhs_args , uf_guidance = old_guidance }) | isStableSource src -- See Note [Specialising unfoldings] , UnfWhen { ug_arity = old_arity } <- old_guidance - = mkCoreUnfolding src top_lvl new_tmpl + = mkCoreUnfolding src top_lvl new_tmpl Nothing (old_guidance { ug_arity = old_arity - arity_decrease }) where new_tmpl = simpleOptExpr opts $ @@ -310,11 +320,12 @@ mkUnfolding :: UnfoldingOpts -> Bool -- Definitely a bottoming binding -- (only relevant for top-level bindings) -> CoreExpr + -> Maybe UnfoldingCache -> Unfolding -- Calculates unfolding guidance -- Occurrence-analyses the expression before capturing it -mkUnfolding opts src top_lvl is_bottoming expr - = mkCoreUnfolding src top_lvl expr guidance +mkUnfolding opts src top_lvl is_bottoming expr cache + = mkCoreUnfolding src top_lvl expr cache guidance where is_top_bottoming = top_lvl && is_bottoming guidance = calcUnfoldingGuidance opts is_top_bottoming expr @@ -322,26 +333,20 @@ mkUnfolding opts src top_lvl is_bottoming expr -- See Note [Calculate unfolding guidance on the non-occ-anal'd expression] mkCoreUnfolding :: UnfoldingSource -> Bool -> CoreExpr - -> UnfoldingGuidance -> Unfolding + -> Maybe UnfoldingCache -> UnfoldingGuidance -> Unfolding -- Occurrence-analyses the expression before capturing it -mkCoreUnfolding src top_lvl expr guidance - = CoreUnfolding { uf_tmpl = is_value `seq` - is_conlike `seq` - is_work_free `seq` - is_expandable `seq` +mkCoreUnfolding src top_lvl expr precomputed_cache guidance + = CoreUnfolding { uf_tmpl = cache `seq` occurAnalyseExpr expr -- occAnalyseExpr: see Note [Occurrence analysis of unfoldings] - -- See #20905 for what a discussion of these 'seq's + -- See #20905 for what a discussion of this 'seq'. -- We are careful to make sure we only -- have one copy of an unfolding around at once. -- Note [Thoughtful forcing in mkCoreUnfolding] , uf_src = src , uf_is_top = top_lvl - , uf_is_value = is_value - , uf_is_conlike = is_conlike - , uf_is_work_free = is_work_free - , uf_expandable = is_expandable + , uf_cache = cache , uf_guidance = guidance } where is_value = exprIsHNF expr @@ -349,6 +354,13 @@ mkCoreUnfolding src top_lvl expr guidance is_work_free = exprIsWorkFree expr is_expandable = exprIsExpandable expr + recomputed_cache = UnfoldingCache { uf_is_value = is_value + , uf_is_conlike = is_conlike + , uf_is_work_free = is_work_free + , uf_expandable = is_expandable } + + cache = fromMaybe recomputed_cache precomputed_cache + ---------------- certainlyWillInline :: UnfoldingOpts -> IdInfo -> CoreExpr -> Maybe Unfolding -- ^ Sees if the unfolding is pretty certain to inline. @@ -476,4 +488,3 @@ reducing memory pressure. The result of fixing this led to a 1G reduction in peak memory usage (12G -> 11G) when compiling a very large module (peak 3 million terms). For more discussion see #20905. -} - ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -2253,10 +2253,9 @@ diffUnfold env (DFunUnfolding bs1 c1 a1) | c1 == c2 && equalLength bs1 bs2 = concatMap (uncurry (diffExpr False env')) (zip a1 a2) where env' = rnBndrs2 env bs1 bs2 -diffUnfold env (CoreUnfolding t1 _ _ v1 cl1 wf1 x1 g1) - (CoreUnfolding t2 _ _ v2 cl2 wf2 x2 g2) - | v1 == v2 && cl1 == cl2 - && wf1 == wf2 && x1 == x2 && g1 == g2 +diffUnfold env (CoreUnfolding t1 _ _ c1 g1) + (CoreUnfolding t2 _ _ c2 g2) + | c1 == c2 && g1 == g2 = diffExpr False env t1 t2 diffUnfold _ uf1 uf2 = [fsep [ppr uf1, text "/=", ppr uf2]] ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -508,9 +508,10 @@ toIfaceJoinInfo Nothing = IfaceNotJoinPoint toIfUnfolding :: Bool -> Unfolding -> Maybe IfaceInfoItem toIfUnfolding lb (CoreUnfolding { uf_tmpl = rhs , uf_src = src + , uf_cache = cache , uf_guidance = guidance }) = Just $ HsUnfold lb $ - IfCoreUnfold src (toIfGuidance src guidance) (toIfaceExpr rhs) + IfCoreUnfold src cache (toIfGuidance src guidance) (toIfaceExpr rhs) -- Yes, even if guidance is UnfNever, expose the unfolding -- If we didn't want to expose the unfolding, GHC.Iface.Tidy would -- have stuck in NoUnfolding. For supercompilation we want ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -596,8 +596,8 @@ rnIfaceInfoItem i = pure i rnIfaceUnfolding :: Rename IfaceUnfolding -rnIfaceUnfolding (IfCoreUnfold src guide if_expr) - = IfCoreUnfold src guide <$> rnIfaceExpr if_expr +rnIfaceUnfolding (IfCoreUnfold src cache guide if_expr) + = IfCoreUnfold src cache guide <$> rnIfaceExpr if_expr rnIfaceUnfolding (IfDFunUnfold bs ops) = IfDFunUnfold <$> rnIfaceBndrs bs <*> mapM rnIfaceExpr ops ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -49,7 +49,7 @@ import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey, import GHC.Types.Unique ( hasKey ) import GHC.Iface.Type import GHC.Iface.Recomp.Binary -import GHC.Core( IsOrphan, isOrphan ) +import GHC.Core( IsOrphan, isOrphan, UnfoldingCache(..) ) import GHC.Types.Demand import GHC.Types.Cpr import GHC.Core.Class @@ -365,9 +365,14 @@ data IfaceInfoItem -- only later attached to the Id. Partial reason: some are orphans. data IfaceUnfolding - = IfCoreUnfold UnfoldingSource IfGuidance IfaceExpr + = IfCoreUnfold UnfoldingSource + IfUnfoldingCache -- See Note [Tying the 'CoreUnfolding' knot] + IfGuidance + IfaceExpr | IfDFunUnfold [IfaceBndr] [IfaceExpr] +type IfUnfoldingCache = UnfoldingCache + data IfGuidance = IfNoGuidance -- Compute it from the IfaceExpr | IfWhen Arity Bool Bool -- Just like UnfWhen in Core.UnfoldingGuidance @@ -1522,7 +1527,7 @@ instance Outputable IfaceJoinInfo where ppr (IfaceJoinPoint ar) = angleBrackets (text "join" <+> ppr ar) instance Outputable IfaceUnfolding where - ppr (IfCoreUnfold src guide e) + ppr (IfCoreUnfold src _ guide e) = sep [ text "Core:" <+> ppr src <+> ppr guide, ppr e ] ppr (IfDFunUnfold bs es) = hang (text "DFun:" <+> sep (map ppr bs) <> dot) 2 (sep (map pprParendIfaceExpr es)) @@ -1774,7 +1779,7 @@ freeNamesItem (HsLFInfo (IfLFCon n)) = unitNameSet n freeNamesItem _ = emptyNameSet freeNamesIfUnfold :: IfaceUnfolding -> NameSet -freeNamesIfUnfold (IfCoreUnfold _ _ e) = freeNamesIfExpr e +freeNamesIfUnfold (IfCoreUnfold _ _ _ e) = freeNamesIfExpr e freeNamesIfUnfold (IfDFunUnfold bs es) = freeNamesIfBndrs bs &&& fnList freeNamesIfExpr es freeNamesIfExpr :: IfaceExpr -> NameSet @@ -2296,9 +2301,10 @@ instance Binary IfaceInfoItem where _ -> HsTagSig <$> get bh instance Binary IfaceUnfolding where - put_ bh (IfCoreUnfold s g e) = do + put_ bh (IfCoreUnfold s c g e) = do putByte bh 0 put_ bh s + putUnfoldingCache bh c put_ bh g put_ bh e put_ bh (IfDFunUnfold as bs) = do @@ -2309,9 +2315,10 @@ instance Binary IfaceUnfolding where h <- getByte bh case h of 0 -> do s <- get bh + c <- getUnfoldingCache bh g <- get bh e <- get bh - return (IfCoreUnfold s g e) + return (IfCoreUnfold s c g e) _ -> do as <- get bh bs <- get bh return (IfDFunUnfold as bs) @@ -2332,6 +2339,26 @@ instance Binary IfGuidance where c <- get bh return (IfWhen a b c) +putUnfoldingCache :: BinHandle -> IfUnfoldingCache -> IO () +putUnfoldingCache bh (UnfoldingCache { uf_is_value = hnf, uf_is_conlike = conlike + , uf_is_work_free = wf, uf_expandable = exp }) = do + let b = zeroBits .<<|. hnf .<<|. conlike .<<|. wf .<<|. exp + putByte bh b + +getUnfoldingCache :: BinHandle -> IO IfUnfoldingCache +getUnfoldingCache bh = do + b <- getByte bh + let hnf = testBit b 3 + conlike = testBit b 2 + wf = testBit b 1 + exp = testBit b 0 + return (UnfoldingCache { uf_is_value = hnf, uf_is_conlike = conlike + , uf_is_work_free = wf, uf_expandable = exp }) + +infixl 9 .<<|. +(.<<|.) :: (Bits a) => a -> Bool -> a +x .<<|. b = (if b then (`setBit` 0) else id) (x `shiftL` 1) + instance Binary IfaceAlt where put_ bh (IfaceAlt a b c) = do put_ bh a @@ -2688,8 +2715,9 @@ instance NFData IfGuidance where instance NFData IfaceUnfolding where rnf = \case - IfCoreUnfold src guidance expr -> src `seq` rnf guidance `seq` rnf expr - IfDFunUnfold bndrs exprs -> rnf bndrs `seq` rnf exprs + IfCoreUnfold src cache guidance expr -> src `seq` cache `seq` rnf guidance `seq` rnf expr + IfDFunUnfold bndrs exprs -> rnf bndrs `seq` rnf exprs + -- See Note [UnfoldingCache] in GHC.Core for why it suffices to merely `seq` on cache instance NFData IfaceExpr where rnf = \case ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1715,7 +1715,7 @@ tcIdInfo ignore_prags toplvl name ty info = do need_prag :: IfaceInfoItem -> Bool -- Always read in compulsory unfoldings -- See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy - need_prag (HsUnfold _ (IfCoreUnfold src _ _)) = isCompulsorySource src + need_prag (HsUnfold _ (IfCoreUnfold src _ _ _)) = isCompulsorySource src need_prag _ = False tcPrag :: IdInfo -> IfaceInfoItem -> IfL IdInfo @@ -1776,13 +1776,14 @@ tcLFInfo lfi = case lfi of tcUnfolding :: TopLevelFlag -> Name -> Type -> IdInfo -> IfaceUnfolding -> IfL Unfolding -- See Note [Lazily checking Unfoldings] -tcUnfolding toplvl name _ info (IfCoreUnfold src if_guidance if_expr) +tcUnfolding toplvl name _ info (IfCoreUnfold src cache if_guidance if_expr) = do { uf_opts <- unfoldingOpts <$> getDynFlags ; expr <- tcUnfoldingRhs (isCompulsorySource src) toplvl name if_expr ; let guidance = case if_guidance of IfWhen arity unsat_ok boring_ok -> UnfWhen arity unsat_ok boring_ok IfNoGuidance -> calcUnfoldingGuidance uf_opts is_top_bottoming expr - ; return $ mkCoreUnfolding src True expr guidance } + -- See Note [Tying the 'CoreUnfolding' knot] + ; return $ mkCoreUnfolding src True expr (Just cache) guidance } where -- Strictness should occur before unfolding! is_top_bottoming = isTopLevel toplvl && isDeadEndSig (dmdSigInfo info) @@ -1795,6 +1796,49 @@ tcUnfolding _toplvl name dfun_ty _ (IfDFunUnfold bs ops) doc = text "Class ops for dfun" <+> ppr name (_, _, cls, _) = tcSplitDFunTy dfun_ty +{- Note [Tying the 'CoreUnfolding' knot] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The unfolding of recursive definitions can contain references to the +Id being defined. Consider the following example: + + foo :: () + foo = foo + +The unfolding template of 'foo' is, of course, 'foo'; so the interface +file for this module contains: + + foo :: (); Unfolding = foo + +When rehydrating the interface file we are going to make an Id for +'foo' (in GHC.IfaceToCore), with an 'Unfolding'. We used to make this +'Unfolding' by calling 'mkFinalUnfolding', but that needs to populate, +among other fields, the 'uf_is_value' field, by computing +'exprIsValue' of the template (in this case, 'foo'). + +'exprIsValue e' looks at the unfoldings of variables in 'e' to see if +they are evaluated; so it consults the `uf_is_value` field of +variables in `e`. Now we can see the problem: to set the `uf_is_value` +field of `foo`'s unfolding, we look at its unfolding (in this case +just `foo` itself!). Loop. This is the root cause of ticket #22272. + +The simple solution we chose is to serialise the various auxiliary +fields of `CoreUnfolding` so that we don't need to recreate them when +rehydrating. Specifically, the following fields are moved to the +'UnfoldingCache', which is persisted in the interface file: + +* 'uf_is_conlike' +* 'uf_is_value' +* 'uf_is_work_free' +* 'uf_expandable' + +These four bits make the interface files only one byte larger per +unfolding; on the other hand, this does save calls to 'exprIsValue', +'exprIsExpandable' etc for every imported Id. + +We could choose to do this only for loop breakers. But that's a bit +more complicated and it seems good all round. +-} + {- Note [Lazily checking Unfoldings] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For unfoldings, we try to do the job lazily, so that we never typecheck ===================================== testsuite/tests/deSugar/should_compile/T13208.stdout ===================================== @@ -1,6 +1,6 @@ - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}] f = \ (@p) _ [Occ=Dead] -> GHC.Types.True - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 80 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/numeric/should_compile/T14170.stdout ===================================== @@ -6,44 +6,50 @@ Result size of Tidy Core -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] NatVal.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] NatVal.$trModule3 = GHC.Types.TrNameS NatVal.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] NatVal.$trModule2 = "NatVal"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] NatVal.$trModule1 = GHC.Types.TrNameS NatVal.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} NatVal.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] NatVal.$trModule = GHC.Types.Module NatVal.$trModule3 NatVal.$trModule1 -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} foo :: Integer [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] foo = GHC.Num.Integer.IS 0# ===================================== testsuite/tests/numeric/should_compile/T14465.stdout ===================================== @@ -6,43 +6,49 @@ Result size of Tidy Core -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} ten :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] ten = GHC.Num.Natural.NS 10## -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} M.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] M.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.$trModule3 = GHC.Types.TrNameS M.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} M.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] M.$trModule2 = "M"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.$trModule1 = GHC.Types.TrNameS M.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} M.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.$trModule = GHC.Types.Module M.$trModule3 M.$trModule1 -- RHS size: {terms: 1, types: 1, coercions: 0, joins: 0/0} @@ -50,23 +56,25 @@ minusOne :: Natural [GblId, Str=b, Cpr=b, - Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=False, ConLike=False, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] minusOne = GHC.Prim.Exception.raiseUnderflow @Natural -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} twoTimesTwo :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] twoTimesTwo = GHC.Num.Natural.NS 4## -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} M.one1 :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] M.one1 = GHC.Num.Natural.NS 1## -- RHS size: {terms: 4, types: 1, coercions: 0, joins: 0/0} @@ -74,15 +82,16 @@ plusOne :: Natural -> Natural [GblId, Arity=1, Str=<1L>, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [0] 30 0}] plusOne = \ (n :: Natural) -> naturalAdd n M.one1 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} one :: Natural [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] one = M.one1 ===================================== testsuite/tests/numeric/should_compile/T7116.stdout ===================================== @@ -6,36 +6,41 @@ Result size of Tidy Core -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T7116.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] T7116.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T7116.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T7116.$trModule3 = GHC.Types.TrNameS T7116.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T7116.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] T7116.$trModule2 = "T7116"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T7116.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T7116.$trModule1 = GHC.Types.TrNameS T7116.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7116.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T7116.$trModule = GHC.Types.Module T7116.$trModule3 T7116.$trModule1 @@ -45,8 +50,8 @@ dr :: Double -> Double Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (x [Occ=Once1!] :: Double) -> case x of { GHC.Types.D# x1 -> @@ -62,8 +67,8 @@ dl :: Double -> Double Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] dl = dr @@ -73,8 +78,8 @@ fr :: Float -> Float Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (x [Occ=Once1!] :: Float) -> case x of { GHC.Types.F# x1 -> @@ -92,8 +97,8 @@ fl :: Float -> Float Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] fl = fr ===================================== testsuite/tests/simplCore/should_compile/T22272.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module T22272 where + +import T22272_A + +bar :: () +bar = foo ===================================== testsuite/tests/simplCore/should_compile/T22272.stderr ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling T22272_A ( T22272_A.hs, T22272_A.o ) +[2 of 2] Compiling T22272 ( T22272.hs, T22272.o ) ===================================== testsuite/tests/simplCore/should_compile/T22272_A.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module T22272_A where + +foo :: () +foo = foo ===================================== testsuite/tests/simplCore/should_compile/T3772.stdout ===================================== @@ -6,36 +6,41 @@ Result size of Tidy Core -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T3772.$trModule4 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 20 0}] T3772.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T3772.$trModule3 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T3772.$trModule3 = GHC.Types.TrNameS T3772.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T3772.$trModule2 :: GHC.Prim.Addr# [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 30 0}] T3772.$trModule2 = "T3772"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T3772.$trModule1 :: GHC.Types.TrName [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T3772.$trModule1 = GHC.Types.TrNameS T3772.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T3772.$trModule :: GHC.Types.Module [GblId, - Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] + Unf=Unf{Src=, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, + Guidance=IF_ARGS [] 10 10}] T3772.$trModule = GHC.Types.Module T3772.$trModule3 T3772.$trModule1 @@ -67,8 +72,8 @@ foo [InlPrag=NOINLINE[final]] :: Int -> () Arity=1, Str=<1!P(L)>, Cpr=1, - Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, + Unf=Unf{Src=StableSystem, TopLvl=True, + Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) Tmpl= \ (n [Occ=Once1!] :: Int) -> case n of { GHC.Types.I# ww [Occ=Once1] -> ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -457,3 +457,4 @@ test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m - test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T22491', normal, compile, ['-O2']) test('T21476', normal, compile, ['']) +test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings -fno-omit-interface-pragmas -fno-ignore-interface-pragmas']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/884790e2f3480dfcd73b1c094123555956eac6e0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/884790e2f3480dfcd73b1c094123555956eac6e0 You're receiving 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 Dec 14 03:20:41 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Dec 2022 22:20:41 -0500 Subject: [Git][ghc/ghc][master] EPA: When splitting out header comments, keep ones for first decl Message-ID: <6399410946ef0_389fe218b96e4c4803de@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 5 changed files: - compiler/GHC/Parser/Lexer.x - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/parser/should_compile/DumpParsedAstComments.hs - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr - testsuite/tests/printer/Ppr031.hs Changes: ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -3676,6 +3676,25 @@ allocateComments ss comment_q = in (comment_q', reverse newAnns) +-- Comments appearing without a line-break before the first +-- declaration are associated with the declaration +splitPriorComments + :: RealSrcSpan + -> [LEpaComment] + -> ([LEpaComment], [LEpaComment]) +splitPriorComments ss prior_comments = + let + -- True if there is only one line between the earlier and later span + cmp later earlier + = srcSpanStartLine later - srcSpanEndLine earlier == 1 + + go decl _ [] = ([],decl) + go decl r (c@(L l _):cs) = if cmp r (anchor l) + then go (c:decl) (anchor l) cs + else (reverse (c:cs), decl) + in + go [] ss prior_comments + allocatePriorComments :: RealSrcSpan -> [LEpaComment] @@ -3684,12 +3703,13 @@ allocatePriorComments allocatePriorComments ss comment_q mheader_comments = let cmp (L l _) = anchor l <= ss - (before,after) = partition cmp comment_q - newAnns = before + (newAnns,after) = partition cmp comment_q comment_q'= after + (prior_comments, decl_comments) = splitPriorComments ss newAnns in case mheader_comments of - Strict.Nothing -> (Strict.Just (reverse newAnns), comment_q', []) + Strict.Nothing -> (Strict.Just prior_comments, comment_q', decl_comments) + -- Strict.Nothing -> (Strict.Just [], comment_q', newAnns) Strict.Just _ -> (mheader_comments, comment_q', reverse newAnns) allocateFinalComments ===================================== testsuite/tests/ghc-api/exactprint/Test20239.stderr ===================================== @@ -19,14 +19,7 @@ [] [])) (EpaCommentsBalanced - [(L - (Anchor - { Test20239.hs:3:1-28 } - (UnchangedAnchor)) - (EpaComment - (EpaLineComment - "-- | Leading Haddock Comment") - { Test20239.hs:1:18-22 }))] + [] [(L (Anchor { Test20239.hs:8:1 } @@ -53,6 +46,14 @@ []) (EpaComments [(L + (Anchor + { Test20239.hs:3:1-28 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- | Leading Haddock Comment") + { Test20239.hs:1:18-22 })) + ,(L (Anchor { Test20239.hs:7:34-63 } (UnchangedAnchor)) ===================================== testsuite/tests/parser/should_compile/DumpParsedAstComments.hs ===================================== @@ -4,6 +4,10 @@ -} module DumpParsedAstComments where +-- Other comment + +-- comment 1 for foo +-- comment 2 for foo foo = do -- normal comment 1 ===================================== testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr ===================================== @@ -34,15 +34,23 @@ (UnchangedAnchor)) (EpaComment (EpaBlockComment - "{-\n Block comment at the beginning\n -}") - { DumpParsedAstComments.hs:1:1-28 }))] + "{-/n Block comment at the beginning/n -}") + { DumpParsedAstComments.hs:1:1-28 })) + ,(L + (Anchor + { DumpParsedAstComments.hs:7:1-16 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- Other comment") + { DumpParsedAstComments.hs:5:30-34 }))] [(L (Anchor - { DumpParsedAstComments.hs:13:1 } + { DumpParsedAstComments.hs:17:1 } (UnchangedAnchor)) (EpaComment (EpaEofComment) - { DumpParsedAstComments.hs:13:1 }))])) + { DumpParsedAstComments.hs:17:1 }))])) (VirtualBraces (1)) (Nothing) @@ -56,47 +64,63 @@ [(L (SrcSpanAnn (EpAnn (Anchor - { DumpParsedAstComments.hs:(7,1)-(9,3) } + { DumpParsedAstComments.hs:(11,1)-(13,3) } (UnchangedAnchor)) (AnnListItem []) (EpaComments [(L (Anchor - { DumpParsedAstComments.hs:11:1-20 } + { DumpParsedAstComments.hs:9:1-20 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- comment 1 for foo") + { DumpParsedAstComments.hs:7:1-16 })) + ,(L + (Anchor + { DumpParsedAstComments.hs:10:1-20 } + (UnchangedAnchor)) + (EpaComment + (EpaLineComment + "-- comment 2 for foo") + { DumpParsedAstComments.hs:9:1-20 })) + ,(L + (Anchor + { DumpParsedAstComments.hs:15:1-20 } (UnchangedAnchor)) (EpaComment (EpaLineComment "-- | Haddock comment") - { DumpParsedAstComments.hs:9:3 - }))])) { DumpParsedAstComments.hs:(7,1)-(9,3) }) + { DumpParsedAstComments.hs:13:3 + }))])) { DumpParsedAstComments.hs:(11,1)-(13,3) }) (ValD (NoExtField) (FunBind (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:7:1-3 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:11:1-3 }) (Unqual {OccName: foo})) (MG (FromSource) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(7,1)-(9,3) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(11,1)-(13,3) }) [(L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(7,1)-(9,3) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(11,1)-(13,3) }) (Match (EpAnn (Anchor - { DumpParsedAstComments.hs:(7,1)-(9,3) } + { DumpParsedAstComments.hs:(11,1)-(13,3) } (UnchangedAnchor)) [] (EpaComments [])) (FunRhs (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:7:1-3 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:11:1-3 }) (Unqual {OccName: foo})) (Prefix) @@ -108,72 +132,72 @@ [(L (SrcSpanAnn (EpAnnNotUsed) - { DumpParsedAstComments.hs:(7,5)-(9,3) }) + { DumpParsedAstComments.hs:(11,5)-(13,3) }) (GRHS (EpAnn (Anchor - { DumpParsedAstComments.hs:(7,5)-(9,3) } + { DumpParsedAstComments.hs:(11,5)-(13,3) } (UnchangedAnchor)) (GrhsAnn (Nothing) - (AddEpAnn AnnEqual (EpaSpan { DumpParsedAstComments.hs:7:5 }))) + (AddEpAnn AnnEqual (EpaSpan { DumpParsedAstComments.hs:11:5 }))) (EpaComments [])) [] (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(7,7)-(9,3) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:(11,7)-(13,3) }) (HsDo (EpAnn (Anchor - { DumpParsedAstComments.hs:(7,7)-(9,3) } + { DumpParsedAstComments.hs:(11,7)-(13,3) } (UnchangedAnchor)) (AnnList (Just (Anchor - { DumpParsedAstComments.hs:9:3 } + { DumpParsedAstComments.hs:13:3 } (UnchangedAnchor))) (Nothing) (Nothing) - [(AddEpAnn AnnDo (EpaSpan { DumpParsedAstComments.hs:7:7-8 }))] + [(AddEpAnn AnnDo (EpaSpan { DumpParsedAstComments.hs:11:7-8 }))] []) (EpaComments [(L (Anchor - { DumpParsedAstComments.hs:8:3-19 } + { DumpParsedAstComments.hs:12:3-19 } (UnchangedAnchor)) (EpaComment (EpaLineComment "-- normal comment") - { DumpParsedAstComments.hs:7:7-8 }))])) + { DumpParsedAstComments.hs:11:7-8 }))])) (DoExpr (Nothing)) (L (SrcSpanAnn (EpAnn (Anchor - { DumpParsedAstComments.hs:9:3 } + { DumpParsedAstComments.hs:13:3 } (UnchangedAnchor)) (AnnList (Just (Anchor - { DumpParsedAstComments.hs:9:3 } + { DumpParsedAstComments.hs:13:3 } (UnchangedAnchor))) (Nothing) (Nothing) [] []) (EpaComments - [])) { DumpParsedAstComments.hs:9:3 }) + [])) { DumpParsedAstComments.hs:13:3 }) [(L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:9:3 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:13:3 }) (BodyStmt (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:9:3 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:13:3 }) (HsOverLit (EpAnn (Anchor - { DumpParsedAstComments.hs:9:3 } + { DumpParsedAstComments.hs:13:3 } (UnchangedAnchor)) (NoEpAnns) (EpaComments @@ -192,37 +216,37 @@ ,(L (SrcSpanAnn (EpAnn (Anchor - { DumpParsedAstComments.hs:12:1-23 } + { DumpParsedAstComments.hs:16:1-23 } (UnchangedAnchor)) (AnnListItem []) (EpaComments - [])) { DumpParsedAstComments.hs:12:1-23 }) + [])) { DumpParsedAstComments.hs:16:1-23 }) (ValD (NoExtField) (FunBind (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:1-4 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:1-4 }) (Unqual {OccName: main})) (MG (FromSource) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:1-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:1-23 }) [(L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:1-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:1-23 }) (Match (EpAnn (Anchor - { DumpParsedAstComments.hs:12:1-23 } + { DumpParsedAstComments.hs:16:1-23 } (UnchangedAnchor)) [] (EpaComments [])) (FunRhs (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:1-4 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:1-4 }) (Unqual {OccName: main})) (Prefix) @@ -234,42 +258,42 @@ [(L (SrcSpanAnn (EpAnnNotUsed) - { DumpParsedAstComments.hs:12:6-23 }) + { DumpParsedAstComments.hs:16:6-23 }) (GRHS (EpAnn (Anchor - { DumpParsedAstComments.hs:12:6-23 } + { DumpParsedAstComments.hs:16:6-23 } (UnchangedAnchor)) (GrhsAnn (Nothing) - (AddEpAnn AnnEqual (EpaSpan { DumpParsedAstComments.hs:12:6 }))) + (AddEpAnn AnnEqual (EpaSpan { DumpParsedAstComments.hs:16:6 }))) (EpaComments [])) [] (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:8-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:8-23 }) (HsApp (EpAnn (Anchor - { DumpParsedAstComments.hs:12:8-23 } + { DumpParsedAstComments.hs:16:8-23 } (UnchangedAnchor)) (NoEpAnns) (EpaComments [])) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:8-15 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:8-15 }) (HsVar (NoExtField) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:8-15 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:8-15 }) (Unqual {OccName: putStrLn})))) (L - (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:12:17-23 }) + (SrcSpanAnn (EpAnnNotUsed) { DumpParsedAstComments.hs:16:17-23 }) (HsLit (EpAnn (Anchor - { DumpParsedAstComments.hs:12:17-23 } + { DumpParsedAstComments.hs:16:17-23 } (UnchangedAnchor)) (NoEpAnns) (EpaComments ===================================== testsuite/tests/printer/Ppr031.hs ===================================== @@ -1,4 +1,5 @@ {-# LANGUAGE ImplicitParams, NamedFieldPuns, ParallelListComp, PatternGuards #-} + spec :: Spec spec = do describe "split4'8" $ do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f3011896aa3dc8cc14bd61ccb68ab09e17c330e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f3011896aa3dc8cc14bd61ccb68ab09e17c330e You're receiving 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 Dec 14 03:20:58 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Dec 2022 22:20:58 -0500 Subject: [Git][ghc/ghc][master] JS: fix object file name comparison (#22578) Message-ID: <6399411a8c578_389fe252710483191@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00 JS: fix object file name comparison (#22578) - - - - - 1 changed file: - compiler/GHC/Driver/Pipeline/Execute.hs Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -388,7 +388,14 @@ runJsPhase pipe_env hsc_env input_fn = do -- ensure the timestamp is refreshed, see Note [JS Backend .o file procedure]. If -- they are not the same then we embed the .js file into a .o file with the -- addition of a header - if (input_fn /= output_fn) + -- + -- We need to canonicalize the paths, otherwise the comparison can return + -- wrong results (e.g. with Cabal using paths containing "build/./Foo/..." + -- that are compared to "build/Foo/..."). + -- + cin <- canonicalizePath input_fn + cout <- canonicalizePath output_fn + if (not (equalFilePath cin cout)) then embedJsFile logger dflags tmpfs unit_env input_fn output_fn else touchObjectFile logger dflags output_fn View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8b1f1b4503b810c40d37af797f1c7c566250c3d0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8b1f1b4503b810c40d37af797f1c7c566250c3d0 You're receiving 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 Dec 14 03:21:20 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Dec 2022 22:21:20 -0500 Subject: [Git][ghc/ghc][master] configure: Bump min bootstrap GHC version to 9.2 Message-ID: <6399413053883_389fe2161ceccc48661f@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 1 changed file: - configure.ac Changes: ===================================== configure.ac ===================================== @@ -224,7 +224,7 @@ if test "$WithGhc" = "" then AC_MSG_ERROR([GHC is required.]) fi -MinBootGhcVersion="9.0" +MinBootGhcVersion="9.2" FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9e161bb8f416a0cfd1ba7918f9ffafb19cd8372 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e9e161bb8f416a0cfd1ba7918f9ffafb19cd8372 You're receiving 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 Dec 14 03:51:57 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 13 Dec 2022 22:51:57 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 18 commits: Respect -XStrict in the pattern-match checker (#21761) Message-ID: <6399485dca87f_389fe218b96e4c4898f9@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00 JS: fix object file name comparison (#22578) - - - - - e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 453e48f3 by Ben Gamari at 2022-12-13T22:51:48-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - bbdfc72b by Ben Gamari at 2022-12-13T22:51:48-05:00 cmm: Introduce blockConcat - - - - - e5cddafa by Ben Gamari at 2022-12-13T22:51:48-05:00 cmm: Introduce MemoryOrderings - - - - - 23eac4dc by Ben Gamari at 2022-12-13T22:51:48-05:00 llvm: Respect memory specified orderings - - - - - b94f186a by Ben Gamari at 2022-12-13T22:51:48-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 8f73115f by Ben Gamari at 2022-12-13T22:51:48-05:00 cmm/Parser: Reduce some repetition - - - - - bffb67ba by Ben Gamari at 2022-12-13T22:51:49-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - c4e14d99 by Ben Gamari at 2022-12-13T22:51:49-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 6d92b5fd by Ben Gamari at 2022-12-13T22:51:49-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - f3002b00 by Ben Gamari at 2022-12-13T22:51:49-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 4bf5429f by Ben Gamari at 2022-12-13T22:51:49-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 791ff2e5 by Ben Gamari at 2022-12-13T22:51:49-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 98ca53c9 by Ryan Scott at 2022-12-13T22:51:49-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.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/71da829377c50062b2499910be7d219036ad6adc...98ca53c9ce33dc72e798c8c4a439275019484374 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/71da829377c50062b2499910be7d219036ad6adc...98ca53c9ce33dc72e798c8c4a439275019484374 You're receiving 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 Dec 14 08:25:41 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 14 Dec 2022 03:25:41 -0500 Subject: [Git][ghc/ghc][wip/T22459] 6 commits: Respect -XStrict in the pattern-match checker (#21761) Message-ID: <63998885b8fe2_389fe25267051232c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22459 at Glasgow Haskell Compiler / GHC Commits: e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00 JS: fix object file name comparison (#22578) - - - - - e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 62ca7147 by Simon Peyton Jones at 2022-12-14T08:25:36+00:00 Abstract over the right free vars Fix #22459, in two ways: (1) Make the Specialiser not create a bogus specialisation if it is presented by strangely polymorphic dictionary. See Note [Weird special case in SpecDict] in GHC.Core.Opt.Specialise (2) Be more careful in abstractFloats See Note [Which type variables to abstract over] in GHC.Core.Opt.Simplify.Utils. So (2) stops creating the excessively polymorphic dictionary in abstractFloats, while (1) stops crashing if some other pass should nevertheless create a weirdly polymorphic dictionary. - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser/Lexer.x - configure.ac - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/ghc-api/exactprint/Test20239.stderr - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - testsuite/tests/parser/should_compile/DumpParsedAstComments.hs - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr - + testsuite/tests/pmcheck/should_compile/T21761.hs - + testsuite/tests/pmcheck/should_compile/T21761.stderr - testsuite/tests/pmcheck/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/7bf221fafb50f80d0326e1095a75f4105016e354...62ca714781b6ef07dcaa13e6fcffa4ae0f83b677 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7bf221fafb50f80d0326e1095a75f4105016e354...62ca714781b6ef07dcaa13e6fcffa4ae0f83b677 You're receiving 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 Dec 14 08:28:21 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 14 Dec 2022 03:28:21 -0500 Subject: [Git][ghc/ghc][wip/T22547] 6 commits: Respect -XStrict in the pattern-match checker (#21761) Message-ID: <639989254c6bb_389fe2202f1ac8517814@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22547 at Glasgow Haskell Compiler / GHC Commits: e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00 JS: fix object file name comparison (#22578) - - - - - e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 9f62efb4 by Simon Peyton Jones at 2022-12-14T08:28:17+00:00 Fix bogus test in Lint The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation. - - - - - 30 changed files: - compiler/GHC/Core.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/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser/Lexer.x - configure.ac - testsuite/tests/deSugar/should_compile/T13208.stdout - testsuite/tests/ghc-api/exactprint/Test20239.stderr - + testsuite/tests/indexed-types/should_compile/T22547.hs - testsuite/tests/indexed-types/should_compile/all.T - testsuite/tests/numeric/should_compile/T14170.stdout - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - testsuite/tests/parser/should_compile/DumpParsedAstComments.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a547a406ba5021e51125fa165dc961c3a6ad727...9f62efb46d13e5c89c6aea14d3a8900fb432f797 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a547a406ba5021e51125fa165dc961c3a6ad727...9f62efb46d13e5c89c6aea14d3a8900fb432f797 You're receiving 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 Dec 14 08:52:28 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Dec 2022 03:52:28 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 13 commits: hadrian: Don't enable TSAN in stage0 build Message-ID: <63998eccb28c1_389fe25265c53027a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a19e12c5 by Ben Gamari at 2022-12-14T03:52:05-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - 400dc74c by Ben Gamari at 2022-12-14T03:52:05-05:00 cmm: Introduce blockConcat - - - - - 7c580c72 by Ben Gamari at 2022-12-14T03:52:05-05:00 cmm: Introduce MemoryOrderings - - - - - 6ec02d22 by Ben Gamari at 2022-12-14T03:52:05-05:00 llvm: Respect memory specified orderings - - - - - fbf5cdb8 by Ben Gamari at 2022-12-14T03:52:06-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - ffd7d35a by Ben Gamari at 2022-12-14T03:52:06-05:00 cmm/Parser: Reduce some repetition - - - - - ba66864a by Ben Gamari at 2022-12-14T03:52:06-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - e6f51cea by Ben Gamari at 2022-12-14T03:52:06-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - c3352183 by Ben Gamari at 2022-12-14T03:52:06-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - dc3b6cf0 by Ben Gamari at 2022-12-14T03:52:06-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 596fc51e by Ben Gamari at 2022-12-14T03:52:06-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 25a0235d by Ben Gamari at 2022-12-14T03:52:06-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 490b79cb by Ryan Scott at 2022-12-14T03:52:06-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Validity.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - hadrian/src/Flavour.hs - rts/HeapStackCheck.cmm - + rts/TSANUtils.c - rts/include/rts/TSANUtils.h - rts/rts.cabal.in - + testsuite/tests/typecheck/should_fail/T22570.hs - + testsuite/tests/typecheck/should_fail/T22570.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Cmm/Config.hs ===================================== @@ -19,6 +19,7 @@ data CmmConfig = CmmConfig , cmmDoLinting :: !Bool -- ^ Do Cmm Linting Optimization or not , cmmOptElimCommonBlks :: !Bool -- ^ Eliminate common blocks or not , cmmOptSink :: !Bool -- ^ Perform sink after stack layout or not + , cmmOptThreadSanitizer :: !Bool -- ^ Instrument memory accesses for ThreadSanitizer , cmmGenStackUnwindInstr :: !Bool -- ^ Generate stack unwinding instructions (for debugging) , cmmExternalDynamicRefs :: !Bool -- ^ Generate code to link against dynamic libraries , cmmDoCmmSwitchPlans :: !Bool -- ^ Should the Cmm pass replace Stg switch statements ===================================== compiler/GHC/Cmm/ContFlowOpt.hs ===================================== @@ -10,7 +10,7 @@ where import GHC.Prelude hiding (succ, unzip, zip) -import GHC.Cmm.Dataflow.Block +import GHC.Cmm.Dataflow.Block hiding (blockConcat) import GHC.Cmm.Dataflow.Collections import GHC.Cmm.Dataflow.Graph import GHC.Cmm.Dataflow.Label ===================================== compiler/GHC/Cmm/Dataflow/Block.hs ===================================== @@ -14,6 +14,7 @@ module GHC.Cmm.Dataflow.Block , IndexedCO , Block(..) , blockAppend + , blockConcat , blockCons , blockFromList , blockJoin @@ -136,6 +137,8 @@ blockJoin f b t = BlockCC f b t blockAppend :: Block n e O -> Block n O x -> Block n e x blockAppend = cat +blockConcat :: [Block n O O] -> Block n O O +blockConcat = foldr blockAppend emptyBlock -- Taking apart ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -94,6 +94,10 @@ $white_no_nl+ ; "!=" { kw CmmT_Ne } "&&" { kw CmmT_BoolAnd } "||" { kw CmmT_BoolOr } + "%relaxed" { kw CmmT_Relaxed } + "%acquire" { kw CmmT_Acquire } + "%release" { kw CmmT_Release } + "%seq_cst" { kw CmmT_SeqCst } "True" { kw CmmT_True } "False" { kw CmmT_False } @@ -183,6 +187,10 @@ data CmmToken | CmmT_False | CmmT_True | CmmT_likely + | CmmT_Relaxed + | CmmT_Acquire + | CmmT_Release + | CmmT_SeqCst deriving (Show) -- ----------------------------------------------------------------------------- ===================================== compiler/GHC/Cmm/MachOp.hs ===================================== @@ -24,6 +24,7 @@ module GHC.Cmm.MachOp , machOpMemcpyishAlign -- Atomic read-modify-write + , MemoryOrdering(..) , AtomicMachOp(..) ) where @@ -662,10 +663,12 @@ data CallishMachOp | MO_BSwap Width | MO_BRev Width - -- Atomic read-modify-write. + -- | Atomic read-modify-write. Arguments are @[dest, n]@. | MO_AtomicRMW Width AtomicMachOp - | MO_AtomicRead Width - | MO_AtomicWrite Width + -- | Atomic read. Arguments are @[addr]@. + | MO_AtomicRead Width MemoryOrdering + -- | Atomic write. Arguments are @[addr, value]@. + | MO_AtomicWrite Width MemoryOrdering -- | Atomic compare-and-swap. Arguments are @[dest, expected, new]@. -- Sequentially consistent. -- Possible future refactoring: should this be an'MO_AtomicRMW' variant? @@ -680,6 +683,14 @@ data CallishMachOp | MO_ResumeThread deriving (Eq, Show) +-- | C11 memory ordering semantics. +data MemoryOrdering + = MemOrderRelaxed -- ^ relaxed ordering + | MemOrderAcquire -- ^ acquire ordering + | MemOrderRelease -- ^ release ordering + | MemOrderSeqCst -- ^ sequentially consistent + deriving (Eq, Ord, Show) + -- | The operation to perform atomically. data AtomicMachOp = AMO_Add ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -194,6 +194,27 @@ convention. Note if a field is longer than a word (e.g. a D_ on a 32-bit machine) then the call will push as many words as necessary to the stack to accommodate it (e.g. 2). +Memory ordering +--------------- + +Cmm respects the C11 memory model and distinguishes between non-atomic and +atomic memory accesses. In C11 fashion, atomic accesses can provide a number of +memory ordering guarantees. These are supported in Cmm syntax as follows: + + W_[ptr] = ...; // a non-atomic store + %relaxed W_[ptr] = ...; // an atomic store with relaxed ordering semantics + %release W_[ptr] = ...; // an atomic store with release ordering semantics + + x = W_(ptr); // a non-atomic load + x = %relaxed W_[ptr]; // an atomic load with relaxed ordering + x = %acquire W_[ptr]; // an atomic load with acquire ordering + // or equivalently... + x = prim %load_acquire64(ptr); + +Here we used W_ as an example but these operations can be used on all Cmm +types. + +See Note [Heap memory barriers] in SMP.h for details. ----------------------------------------------------------------------------- -} @@ -313,6 +334,10 @@ import qualified Data.ByteString.Char8 as BS8 'True' { L _ (CmmT_True ) } 'False' { L _ (CmmT_False) } 'likely'{ L _ (CmmT_likely)} + 'relaxed'{ L _ (CmmT_Relaxed)} + 'acquire'{ L _ (CmmT_Acquire)} + 'release'{ L _ (CmmT_Release)} + 'seq_cst'{ L _ (CmmT_SeqCst)} 'CLOSURE' { L _ (CmmT_CLOSURE) } 'INFO_TABLE' { L _ (CmmT_INFO_TABLE) } @@ -627,8 +652,23 @@ stmt :: { CmmParse () } | lreg '=' expr ';' { do reg <- $1; e <- $3; withSourceNote $2 $4 (emitAssign reg e) } + + -- Use lreg instead of local_reg to avoid ambiguity + | lreg '=' mem_ordering type '[' expr ']' ';' + { do reg <- $1; + let lreg = case reg of + { CmmLocal r -> r + ; other -> pprPanic "CmmParse:" (ppr reg <> text "not a local register") + } ; + mord <- $3; + let { ty = $4; w = typeWidth ty }; + e <- $6; + let op = MO_AtomicRead w mord; + withSourceNote $2 $7 $ code (emitPrimCall [lreg] op [e]) } + | mem_ordering type '[' expr ']' '=' expr ';' + { do mord <- $1; withSourceNote $3 $8 (doStore (Just mord) $2 $4 $7) } | type '[' expr ']' '=' expr ';' - { withSourceNote $2 $7 (doStore $1 $3 $6) } + { withSourceNote $2 $7 (doStore Nothing $1 $3 $6) } -- Gah! We really want to say "foreign_results" but that causes -- a shift/reduce conflict with assignment. We either @@ -678,6 +718,14 @@ unwind_regs | GLOBALREG '=' expr_or_unknown { do e <- $3; return [($1, e)] } +-- | A memory ordering +mem_ordering :: { CmmParse MemoryOrdering } +mem_ordering + : 'relaxed' { do return MemOrderRelaxed } + | 'release' { do return MemOrderRelease } + | 'acquire' { do return MemOrderAcquire } + | 'seq_cst' { do return MemOrderSeqCst } + -- | Used by unwind to indicate unknown unwinding values. expr_or_unknown :: { CmmParse (Maybe CmmExpr) } @@ -953,6 +1001,7 @@ exprMacros profile align_check = listToUFM [ platform = profilePlatform profile -- we understand a subset of C-- primitives: +machOps :: UniqFM FastString (Width -> MachOp) machOps = listToUFM $ map (\(x, y) -> (mkFastString x, y)) [ ( "add", MO_Add ), @@ -1073,37 +1122,32 @@ callishMachOps platform = listToUFM $ ( "suspendThread", (MO_SuspendThread,) ), ( "resumeThread", (MO_ResumeThread,) ), - ("prefetch0", (MO_Prefetch_Data 0,)), - ("prefetch1", (MO_Prefetch_Data 1,)), - ("prefetch2", (MO_Prefetch_Data 2,)), - ("prefetch3", (MO_Prefetch_Data 3,)), - - ( "popcnt8", (MO_PopCnt W8,)), - ( "popcnt16", (MO_PopCnt W16,)), - ( "popcnt32", (MO_PopCnt W32,)), - ( "popcnt64", (MO_PopCnt W64,)), - - ( "pdep8", (MO_Pdep W8,)), - ( "pdep16", (MO_Pdep W16,)), - ( "pdep32", (MO_Pdep W32,)), - ( "pdep64", (MO_Pdep W64,)), - - ( "pext8", (MO_Pext W8,)), - ( "pext16", (MO_Pext W16,)), - ( "pext32", (MO_Pext W32,)), - ( "pext64", (MO_Pext W64,)), - - ( "cmpxchg8", (MO_Cmpxchg W8,)), - ( "cmpxchg16", (MO_Cmpxchg W16,)), - ( "cmpxchg32", (MO_Cmpxchg W32,)), - ( "cmpxchg64", (MO_Cmpxchg W64,)), - - ( "xchg8", (MO_Xchg W8,)), - ( "xchg16", (MO_Xchg W16,)), - ( "xchg32", (MO_Xchg W32,)), - ( "xchg64", (MO_Xchg W64,)) + ( "prefetch0", (MO_Prefetch_Data 0,)), + ( "prefetch1", (MO_Prefetch_Data 1,)), + ( "prefetch2", (MO_Prefetch_Data 2,)), + ( "prefetch3", (MO_Prefetch_Data 3,)) + ] ++ concat + [ allWidths "popcnt" MO_PopCnt + , allWidths "pdep" MO_Pdep + , allWidths "pext" MO_Pext + , allWidths "cmpxchg" MO_Cmpxchg + , allWidths "xchg" MO_Xchg + , allWidths "load_relaxed" (\w -> MO_AtomicRead w MemOrderAcquire) + , allWidths "load_acquire" (\w -> MO_AtomicRead w MemOrderAcquire) + , allWidths "load_seqcst" (\w -> MO_AtomicRead w MemOrderSeqCst) + , allWidths "store_release" (\w -> MO_AtomicWrite w MemOrderRelease) + , allWidths "store_seqcst" (\w -> MO_AtomicWrite w MemOrderSeqCst) ] where + allWidths + :: String + -> (Width -> CallishMachOp) + -> [(FastString, a -> (CallishMachOp, a))] + allWidths name f = + [ (mkFastString $ name ++ show (widthInBits w), (f w,)) + | w <- [W8, W16, W32, W64] + ] + memcpyLikeTweakArgs :: (Int -> CallishMachOp) -> [CmmExpr] -> (CallishMachOp, [CmmExpr]) memcpyLikeTweakArgs op [] = pgmError "memcpy-like function requires at least one argument" memcpyLikeTweakArgs op args@(_:_) = @@ -1347,8 +1391,12 @@ primCall results_code name args_code let (p, args') = f args code (emitPrimCall (map fst results) p args') -doStore :: CmmType -> CmmParse CmmExpr -> CmmParse CmmExpr -> CmmParse () -doStore rep addr_code val_code +doStore :: Maybe MemoryOrdering + -> CmmType + -> CmmParse CmmExpr -- ^ address + -> CmmParse CmmExpr -- ^ value + -> CmmParse () +doStore mem_ord rep addr_code val_code = do platform <- getPlatform addr <- addr_code val <- val_code @@ -1362,7 +1410,7 @@ doStore rep addr_code val_code let coerce_val | val_width /= rep_width = CmmMachOp (MO_UU_Conv val_width rep_width) [val] | otherwise = val - emitStore addr coerce_val + emitStore mem_ord addr coerce_val -- ----------------------------------------------------------------------------- -- If-then-else and boolean expressions ===================================== compiler/GHC/Cmm/Pipeline.hs ===================================== @@ -19,6 +19,7 @@ import GHC.Cmm.LayoutStack import GHC.Cmm.ProcPoint import GHC.Cmm.Sink import GHC.Cmm.Switch.Implement +import GHC.Cmm.ThreadSanitizer import GHC.Types.Unique.Supply @@ -98,6 +99,13 @@ cpsTop logger platform cfg proc = else pure g dump Opt_D_dump_cmm_switch "Post switch plan" g + ----------- ThreadSanitizer instrumentation ----------------------------- + g <- {-# SCC "annotateTSAN" #-} + if cmmOptThreadSanitizer cfg + then runUniqSM $ annotateTSAN platform g + else return g + dump Opt_D_dump_cmm_thread_sanitizer "ThreadSanitizer instrumentation" g + ----------- Proc points ------------------------------------------------- let call_pps :: ProcPointSet -- LabelMap ===================================== compiler/GHC/Cmm/ThreadSanitizer.hs ===================================== @@ -0,0 +1,285 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} + +-- | Annotate a CmmGraph with ThreadSanitizer instrumentation calls. +module GHC.Cmm.ThreadSanitizer (annotateTSAN) where + +import GHC.Prelude + +import GHC.StgToCmm.Utils (get_GlobalReg_addr) +import GHC.Platform +import GHC.Platform.Regs (activeStgRegs, callerSaves) +import GHC.Cmm +import GHC.Cmm.Utils +import GHC.Cmm.CLabel +import GHC.Cmm.Dataflow +import GHC.Cmm.Dataflow.Block +import GHC.Cmm.Dataflow.Graph +import GHC.Data.FastString +import GHC.Types.Basic +import GHC.Types.ForeignCall +import GHC.Types.Unique +import GHC.Types.Unique.Supply + +import Data.Maybe (fromMaybe) + +data Env = Env { platform :: Platform + , uniques :: [Unique] + } + +annotateTSAN :: Platform -> CmmGraph -> UniqSM CmmGraph +annotateTSAN platform graph = do + env <- Env platform <$> getUniquesM + return $ modifyGraph (mapGraphBlocks (annotateBlock env)) graph + +mapBlockList :: (forall e' x'. n e' x' -> Block n e' x') + -> Block n e x -> Block n e x +mapBlockList f (BlockCO n rest ) = f n `blockAppend` mapBlockList f rest +mapBlockList f (BlockCC n rest m) = f n `blockAppend` mapBlockList f rest `blockAppend` f m +mapBlockList f (BlockOC rest m) = mapBlockList f rest `blockAppend` f m +mapBlockList _ BNil = BNil +mapBlockList f (BMiddle blk) = f blk +mapBlockList f (BCat a b) = mapBlockList f a `blockAppend` mapBlockList f b +mapBlockList f (BSnoc a n) = mapBlockList f a `blockAppend` f n +mapBlockList f (BCons n a) = f n `blockAppend` mapBlockList f a + +annotateBlock :: Env -> Block CmmNode e x -> Block CmmNode e x +annotateBlock env = mapBlockList (annotateNode env) + +annotateNode :: Env -> CmmNode e x -> Block CmmNode e x +annotateNode env node = + case node of + CmmEntry{} -> BlockCO node BNil + CmmComment{} -> BMiddle node + CmmTick{} -> BMiddle node + CmmUnwind{} -> BMiddle node + CmmAssign{} -> annotateNodeOO env node + CmmStore lhs rhs align -> + let ty = cmmExprType (platform env) rhs + rhs_nodes = annotateLoads env (collectExprLoads rhs) + lhs_nodes = annotateLoads env (collectExprLoads lhs) + st = tsanStore env align ty lhs + in rhs_nodes `blockAppend` lhs_nodes `blockAppend` st `blockSnoc` node + CmmUnsafeForeignCall (PrimTarget op) formals args -> + let node' = fromMaybe (BMiddle node) (annotatePrim env op formals args) + arg_nodes = blockConcat $ map (annotateExpr env) args + in arg_nodes `blockAppend` node' + CmmUnsafeForeignCall{} -> annotateNodeOO env node + CmmBranch{} -> annotateNodeOC env node + CmmCondBranch{} -> annotateNodeOC env node + CmmSwitch{} -> annotateNodeOC env node + CmmCall{} -> annotateNodeOC env node + CmmForeignCall{} -> annotateNodeOC env node + +annotateNodeOO :: Env -> CmmNode O O -> Block CmmNode O O +annotateNodeOO env node = + annotateLoads env (collectLoadsNode node) `blockSnoc` node + +annotateNodeOC :: Env -> CmmNode O C -> Block CmmNode O C +annotateNodeOC env node = + annotateLoads env (collectLoadsNode node) `blockJoinTail` node + +annotateExpr :: Env -> CmmExpr -> Block CmmNode O O +annotateExpr env expr = + annotateLoads env (collectExprLoads expr) + +data Load = Load CmmType AlignmentSpec CmmExpr + +annotateLoads :: Env -> [Load] -> Block CmmNode O O +annotateLoads env loads = + blockConcat + [ tsanLoad env align ty addr + | Load ty align addr <- loads + ] + +collectLoadsNode :: CmmNode e x -> [Load] +collectLoadsNode node = + foldExp (\exp rest -> collectExprLoads exp ++ rest) node [] + +-- | Collect all of the memory locations loaded from by a 'CmmExpr'. +collectExprLoads :: CmmExpr -> [Load] +collectExprLoads (CmmLit _) = [] +collectExprLoads (CmmLoad e ty align) = [Load ty align e] +collectExprLoads (CmmReg _) = [] +collectExprLoads (CmmMachOp _op args) = foldMap collectExprLoads args +collectExprLoads (CmmStackSlot _ _) = [] +collectExprLoads (CmmRegOff _ _) = [] + +-- | Generate TSAN instrumentation for a 'CallishMachOp' occurrence. +annotatePrim :: Env + -> CallishMachOp -- ^ the applied operation + -> [CmmFormal] -- ^ results + -> [CmmActual] -- ^ arguments + -> Maybe (Block CmmNode O O) + -- ^ 'Just' a block of instrumentation, if applicable +annotatePrim env (MO_AtomicRMW w aop) [dest] [addr, val] = Just $ tsanAtomicRMW env MemOrderSeqCst aop w addr val dest +annotatePrim env (MO_AtomicRead w mord) [dest] [addr] = Just $ tsanAtomicLoad env mord w addr dest +annotatePrim env (MO_AtomicWrite w mord) [] [addr, val] = Just $ tsanAtomicStore env mord w val addr +annotatePrim env (MO_Xchg w) [dest] [addr, val] = Just $ tsanAtomicExchange env MemOrderSeqCst w val addr dest +annotatePrim env (MO_Cmpxchg w) [dest] [addr, expected, new] + = Just $ tsanAtomicCas env MemOrderSeqCst MemOrderSeqCst w addr expected new dest +annotatePrim _ _ _ _ = Nothing + +mkUnsafeCall :: Env + -> ForeignTarget -- ^ function + -> [CmmFormal] -- ^ results + -> [CmmActual] -- ^ arguments + -> Block CmmNode O O +mkUnsafeCall env ftgt formals args = + save `blockAppend` -- save global registers + bind_args `blockSnoc` -- bind arguments to local registers + call `blockAppend` -- perform call + restore -- restore global registers + where + -- We are rather conservative here and just save/restore all GlobalRegs. + (save, restore) = saveRestoreCallerRegs (platform env) + + -- We also must be careful not to mention caller-saved registers in + -- arguments as Cmm-Lint checks this. To accomplish this we instead bind + -- the arguments to local registers. + arg_regs :: [CmmReg] + arg_regs = zipWith arg_reg (uniques env) args + where + arg_reg :: Unique -> CmmExpr -> CmmReg + arg_reg u expr = CmmLocal $ LocalReg u (cmmExprType (platform env) expr) + + bind_args :: Block CmmNode O O + bind_args = blockConcat $ zipWith (\r e -> BMiddle $ CmmAssign r e) arg_regs args + + call = CmmUnsafeForeignCall ftgt formals (map CmmReg arg_regs) + +saveRestoreCallerRegs :: Platform + -> (Block CmmNode O O, Block CmmNode O O) +saveRestoreCallerRegs platform = + (save, restore) + where + regs = filter (callerSaves platform) (activeStgRegs platform) + + save = blockFromList (map saveReg regs) + saveReg reg = + CmmStore (get_GlobalReg_addr platform reg) + (CmmReg (CmmGlobal reg)) + NaturallyAligned + + restore = blockFromList (map restoreReg regs) + restoreReg reg = + CmmAssign (CmmGlobal reg) + (CmmLoad (get_GlobalReg_addr platform reg) + (globalRegType platform reg) + NaturallyAligned) + +-- | Mirrors __tsan_memory_order +-- +memoryOrderToTsanMemoryOrder :: Env -> MemoryOrdering -> CmmExpr +memoryOrderToTsanMemoryOrder env mord = + mkIntExpr (platform env) n + where + n = case mord of + MemOrderRelaxed -> 0 + MemOrderAcquire -> 2 + MemOrderRelease -> 3 + MemOrderSeqCst -> 5 + +tsanTarget :: FastString -- ^ function name + -> [ForeignHint] -- ^ formals + -> [ForeignHint] -- ^ arguments + -> ForeignTarget +tsanTarget fn formals args = + ForeignTarget (CmmLit (CmmLabel lbl)) conv + where + conv = ForeignConvention CCallConv args formals CmmMayReturn + lbl = mkForeignLabel fn Nothing ForeignLabelInExternalPackage IsFunction + +tsanStore :: Env + -> AlignmentSpec -> CmmType -> CmmExpr + -> Block CmmNode O O +tsanStore env align ty addr = + mkUnsafeCall env ftarget [] [addr] + where + ftarget = tsanTarget fn [] [AddrHint] + w = widthInBytes (typeWidth ty) + fn = case align of + Unaligned + | w > 1 -> fsLit $ "__tsan_unaligned_write" ++ show w + _ -> fsLit $ "__tsan_write" ++ show w + +tsanLoad :: Env + -> AlignmentSpec -> CmmType -> CmmExpr + -> Block CmmNode O O +tsanLoad env align ty addr = + mkUnsafeCall env ftarget [] [addr] + where + ftarget = tsanTarget fn [] [AddrHint] + w = widthInBytes (typeWidth ty) + fn = case align of + Unaligned + | w > 1 -> fsLit $ "__tsan_unaligned_read" ++ show w + _ -> fsLit $ "__tsan_read" ++ show w + +tsanAtomicStore :: Env + -> MemoryOrdering -> Width -> CmmExpr -> CmmExpr + -> Block CmmNode O O +tsanAtomicStore env mord w val addr = + mkUnsafeCall env ftarget [] [addr, val, mord'] + where + mord' = memoryOrderToTsanMemoryOrder env mord + ftarget = tsanTarget fn [] [AddrHint, NoHint, NoHint] + fn = fsLit $ "__tsan_atomic" ++ show (widthInBits w) ++ "_store" + +tsanAtomicLoad :: Env + -> MemoryOrdering -> Width -> CmmExpr -> LocalReg + -> Block CmmNode O O +tsanAtomicLoad env mord w addr dest = + mkUnsafeCall env ftarget [dest] [addr, mord'] + where + mord' = memoryOrderToTsanMemoryOrder env mord + ftarget = tsanTarget fn [NoHint] [AddrHint, NoHint] + fn = fsLit $ "__tsan_atomic" ++ show (widthInBits w) ++ "_load" + +tsanAtomicExchange :: Env + -> MemoryOrdering -> Width -> CmmExpr -> CmmExpr -> LocalReg + -> Block CmmNode O O +tsanAtomicExchange env mord w val addr dest = + mkUnsafeCall env ftarget [dest] [addr, val, mord'] + where + mord' = memoryOrderToTsanMemoryOrder env mord + ftarget = tsanTarget fn [NoHint] [AddrHint, NoHint, NoHint] + fn = fsLit $ "__tsan_atomic" ++ show (widthInBits w) ++ "_exchange" + +-- N.B. C11 CAS returns a boolean (to avoid the ABA problem) whereas Cmm's CAS +-- returns the expected value. We use define a shim in the RTS to provide +-- Cmm's semantics using the TSAN C11 primitive. +tsanAtomicCas :: Env + -> MemoryOrdering -- ^ success ordering + -> MemoryOrdering -- ^ failure ordering + -> Width + -> CmmExpr -- ^ address + -> CmmExpr -- ^ expected value + -> CmmExpr -- ^ new value + -> LocalReg -- ^ result destination + -> Block CmmNode O O +tsanAtomicCas env mord_success mord_failure w addr expected new dest = + mkUnsafeCall env ftarget [dest] [addr, expected, new, mord_success', mord_failure'] + where + mord_success' = memoryOrderToTsanMemoryOrder env mord_success + mord_failure' = memoryOrderToTsanMemoryOrder env mord_failure + ftarget = tsanTarget fn [NoHint] [AddrHint, NoHint, NoHint, NoHint, NoHint] + fn = fsLit $ "ghc_tsan_atomic" ++ show (widthInBits w) ++ "_compare_exchange" + +tsanAtomicRMW :: Env + -> MemoryOrdering -> AtomicMachOp -> Width -> CmmExpr -> CmmExpr -> LocalReg + -> Block CmmNode O O +tsanAtomicRMW env mord op w addr val dest = + mkUnsafeCall env ftarget [dest] [addr, val, mord'] + where + mord' = memoryOrderToTsanMemoryOrder env mord + ftarget = tsanTarget fn [NoHint] [AddrHint, NoHint, NoHint] + op' = case op of + AMO_Add -> "fetch_add" + AMO_Sub -> "fetch_sub" + AMO_And -> "fetch_and" + AMO_Nand -> "fetch_nand" + AMO_Or -> "fetch_or" + AMO_Xor -> "fetch_xor" + fn = fsLit $ "__tsan_atomic" ++ show (widthInBits w) ++ "_" ++ op' + ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -1533,8 +1533,8 @@ genCCall target dest_regs arg_regs bid = do -- -- Atomic read-modify-write. MO_AtomicRMW w amop -> mkCCall (atomicRMWLabel w amop) - MO_AtomicRead w -> mkCCall (atomicReadLabel w) - MO_AtomicWrite w -> mkCCall (atomicWriteLabel w) + MO_AtomicRead w _ -> mkCCall (atomicReadLabel w) + MO_AtomicWrite w _ -> mkCCall (atomicWriteLabel w) MO_Cmpxchg w -> mkCCall (cmpxchgLabel w) -- -- Should be an AtomicRMW variant eventually. -- -- Sequential consistent. ===================================== compiler/GHC/CmmToAsm/PPC/CodeGen.hs ===================================== @@ -1173,7 +1173,7 @@ genCCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n] (n_reg, n_code) <- getSomeReg n return (op dst dst (RIReg n_reg), n_code) -genCCall (PrimTarget (MO_AtomicRead width)) [dst] [addr] +genCCall (PrimTarget (MO_AtomicRead width _)) [dst] [addr] = do let fmt = intFormat width reg_dst = getLocalRegReg dst form = if widthInBits width == 64 then DS else D @@ -1200,7 +1200,7 @@ genCCall (PrimTarget (MO_AtomicRead width)) [dst] [addr] -- This is also what gcc does. -genCCall (PrimTarget (MO_AtomicWrite width)) [] [addr, val] = do +genCCall (PrimTarget (MO_AtomicWrite width _)) [] [addr, val] = do code <- assignMem_IntCode (intFormat width) addr val return $ unitOL HWSYNC `appOL` code @@ -2067,8 +2067,8 @@ genCCall' config gcp target dest_regs args MO_AtomicRMW {} -> unsupported MO_Cmpxchg w -> (cmpxchgLabel w, False) MO_Xchg w -> (xchgLabel w, False) - MO_AtomicRead _ -> unsupported - MO_AtomicWrite _ -> unsupported + MO_AtomicRead _ _ -> unsupported + MO_AtomicWrite _ _ -> unsupported MO_S_Mul2 {} -> unsupported MO_S_QuotRem {} -> unsupported ===================================== compiler/GHC/CmmToAsm/Wasm/FromCmm.hs ===================================== @@ -1304,7 +1304,7 @@ lower_CallishMachOp lbl (MO_AtomicRMW w0 op) rs xs = CmmMayReturn rs xs -lower_CallishMachOp lbl (MO_AtomicRead w0) [reg] [ptr] = do +lower_CallishMachOp lbl (MO_AtomicRead w0 _) [reg] [ptr] = do SomeWasmExpr ty (WasmExpr ret_instr) <- lower_CmmLoad lbl @@ -1313,7 +1313,7 @@ lower_CallishMachOp lbl (MO_AtomicRead w0) [reg] [ptr] = do NaturallyAligned ri <- onCmmLocalReg_Typed ty reg pure $ WasmStatements $ ret_instr `WasmConcat` WasmLocalSet ty ri -lower_CallishMachOp lbl (MO_AtomicWrite _) [] [ptr, val] = +lower_CallishMachOp lbl (MO_AtomicWrite _ _) [] [ptr, val] = lower_CmmStore lbl ptr val NaturallyAligned lower_CallishMachOp lbl (MO_Cmpxchg w0) rs xs = lower_MO_Cmpxchg lbl w0 rs xs lower_CallishMachOp lbl (MO_Xchg w0) rs xs = ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -2203,8 +2203,8 @@ genSimplePrim bid (MO_Pdep width) [dst] [src,mask] = genPdep bid widt genSimplePrim bid (MO_Pext width) [dst] [src,mask] = genPext bid width dst src mask genSimplePrim bid (MO_Clz width) [dst] [src] = genClz bid width dst src genSimplePrim bid (MO_UF_Conv width) [dst] [src] = genWordToFloat bid width dst src -genSimplePrim _ (MO_AtomicRead w) [dst] [addr] = genAtomicRead w dst addr -genSimplePrim _ (MO_AtomicWrite w) [] [addr,val] = genAtomicWrite w addr val +genSimplePrim _ (MO_AtomicRead w mo) [dst] [addr] = genAtomicRead w mo dst addr +genSimplePrim _ (MO_AtomicWrite w mo) [] [addr,val] = genAtomicWrite w mo addr val genSimplePrim bid (MO_Cmpxchg width) [dst] [addr,old,new] = genCmpXchg bid width dst addr old new genSimplePrim _ (MO_Xchg width) [dst] [addr, value] = genXchg width dst addr value genSimplePrim _ (MO_AddWordC w) [r,c] [x,y] = genAddSubRetCarry w ADD_CC (const Nothing) CARRY r c x y @@ -3962,15 +3962,20 @@ genWordToFloat bid width dst src = -- TODO: generate assembly instead genPrimCCall bid (word2FloatLabel width) [dst] [src] -genAtomicRead :: Width -> LocalReg -> CmmExpr -> NatM InstrBlock -genAtomicRead width dst addr = do +genAtomicRead :: Width -> MemoryOrdering -> LocalReg -> CmmExpr -> NatM InstrBlock +genAtomicRead width _mord dst addr = do load_code <- intLoadCode (MOV (intFormat width)) addr return (load_code (getLocalRegReg dst)) -genAtomicWrite :: Width -> CmmExpr -> CmmExpr -> NatM InstrBlock -genAtomicWrite width addr val = do +genAtomicWrite :: Width -> MemoryOrdering -> CmmExpr -> CmmExpr -> NatM InstrBlock +genAtomicWrite width mord addr val = do code <- assignMem_IntCode (intFormat width) addr val - return $ code `snocOL` MFENCE + let needs_fence = case mord of + MemOrderSeqCst -> True + MemOrderRelease -> True + MemOrderAcquire -> pprPanic "genAtomicWrite: acquire ordering on write" empty + MemOrderRelaxed -> False + return $ if needs_fence then code `snocOL` MFENCE else code genCmpXchg :: BlockId ===================================== compiler/GHC/CmmToC.hs ===================================== @@ -944,8 +944,9 @@ pprCallishMachOp_for_C mop MO_AtomicRMW w amop -> ftext (atomicRMWLabel w amop) MO_Cmpxchg w -> ftext (cmpxchgLabel w) MO_Xchg w -> ftext (xchgLabel w) - MO_AtomicRead w -> ftext (atomicReadLabel w) - MO_AtomicWrite w -> ftext (atomicWriteLabel w) + -- TODO: handle orderings + MO_AtomicRead w _ -> ftext (atomicReadLabel w) + MO_AtomicWrite w _ -> ftext (atomicWriteLabel w) MO_UF_Conv w -> ftext (word2FloatLabel w) MO_S_Mul2 {} -> unsupported ===================================== compiler/GHC/CmmToLlvm/CodeGen.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.Semigroup as Semigroup import Data.List ( nub ) import Data.Maybe ( catMaybes ) -type Atomic = Bool +type Atomic = Maybe MemoryOrdering type LlvmStatements = OrdList LlvmStatement data Signage = Signed | Unsigned deriving (Eq, Show) @@ -265,9 +265,9 @@ genCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n] = runStmtsDecls $ retVar <- doExprW targetTy $ AtomicRMW op ptrVar nVar SyncSeqCst statement $ Store retVar dstVar Nothing -genCall (PrimTarget (MO_AtomicRead _)) [dst] [addr] = runStmtsDecls $ do +genCall (PrimTarget (MO_AtomicRead _ mem_ord)) [dst] [addr] = runStmtsDecls $ do dstV <- getCmmRegW (CmmLocal dst) - v1 <- genLoadW True addr (localRegType dst) NaturallyAligned + v1 <- genLoadW (Just mem_ord) addr (localRegType dst) NaturallyAligned statement $ Store v1 dstV Nothing genCall (PrimTarget (MO_Cmpxchg _width)) @@ -294,13 +294,14 @@ genCall (PrimTarget (MO_Xchg _width)) [dst] [addr, val] = runStmtsDecls $ do resVar <- doExprW (getVarType valVar) (AtomicRMW LAO_Xchg ptrVar valVar SyncSeqCst) statement $ Store resVar dstV Nothing -genCall (PrimTarget (MO_AtomicWrite _width)) [] [addr, val] = runStmtsDecls $ do +genCall (PrimTarget (MO_AtomicWrite _width mem_ord)) [] [addr, val] = runStmtsDecls $ do addrVar <- exprToVarW addr valVar <- exprToVarW val let ptrTy = pLift $ getVarType valVar ptrExpr = Cast LM_Inttoptr addrVar ptrTy ptrVar <- doExprW ptrTy ptrExpr - statement $ Expr $ AtomicRMW LAO_Xchg ptrVar valVar SyncSeqCst + let ordering = convertMemoryOrdering mem_ord + statement $ Expr $ AtomicRMW LAO_Xchg ptrVar valVar ordering -- Handle memcpy function specifically since llvm's intrinsic version takes -- some extra parameters. @@ -1012,11 +1013,11 @@ cmmPrimOpFunctions mop = do MO_Touch -> unsupported MO_UF_Conv _ -> unsupported - MO_AtomicRead _ -> unsupported - MO_AtomicRMW _ _ -> unsupported - MO_AtomicWrite _ -> unsupported - MO_Cmpxchg _ -> unsupported - MO_Xchg _ -> unsupported + MO_AtomicRead _ _ -> unsupported + MO_AtomicRMW _ _ -> unsupported + MO_AtomicWrite _ _ -> unsupported + MO_Cmpxchg _ -> unsupported + MO_Xchg _ -> unsupported MO_I64_ToI -> dontReach64 MO_I64_FromI -> dontReach64 @@ -1368,7 +1369,7 @@ exprToVarOpt opt e = case e of -> genLit opt lit CmmLoad e' ty align - -> genLoad False e' ty align + -> genLoad Nothing e' ty align -- Cmmreg in expression is the value, so must load. If you want actual -- reg pointer, call getCmmReg directly. @@ -1890,7 +1891,8 @@ case we will need a more granular way of specifying alignment. mkLoad :: Atomic -> LlvmVar -> AlignmentSpec -> LlvmExpression mkLoad atomic vptr alignment - | atomic = ALoad SyncSeqCst False vptr + | Just mem_ord <- atomic + = ALoad (convertMemoryOrdering mem_ord) False vptr | otherwise = Load vptr align where ty = pLower (getVarType vptr) @@ -2027,6 +2029,12 @@ genLit _ CmmHighStackMark -- * Misc -- +convertMemoryOrdering :: MemoryOrdering -> LlvmSyncOrdering +convertMemoryOrdering MemOrderRelaxed = SyncUnord +convertMemoryOrdering MemOrderAcquire = SyncAcquire +convertMemoryOrdering MemOrderRelease = SyncRelease +convertMemoryOrdering MemOrderSeqCst = SyncSeqCst + -- | Find CmmRegs that get assigned and allocate them on the stack -- -- Any register that gets written needs to be allocated on the ===================================== compiler/GHC/Driver/Config/Cmm.hs ===================================== @@ -18,6 +18,7 @@ initCmmConfig dflags = CmmConfig , cmmDoLinting = gopt Opt_DoCmmLinting dflags , cmmOptElimCommonBlks = gopt Opt_CmmElimCommonBlocks dflags , cmmOptSink = gopt Opt_CmmSink dflags + , cmmOptThreadSanitizer = gopt Opt_CmmThreadSanitizer dflags , cmmGenStackUnwindInstr = debugLevel dflags > 0 , cmmExternalDynamicRefs = gopt Opt_ExternalDynamicRefs dflags , cmmDoCmmSwitchPlans = not (backendHasNativeSwitch (backend dflags)) ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -66,6 +66,7 @@ data DumpFlag | Opt_D_dump_cmm_split | Opt_D_dump_cmm_info | Opt_D_dump_cmm_cps + | Opt_D_dump_cmm_thread_sanitizer -- end cmm subflags | Opt_D_dump_cfg_weights -- ^ Dump the cfg used for block layout. | Opt_D_dump_asm @@ -354,6 +355,7 @@ data GeneralFlag | Opt_Ticky_Dyn_Thunk | Opt_Ticky_Tag | Opt_Ticky_AP -- ^ Use regular thunks even when we could use std ap thunks in order to get entry counts + | Opt_CmmThreadSanitizer | Opt_RPath | Opt_RelativeDynlibPaths | Opt_CompactUnwind -- ^ @-fcompact-unwind@ ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2434,6 +2434,8 @@ dynamic_flags_deps = [ (setDumpFlag Opt_D_dump_cmm_cps) , make_ord_flag defGhcFlag "ddump-cmm-opt" (setDumpFlag Opt_D_dump_opt_cmm) + , make_ord_flag defGhcFlag "ddump-cmm-thread-sanitizer" + (setDumpFlag Opt_D_dump_cmm_thread_sanitizer) , make_ord_flag defGhcFlag "ddump-cfg-weights" (setDumpFlag Opt_D_dump_cfg_weights) , make_ord_flag defGhcFlag "ddump-core-stats" @@ -3511,8 +3513,8 @@ fFlagsDeps = [ unless (platformOS (targetPlatform dflags) == OSDarwin && turn_on) (addWarn "-compact-unwind is only implemented by the darwin platform. Ignoring.") return dflags)), - flagSpec "show-error-context" Opt_ShowErrorContext - + flagSpec "show-error-context" Opt_ShowErrorContext, + flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer ] ++ fHoleFlags ===================================== compiler/GHC/StgToCmm/ExtCode.hs ===================================== @@ -231,8 +231,12 @@ emitLabel = code . F.emitLabel emitAssign :: CmmReg -> CmmExpr -> CmmParse () emitAssign l r = code (F.emitAssign l r) -emitStore :: CmmExpr -> CmmExpr -> CmmParse () -emitStore l r = code (F.emitStore l r) +emitStore :: Maybe MemoryOrdering -> CmmExpr -> CmmExpr -> CmmParse () +emitStore (Just mem_ord) l r = do + platform <- getPlatform + let w = typeWidth $ cmmExprType platform r + emit $ mkUnsafeCall (PrimTarget $ MO_AtomicWrite w mem_ord) [] [l,r] +emitStore Nothing l r = code (F.emitStore l r) getCode :: CmmParse a -> CmmParse CmmAGraph getCode (EC ec) = EC $ \c e s -> do ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -3011,7 +3011,7 @@ doAtomicReadAddr doAtomicReadAddr res addr ty = emitPrimCall [ res ] - (MO_AtomicRead (typeWidth ty)) + (MO_AtomicRead (typeWidth ty) MemOrderSeqCst) [ addr ] -- | Emit an atomic write to a byte array that acts as a memory barrier. @@ -3039,7 +3039,7 @@ doAtomicWriteAddr doAtomicWriteAddr addr ty val = emitPrimCall [ {- no results -} ] - (MO_AtomicWrite (typeWidth ty)) + (MO_AtomicWrite (typeWidth ty) MemOrderSeqCst) [ addr, val ] doCasByteArray ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -61,7 +61,7 @@ import GHC.Types.Basic ( UnboxedTupleOrSum(..), unboxedTupleOrSumExtension ) import GHC.Types.Name import GHC.Types.Var.Env import GHC.Types.Var.Set -import GHC.Types.Var ( VarBndr(..), mkTyVar ) +import GHC.Types.Var ( VarBndr(..), isInvisibleFunArg, mkTyVar ) import GHC.Utils.FV import GHC.Utils.Error import GHC.Driver.Session @@ -1731,6 +1731,13 @@ the instance head, we'll expand the synonym on fly, and it'll look like instance (%,%) (Show Int, Show Int) and we /really/ don't want that. So we carefully do /not/ expand synonyms, by matching on TyConApp directly. + +For similar reasons, we do not use tcSplitSigmaTy when decomposing the instance +context, as the looks through type synonyms. If we looked through type +synonyms, then it could be possible to write an instance for a type synonym +involving a quantified constraint (see #22570). Instead, we define +splitInstTyForValidity, a specialized version of tcSplitSigmaTy (local to +GHC.Tc.Validity) that does not expand type synonyms. -} checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM () @@ -1774,11 +1781,31 @@ checkValidInstance ctxt hs_type ty = case tau of ; return () } _ -> failWithTc (TcRnNoClassInstHead tau) where - (_tvs, theta, tau) = tcSplitSigmaTy ty + (theta, tau) = splitInstTyForValidity ty -- The location of the "head" of the instance head_loc = getLoc (getLHsInstDeclHead hs_type) +-- | Split an instance type of the form @forall tvbs. inst_ctxt => inst_head@ +-- and return @(inst_ctxt, inst_head)@. This function makes no attempt to look +-- through type synonyms. See @Note [Instances and constraint synonyms]@. +splitInstTyForValidity :: Type -> (ThetaType, Type) +splitInstTyForValidity = split_context [] . drop_foralls + where + -- This is like 'dropForAlls', except that it does not look through type + -- synonyms. + drop_foralls :: Type -> Type + drop_foralls (ForAllTy (Bndr _tv argf) ty) + | isInvisibleForAllTyFlag argf = drop_foralls ty + drop_foralls ty = ty + + -- This is like 'tcSplitPhiTy', except that it does not look through type + -- synonyms. + split_context :: ThetaType -> Type -> (ThetaType, Type) + split_context preds (FunTy { ft_af = af, ft_arg = pred, ft_res = tau }) + | isInvisibleFunArg af = split_context (pred:preds) tau + split_context preds ty = (reverse preds, ty) + {- Note [Paterson conditions] ~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/ghc.cabal.in ===================================== @@ -214,6 +214,7 @@ Library GHC.Cmm.Sink GHC.Cmm.Switch GHC.Cmm.Switch.Implement + GHC.Cmm.ThreadSanitizer GHC.CmmToAsm GHC.Cmm.LRegSet GHC.CmmToAsm.AArch64 ===================================== docs/users_guide/debugging.rst ===================================== @@ -551,6 +551,13 @@ These flags dump various phases of GHC's C-\\- pipeline. Dump the results of the C-\\- control flow optimisation pass. +.. ghc-flag:: -ddump-cmm-thread-sanitizer + :shortdesc: Dump the results of the C-\\- ThreadSanitizer elaboration pass. + :type: dynamic + + Dump the results of the C-\\- pass responsible for adding instrumentation + added by :ghc-flag:`-fcmm-thread-sanitizer`. + .. ghc-flag:: -ddump-cmm-cbe :shortdesc: Dump the results of common block elimination :type: dynamic @@ -1075,6 +1082,15 @@ Checking for consistency Note that this is only intended to be used as a debugging measure, not as the primary means of catching out-of-bounds accesses. +.. ghc-flag:: -fcmm-thread-sanitizer + :shortdesc: Enable ThreadSanitizer instrumentation of memory accesses. + :type: dynamic + + This enables generation of `ThreadSanitizer + ` + instrumentation of memory accesses. Requires use of ``-fsanitize=thread`` + or similar when compiling and linking. + .. _checking-determinism: Checking for determinism ===================================== hadrian/src/Flavour.hs ===================================== @@ -203,12 +203,14 @@ splitSections = splitSectionsIf (/=ghc) -- Disable section splitting for the GHC library. It takes too long and -- there is little benefit. +-- | Build GHC and libraries with ThreadSanitizer support. You likely want to +-- configure with @--disable-large-address-space@ when using this. enableThreadSanitizer :: Flavour -> Flavour -enableThreadSanitizer = addArgs $ mconcat - [ builder (Ghc CompileHs) ? 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" <> arg "-DTSAN_ENABLED") +enableThreadSanitizer = addArgs $ notStage0 ? mconcat + [ builder (Ghc CompileHs) ? (arg "-optc-fsanitize=thread" <> arg "-fcmm-thread-sanitizer") + , builder (Ghc CompileCWithGhc) ? arg "-optc-fsanitize=thread" + , builder (Ghc LinkHs) ? (arg "-optc-fsanitize=thread" <> arg "-optl-fsanitize=thread") + , builder Cc ? arg "-fsanitize=thread" , builder (Cabal Flags) ? arg "thread-sanitizer" , builder Testsuite ? arg "--config=have_thread_sanitizer=True" ] ===================================== rts/HeapStackCheck.cmm ===================================== @@ -569,7 +569,7 @@ stg_block_takemvar_finally W_ r1, r3; r1 = R1; r3 = R3; - unlockClosure(R3, stg_MVAR_DIRTY_info); + unlockClosure(r3, stg_MVAR_DIRTY_info); R1 = r1; R3 = r3; jump StgReturn [R1]; @@ -597,7 +597,7 @@ stg_block_readmvar_finally W_ r1, r3; r1 = R1; r3 = R3; - unlockClosure(R3, stg_MVAR_DIRTY_info); + unlockClosure(r3, stg_MVAR_DIRTY_info); R1 = r1; R3 = r3; jump StgReturn [R1]; @@ -625,7 +625,7 @@ stg_block_putmvar_finally W_ r1, r3; r1 = R1; r3 = R3; - unlockClosure(R3, stg_MVAR_DIRTY_info); + unlockClosure(r3, stg_MVAR_DIRTY_info); R1 = r1; R3 = r3; jump StgReturn [R1]; ===================================== rts/TSANUtils.c ===================================== @@ -0,0 +1,37 @@ +#include + +#if defined(TSAN_ENABLED) + +uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, uint64_t new_value, int success_memorder, int failure_memorder) +{ + __tsan_atomic64_compare_exchange_strong( + ptr, &expected, new_value, + success_memorder, failure_memorder); + return expected; +} + +uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, uint32_t new_value, int success_memorder, int failure_memorder) +{ + __tsan_atomic32_compare_exchange_strong( + ptr, &expected, new_value, + success_memorder, failure_memorder); + return expected; +} + +uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, uint16_t new_value, int success_memorder, int failure_memorder) +{ + __tsan_atomic16_compare_exchange_strong( + ptr, &expected, new_value, + success_memorder, failure_memorder); + return expected; +} + +uint8_t ghc_tsan_atomic8_compare_exchange(uint8_t *ptr, uint8_t expected, uint8_t new_value, int success_memorder, int failure_memorder) +{ + __tsan_atomic8_compare_exchange_strong( + ptr, &expected, new_value, + success_memorder, failure_memorder); + return expected; +} + +#endif ===================================== rts/include/rts/TSANUtils.h ===================================== @@ -65,3 +65,10 @@ void AnnotateBenignRaceSized(const char *file, #define TSAN_ANNOTATE_BENIGN_RACE(addr,desc) \ TSAN_ANNOTATE_BENIGN_RACE_SIZED((void*)(addr), sizeof(*addr), desc) + + +uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, uint64_t new_value, int success_memorder, int failure_memorder); +uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, uint32_t new_value, int success_memorder, int failure_memorder); +uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, uint16_t new_value, int success_memorder, int failure_memorder); +uint8_t ghc_tsan_atomic8_compare_exchange(uint8_t *ptr, uint8_t expected, uint8_t new_value, int success_memorder, int failure_memorder); + ===================================== rts/rts.cabal.in ===================================== @@ -588,6 +588,7 @@ library Trace.c TraverseHeap.c TraverseHeapTest.c + TSANUtils.c WSDeque.c Weak.c eventlog/EventLog.c ===================================== testsuite/tests/typecheck/should_fail/T22570.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module T22570 where + +import Data.Kind + +class SomeClass a +class OtherClass + +type SomeClassUnit = OtherClass => SomeClass () :: Constraint + +instance SomeClassUnit + +type SomeClassSyn a = OtherClass => SomeClass a :: Constraint + +instance SomeClassSyn () ===================================== testsuite/tests/typecheck/should_fail/T22570.stderr ===================================== @@ -0,0 +1,10 @@ + +T22570.hs:11:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassUnit’ + +T22570.hs:15:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassSyn ()’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -665,3 +665,4 @@ test('MissingDefaultMethodBinding', normal, compile_fail, ['']) test('T21447', normal, compile_fail, ['']) test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) +test('T22570', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/98ca53c9ce33dc72e798c8c4a439275019484374...490b79cb641e8927a2341b63153926cc64482919 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/98ca53c9ce33dc72e798c8c4a439275019484374...490b79cb641e8927a2341b63153926cc64482919 You're receiving 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 Dec 14 09:20:55 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Wed, 14 Dec 2022 04:20:55 -0500 Subject: [Git][ghc/ghc][wip/or-pats] 9 commits: Mark T21336a fragile Message-ID: <639995778122e_389fe2202f1ac85462a0@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00 JS: fix object file name comparison (#22578) - - - - - e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 180331f1 by David Knothe at 2022-12-14T10:20:09+01:00 Add Or Patterns (proposal 0522) - - - - - 439f6103 by David Knothe at 2022-12-14T10:20:10+01:00 Update submodule haddock & linting stuff - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34a1ebad3f3f3d02fbabb8d6d1db5797d8449233...439f6103c8ef0e14610e344604fb92d58644b282 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34a1ebad3f3f3d02fbabb8d6d1db5797d8449233...439f6103c8ef0e14610e344604fb92d58644b282 You're receiving 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 Dec 14 10:23:01 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 14 Dec 2022 05:23:01 -0500 Subject: [Git][ghc/ghc][wip/T22459] Abstract over the right free vars Message-ID: <6399a405484fc_389fe2161ceccc551935@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22459 at Glasgow Haskell Compiler / GHC Commits: f9ab917f by Simon Peyton Jones at 2022-12-14T10:22:38+00:00 Abstract over the right free vars Fix #22459, in two ways: (1) Make the Specialiser not create a bogus specialisation if it is presented by strangely polymorphic dictionary. See Note [Weird special case in SpecDict] in GHC.Core.Opt.Specialise (2) Be more careful in abstractFloats See Note [Which type variables to abstract over] in GHC.Core.Opt.Simplify.Utils. So (2) stops creating the excessively polymorphic dictionary in abstractFloats, while (1) stops crashing if some other pass should nevertheless create a weirdly polymorphic dictionary. - - - - - 5 changed files: - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Subst.hs - + testsuite/tests/simplCore/should_compile/T22459.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -2063,34 +2063,51 @@ it is guarded by the doFloatFromRhs call in simplLazyBind. Note [Which type variables to abstract over] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Abstract only over the type variables free in the rhs wrt which the -new binding is abstracted. Note that - - * The naive approach of abstracting wrt the - tyvars free in the Id's /type/ fails. Consider: - /\ a b -> let t :: (a,b) = (e1, e2) - x :: a = fst t - in ... - Here, b isn't free in x's type, but we must nevertheless - abstract wrt b as well, because t's type mentions b. - Since t is floated too, we'd end up with the bogus: - poly_t = /\ a b -> (e1, e2) - poly_x = /\ a -> fst (poly_t a *b*) - - * We must do closeOverKinds. Example (#10934): +new binding is abstracted. Several points worth noting + +(AB1) The naive approach of abstracting wrt the + tyvars free in the Id's /type/ fails. Consider: + /\ a b -> let t :: (a,b) = (e1, e2) + x :: a = fst t + in ... + Here, b isn't free in x's type, but we must nevertheless + abstract wrt b as well, because t's type mentions b. + Since t is floated too, we'd end up with the bogus: + poly_t = /\ a b -> (e1, e2) + poly_x = /\ a -> fst (poly_t a *b*) + +(AB2) We must do closeOverKinds. Example (#10934): f = /\k (f:k->*) (a:k). let t = AccFailure @ (f a) in ... - Here we want to float 't', but we must remember to abstract over - 'k' as well, even though it is not explicitly mentioned in the RHS, - otherwise we get - t = /\ (f:k->*) (a:k). AccFailure @ (f a) - which is obviously bogus. - - * We get the variables to abstract over by filtering down the - the main_tvs for the original function, picking only ones - mentioned in the abstracted body. This means: - - they are automatically in dependency order, because main_tvs is - - there is no issue about non-determinism - - we don't gratuitously change order, which may help (in a tiny - way) with CSE and/or the compiler-debugging experience + Here we want to float 't', but we must remember to abstract over + 'k' as well, even though it is not explicitly mentioned in the RHS, + otherwise we get + t = /\ (f:k->*) (a:k). AccFailure @ (f a) + which is obviously bogus. + +(AB3) We get the variables to abstract over by filtering down the + the main_tvs for the original function, picking only ones + mentioned in the abstracted body. This means: + - they are automatically in dependency order, because main_tvs is + - there is no issue about non-determinism + - we don't gratuitously change order, which may help (in a tiny + way) with CSE and/or the compiler-debugging experience + +(AB4) For a recursive group, it's a bit of a pain to work out the minimal + set of tyvars over which to abstract: + /\ a b c. let x = ...a... in + letrec { p = ...x...q... + q = .....p...b... } in + ... + Since 'x' is abstracted over 'a', the {p,q} group must be abstracted + over 'a' (because x is replaced by (poly_x a)) as well as 'b'. + Remember this bizarre case too: + x::a = x + Here, we must abstract 'x' over 'a'. + + Why is it worth doing this? Partly tidiness; and partly #22459 + which showed that it's harder to do polymorphic specialisation well + if there are dictionaries abstracted over unnecessary type variables. + See Note [Weird special case for SpecDict] in GHC.Core.Opt.Specialise -} abstractFloats :: UnfoldingOpts -> TopLevelFlag -> [OutTyVar] -> SimplFloats @@ -2115,33 +2132,40 @@ abstractFloats uf_opts top_lvl main_tvs floats body rhs' = GHC.Core.Subst.substExpr subst rhs -- tvs_here: see Note [Which type variables to abstract over] - tvs_here = filter (`elemVarSet` free_tvs) main_tvs - free_tvs = closeOverKinds $ - exprSomeFreeVars isTyVar rhs' + tvs_here = choose_tvs (exprSomeFreeVars isTyVar rhs') abstract subst (Rec prs) - = do { (poly_ids, poly_apps) <- mapAndUnzipM (mk_poly1 tvs_here) ids - ; let subst' = GHC.Core.Subst.extendSubstList subst (ids `zip` poly_apps) - poly_pairs = [ mk_poly2 poly_id tvs_here rhs' - | (poly_id, rhs) <- poly_ids `zip` rhss - , let rhs' = GHC.Core.Subst.substExpr subst' rhs ] - ; return (subst', Rec poly_pairs) } + = do { (poly_ids, poly_apps) <- mapAndUnzipM (mk_poly1 tvs_here) ids + ; let subst' = GHC.Core.Subst.extendSubstList subst (ids `zip` poly_apps) + poly_pairs = [ mk_poly2 poly_id tvs_here rhs' + | (poly_id, rhs) <- poly_ids `zip` rhss + , let rhs' = GHC.Core.Subst.substExpr subst' rhs ] + ; return (subst', Rec poly_pairs) } + where + (ids,rhss) = unzip prs + + + -- tvs_here: see Note [Which type variables to abstract over] + tvs_here = choose_tvs (mapUnionVarSet get_bind_fvs prs) + + -- See wrinkle (AB4) in Note [Which type variables to abstract over] + get_bind_fvs (id,rhs) = tyCoVarsOfType (idType id) `unionVarSet` get_rec_rhs_tvs rhs + get_rec_rhs_tvs rhs = nonDetStrictFoldVarSet get_tvs emptyVarSet (exprFreeVars rhs) + + get_tvs :: Var -> VarSet -> VarSet + get_tvs var free_tvs + | isTyVar var -- CoVars have been substituted away + = extendVarSet free_tvs var + | Just poly_app <- GHC.Core.Subst.lookupIdSubst_maybe subst var + = -- 'var' is like 'x' in (AB4) + exprSomeFreeVars isTyVar poly_app `unionVarSet` free_tvs + | otherwise + = free_tvs + + choose_tvs free_tvs + = filter (`elemVarSet` all_free_tvs) main_tvs -- (AB3) where - (ids,rhss) = unzip prs - -- For a recursive group, it's a bit of a pain to work out the minimal - -- set of tyvars over which to abstract: - -- /\ a b c. let x = ...a... in - -- letrec { p = ...x...q... - -- q = .....p...b... } in - -- ... - -- Since 'x' is abstracted over 'a', the {p,q} group must be abstracted - -- over 'a' (because x is replaced by (poly_x a)) as well as 'b'. - -- Since it's a pain, we just use the whole set, which is always safe - -- - -- If you ever want to be more selective, remember this bizarre case too: - -- x::a = x - -- Here, we must abstract 'x' over 'a'. - tvs_here = scopedSort main_tvs + all_free_tvs = closeOverKinds free_tvs -- (AB2) mk_poly1 :: [TyVar] -> Id -> SimplM (Id, CoreExpr) mk_poly1 tvs_here var ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -2516,6 +2516,8 @@ specHeader env (bndr : bndrs) (UnspecType : args) -- the nitty-gritty), as a LHS rule and unfolding details. specHeader env (bndr : bndrs) (SpecDict d : args) | not (isDeadBinder bndr) + , allVarSet (`elemInScopeSet` in_scope) (exprFreeVars d) + -- See Note [Weird special case for SpecDict] = do { (env1, bndr') <- newDictBndr env bndr -- See Note [Zap occ info in rule binders] ; let (env2, dx_bind, spec_dict) = bindAuxiliaryDict env1 bndr bndr' d ; (_, env3, leftover_bndrs, rule_bs, rule_es, bs', dx, spec_args) @@ -2531,6 +2533,8 @@ specHeader env (bndr : bndrs) (SpecDict d : args) , spec_dict : spec_args ) } + where + in_scope = Core.getSubstInScope (se_subst env) -- Finally, we don't want to specialise on this argument 'i': -- - It's an UnSpecArg, or @@ -2752,6 +2756,8 @@ monomorpic, and specialised in one go. Wrinkles. +* See Note [Weird special case for SpecDict] + * With -XOverlappingInstances you might worry about this: class C a where ... instance C (Maybe Int) where ... -- $df1 :: C (Maybe Int) @@ -2777,6 +2783,33 @@ Wrinkles. it's a hard test to make.) But see Note [Specialisation and overlapping instances]. + +Note [Weird special case for SpecDict] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we are trying to specialise for this this call: + $wsplit @T (mkD @k @(a::k) :: C T) +where + mkD :: forall k (a::k). C T +is a top-level dictionary-former. This actually happened in #22459, +because of (MP1) of Note [Specialising polymorphic dictionaries]. + +How can we speicalise $wsplit? We might try + + RULE "SPEC" forall (d :: C T). $wsplit @T d = $s$wsplit + +but then in the body of $s$wsplit what will we use for the dictionary +evidence? We can't use (mkD @k @(a::k)) because k and a aren't in scope. +We could zap `k` to (Any @Type) and `a` to (Any @(Any @Type)), but that +is a lot of hard work for a very strange case. + +So we simply refrain from specialising in this case; hence the guard + allVarSet (`elemInScopeSet` in_scope) (exprFreeVars d) +in the SpecDict cased of specHeader. + +How did this strange polymorphic mkD arise in the first place? +From GHC.Core.Opt.Utils.abstractFloats, which was abstracting +over too many type variables. But that too is now fixed; +see Note [Which type variables to abstract over] in that module. -} instance Outputable DictBind where ===================================== compiler/GHC/Core/Subst.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Subst ( deShadowBinds, substRuleInfo, substRulesForImportedIds, substTyUnchecked, substCo, substExpr, substExprSC, substBind, substBindSC, substUnfolding, substUnfoldingSC, - lookupIdSubst, substIdType, substIdOcc, + lookupIdSubst, lookupIdSubst_maybe, substIdType, substIdOcc, substTickish, substDVarSet, substIdInfo, -- ** Operations on substitutions @@ -184,9 +184,11 @@ extendSubstList subst [] = subst extendSubstList subst ((var,rhs):prs) = extendSubstList (extendSubst subst var rhs) prs -- | Find the substitution for an 'Id' in the 'Subst' +-- The Id should not be a CoVar lookupIdSubst :: HasDebugCallStack => Subst -> Id -> CoreExpr lookupIdSubst (Subst in_scope ids _ _) v - | not (isLocalId v) = Var v + | assertPpr (isId v && not (isCoVar v)) (ppr v) + not (isLocalId v) = Var v | Just e <- lookupVarEnv ids v = e | Just v' <- lookupInScope in_scope v = Var v' -- Vital! See Note [Extending the IdSubstEnv] @@ -194,6 +196,12 @@ lookupIdSubst (Subst in_scope ids _ _) v -- it's a bad bug and we really want to know | otherwise = pprPanic "lookupIdSubst" (ppr v $$ ppr in_scope) +lookupIdSubst_maybe :: HasDebugCallStack => Subst -> Id -> Maybe CoreExpr +-- Just look up in the substitution; do not check the in-scope set +lookupIdSubst_maybe (Subst _ ids _ _) v + = assertPpr (isId v && not (isCoVar v)) (ppr v) $ + lookupVarEnv ids v + delBndr :: Subst -> Var -> Subst delBndr (Subst in_scope ids tvs cvs) v | isCoVar v = Subst in_scope ids tvs (delVarEnv cvs v) ===================================== testsuite/tests/simplCore/should_compile/T22459.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE UndecidableInstances #-} + +{-# OPTIONS_GHC -O #-} + +module Lib (foo) where + +import qualified Data.Map as M + +newtype Fix f = Fix (f (Fix f)) + +instance Eq (f (Fix f)) => Eq (Fix f) where + Fix a == Fix b = a == b + +instance Ord (f (Fix f)) => Ord (Fix f) where + Fix a `compare` Fix b = a `compare` b + +data Foo i r = Foo i r + deriving (Eq, Ord) + +newtype Bar a = Bar (M.Map Char (M.Map (Fix (Foo ())) Word)) + +foo :: Bar a -> Bar a -> Bar a +foo (Bar a) (Bar b) = Bar (M.unionWith M.union a b) ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -458,3 +458,4 @@ test('T22494', [grep_errmsg(r'case') ], compile, ['-O -ddump-simpl -dsuppress-un test('T22491', normal, compile, ['-O2']) test('T21476', normal, compile, ['']) test('T22272', normal, multimod_compile, ['T22272', '-O -fexpose-all-unfoldings -fno-omit-interface-pragmas -fno-ignore-interface-pragmas']) +test('T22459', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f9ab917f069dc21d668f7905e24c29092a373ef3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f9ab917f069dc21d668f7905e24c29092a373ef3 You're receiving 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 Dec 14 10:53:28 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 14 Dec 2022 05:53:28 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22404 Message-ID: <6399ab286c279_389fe21bc7078456157e@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22404 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22404 You're receiving 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 Dec 14 11:52:43 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Dec 2022 06:52:43 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 13 commits: hadrian: Don't enable TSAN in stage0 build Message-ID: <6399b90b6e67_389fe2202f1ac8576479@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6d97e74d by Ben Gamari at 2022-12-14T06:52:19-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - e61856a9 by Ben Gamari at 2022-12-14T06:52:19-05:00 cmm: Introduce blockConcat - - - - - e64d8236 by Ben Gamari at 2022-12-14T06:52:20-05:00 cmm: Introduce MemoryOrderings - - - - - 63b9b00d by Ben Gamari at 2022-12-14T06:52:20-05:00 llvm: Respect memory specified orderings - - - - - c98d0a57 by Ben Gamari at 2022-12-14T06:52:20-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - ded8cbb8 by Ben Gamari at 2022-12-14T06:52:20-05:00 cmm/Parser: Reduce some repetition - - - - - 4ec17c2b by Ben Gamari at 2022-12-14T06:52:20-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - ce29530d by Ben Gamari at 2022-12-14T06:52:20-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 486f16e5 by Ben Gamari at 2022-12-14T06:52:20-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - ee6a4265 by Ben Gamari at 2022-12-14T06:52:20-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - ad67af9b by Ben Gamari at 2022-12-14T06:52:20-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 9c9578a5 by Ben Gamari at 2022-12-14T06:52:20-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - de68c3dd by Ryan Scott at 2022-12-14T06:52:20-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Validity.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - hadrian/src/Flavour.hs - rts/HeapStackCheck.cmm - + rts/TSANUtils.c - rts/include/rts/TSANUtils.h - rts/rts.cabal.in - + testsuite/tests/typecheck/should_fail/T22570.hs - + testsuite/tests/typecheck/should_fail/T22570.stderr - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Cmm/Config.hs ===================================== @@ -19,6 +19,7 @@ data CmmConfig = CmmConfig , cmmDoLinting :: !Bool -- ^ Do Cmm Linting Optimization or not , cmmOptElimCommonBlks :: !Bool -- ^ Eliminate common blocks or not , cmmOptSink :: !Bool -- ^ Perform sink after stack layout or not + , cmmOptThreadSanitizer :: !Bool -- ^ Instrument memory accesses for ThreadSanitizer , cmmGenStackUnwindInstr :: !Bool -- ^ Generate stack unwinding instructions (for debugging) , cmmExternalDynamicRefs :: !Bool -- ^ Generate code to link against dynamic libraries , cmmDoCmmSwitchPlans :: !Bool -- ^ Should the Cmm pass replace Stg switch statements ===================================== compiler/GHC/Cmm/ContFlowOpt.hs ===================================== @@ -10,7 +10,7 @@ where import GHC.Prelude hiding (succ, unzip, zip) -import GHC.Cmm.Dataflow.Block +import GHC.Cmm.Dataflow.Block hiding (blockConcat) import GHC.Cmm.Dataflow.Collections import GHC.Cmm.Dataflow.Graph import GHC.Cmm.Dataflow.Label ===================================== compiler/GHC/Cmm/Dataflow/Block.hs ===================================== @@ -14,6 +14,7 @@ module GHC.Cmm.Dataflow.Block , IndexedCO , Block(..) , blockAppend + , blockConcat , blockCons , blockFromList , blockJoin @@ -136,6 +137,8 @@ blockJoin f b t = BlockCC f b t blockAppend :: Block n e O -> Block n O x -> Block n e x blockAppend = cat +blockConcat :: [Block n O O] -> Block n O O +blockConcat = foldr blockAppend emptyBlock -- Taking apart ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -94,6 +94,10 @@ $white_no_nl+ ; "!=" { kw CmmT_Ne } "&&" { kw CmmT_BoolAnd } "||" { kw CmmT_BoolOr } + "%relaxed" { kw CmmT_Relaxed } + "%acquire" { kw CmmT_Acquire } + "%release" { kw CmmT_Release } + "%seq_cst" { kw CmmT_SeqCst } "True" { kw CmmT_True } "False" { kw CmmT_False } @@ -183,6 +187,10 @@ data CmmToken | CmmT_False | CmmT_True | CmmT_likely + | CmmT_Relaxed + | CmmT_Acquire + | CmmT_Release + | CmmT_SeqCst deriving (Show) -- ----------------------------------------------------------------------------- ===================================== compiler/GHC/Cmm/MachOp.hs ===================================== @@ -24,6 +24,7 @@ module GHC.Cmm.MachOp , machOpMemcpyishAlign -- Atomic read-modify-write + , MemoryOrdering(..) , AtomicMachOp(..) ) where @@ -662,10 +663,12 @@ data CallishMachOp | MO_BSwap Width | MO_BRev Width - -- Atomic read-modify-write. + -- | Atomic read-modify-write. Arguments are @[dest, n]@. | MO_AtomicRMW Width AtomicMachOp - | MO_AtomicRead Width - | MO_AtomicWrite Width + -- | Atomic read. Arguments are @[addr]@. + | MO_AtomicRead Width MemoryOrdering + -- | Atomic write. Arguments are @[addr, value]@. + | MO_AtomicWrite Width MemoryOrdering -- | Atomic compare-and-swap. Arguments are @[dest, expected, new]@. -- Sequentially consistent. -- Possible future refactoring: should this be an'MO_AtomicRMW' variant? @@ -680,6 +683,14 @@ data CallishMachOp | MO_ResumeThread deriving (Eq, Show) +-- | C11 memory ordering semantics. +data MemoryOrdering + = MemOrderRelaxed -- ^ relaxed ordering + | MemOrderAcquire -- ^ acquire ordering + | MemOrderRelease -- ^ release ordering + | MemOrderSeqCst -- ^ sequentially consistent + deriving (Eq, Ord, Show) + -- | The operation to perform atomically. data AtomicMachOp = AMO_Add ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -194,6 +194,27 @@ convention. Note if a field is longer than a word (e.g. a D_ on a 32-bit machine) then the call will push as many words as necessary to the stack to accommodate it (e.g. 2). +Memory ordering +--------------- + +Cmm respects the C11 memory model and distinguishes between non-atomic and +atomic memory accesses. In C11 fashion, atomic accesses can provide a number of +memory ordering guarantees. These are supported in Cmm syntax as follows: + + W_[ptr] = ...; // a non-atomic store + %relaxed W_[ptr] = ...; // an atomic store with relaxed ordering semantics + %release W_[ptr] = ...; // an atomic store with release ordering semantics + + x = W_(ptr); // a non-atomic load + x = %relaxed W_[ptr]; // an atomic load with relaxed ordering + x = %acquire W_[ptr]; // an atomic load with acquire ordering + // or equivalently... + x = prim %load_acquire64(ptr); + +Here we used W_ as an example but these operations can be used on all Cmm +types. + +See Note [Heap memory barriers] in SMP.h for details. ----------------------------------------------------------------------------- -} @@ -313,6 +334,10 @@ import qualified Data.ByteString.Char8 as BS8 'True' { L _ (CmmT_True ) } 'False' { L _ (CmmT_False) } 'likely'{ L _ (CmmT_likely)} + 'relaxed'{ L _ (CmmT_Relaxed)} + 'acquire'{ L _ (CmmT_Acquire)} + 'release'{ L _ (CmmT_Release)} + 'seq_cst'{ L _ (CmmT_SeqCst)} 'CLOSURE' { L _ (CmmT_CLOSURE) } 'INFO_TABLE' { L _ (CmmT_INFO_TABLE) } @@ -627,8 +652,23 @@ stmt :: { CmmParse () } | lreg '=' expr ';' { do reg <- $1; e <- $3; withSourceNote $2 $4 (emitAssign reg e) } + + -- Use lreg instead of local_reg to avoid ambiguity + | lreg '=' mem_ordering type '[' expr ']' ';' + { do reg <- $1; + let lreg = case reg of + { CmmLocal r -> r + ; other -> pprPanic "CmmParse:" (ppr reg <> text "not a local register") + } ; + mord <- $3; + let { ty = $4; w = typeWidth ty }; + e <- $6; + let op = MO_AtomicRead w mord; + withSourceNote $2 $7 $ code (emitPrimCall [lreg] op [e]) } + | mem_ordering type '[' expr ']' '=' expr ';' + { do mord <- $1; withSourceNote $3 $8 (doStore (Just mord) $2 $4 $7) } | type '[' expr ']' '=' expr ';' - { withSourceNote $2 $7 (doStore $1 $3 $6) } + { withSourceNote $2 $7 (doStore Nothing $1 $3 $6) } -- Gah! We really want to say "foreign_results" but that causes -- a shift/reduce conflict with assignment. We either @@ -678,6 +718,14 @@ unwind_regs | GLOBALREG '=' expr_or_unknown { do e <- $3; return [($1, e)] } +-- | A memory ordering +mem_ordering :: { CmmParse MemoryOrdering } +mem_ordering + : 'relaxed' { do return MemOrderRelaxed } + | 'release' { do return MemOrderRelease } + | 'acquire' { do return MemOrderAcquire } + | 'seq_cst' { do return MemOrderSeqCst } + -- | Used by unwind to indicate unknown unwinding values. expr_or_unknown :: { CmmParse (Maybe CmmExpr) } @@ -953,6 +1001,7 @@ exprMacros profile align_check = listToUFM [ platform = profilePlatform profile -- we understand a subset of C-- primitives: +machOps :: UniqFM FastString (Width -> MachOp) machOps = listToUFM $ map (\(x, y) -> (mkFastString x, y)) [ ( "add", MO_Add ), @@ -1073,37 +1122,32 @@ callishMachOps platform = listToUFM $ ( "suspendThread", (MO_SuspendThread,) ), ( "resumeThread", (MO_ResumeThread,) ), - ("prefetch0", (MO_Prefetch_Data 0,)), - ("prefetch1", (MO_Prefetch_Data 1,)), - ("prefetch2", (MO_Prefetch_Data 2,)), - ("prefetch3", (MO_Prefetch_Data 3,)), - - ( "popcnt8", (MO_PopCnt W8,)), - ( "popcnt16", (MO_PopCnt W16,)), - ( "popcnt32", (MO_PopCnt W32,)), - ( "popcnt64", (MO_PopCnt W64,)), - - ( "pdep8", (MO_Pdep W8,)), - ( "pdep16", (MO_Pdep W16,)), - ( "pdep32", (MO_Pdep W32,)), - ( "pdep64", (MO_Pdep W64,)), - - ( "pext8", (MO_Pext W8,)), - ( "pext16", (MO_Pext W16,)), - ( "pext32", (MO_Pext W32,)), - ( "pext64", (MO_Pext W64,)), - - ( "cmpxchg8", (MO_Cmpxchg W8,)), - ( "cmpxchg16", (MO_Cmpxchg W16,)), - ( "cmpxchg32", (MO_Cmpxchg W32,)), - ( "cmpxchg64", (MO_Cmpxchg W64,)), - - ( "xchg8", (MO_Xchg W8,)), - ( "xchg16", (MO_Xchg W16,)), - ( "xchg32", (MO_Xchg W32,)), - ( "xchg64", (MO_Xchg W64,)) + ( "prefetch0", (MO_Prefetch_Data 0,)), + ( "prefetch1", (MO_Prefetch_Data 1,)), + ( "prefetch2", (MO_Prefetch_Data 2,)), + ( "prefetch3", (MO_Prefetch_Data 3,)) + ] ++ concat + [ allWidths "popcnt" MO_PopCnt + , allWidths "pdep" MO_Pdep + , allWidths "pext" MO_Pext + , allWidths "cmpxchg" MO_Cmpxchg + , allWidths "xchg" MO_Xchg + , allWidths "load_relaxed" (\w -> MO_AtomicRead w MemOrderAcquire) + , allWidths "load_acquire" (\w -> MO_AtomicRead w MemOrderAcquire) + , allWidths "load_seqcst" (\w -> MO_AtomicRead w MemOrderSeqCst) + , allWidths "store_release" (\w -> MO_AtomicWrite w MemOrderRelease) + , allWidths "store_seqcst" (\w -> MO_AtomicWrite w MemOrderSeqCst) ] where + allWidths + :: String + -> (Width -> CallishMachOp) + -> [(FastString, a -> (CallishMachOp, a))] + allWidths name f = + [ (mkFastString $ name ++ show (widthInBits w), (f w,)) + | w <- [W8, W16, W32, W64] + ] + memcpyLikeTweakArgs :: (Int -> CallishMachOp) -> [CmmExpr] -> (CallishMachOp, [CmmExpr]) memcpyLikeTweakArgs op [] = pgmError "memcpy-like function requires at least one argument" memcpyLikeTweakArgs op args@(_:_) = @@ -1347,8 +1391,12 @@ primCall results_code name args_code let (p, args') = f args code (emitPrimCall (map fst results) p args') -doStore :: CmmType -> CmmParse CmmExpr -> CmmParse CmmExpr -> CmmParse () -doStore rep addr_code val_code +doStore :: Maybe MemoryOrdering + -> CmmType + -> CmmParse CmmExpr -- ^ address + -> CmmParse CmmExpr -- ^ value + -> CmmParse () +doStore mem_ord rep addr_code val_code = do platform <- getPlatform addr <- addr_code val <- val_code @@ -1362,7 +1410,7 @@ doStore rep addr_code val_code let coerce_val | val_width /= rep_width = CmmMachOp (MO_UU_Conv val_width rep_width) [val] | otherwise = val - emitStore addr coerce_val + emitStore mem_ord addr coerce_val -- ----------------------------------------------------------------------------- -- If-then-else and boolean expressions ===================================== compiler/GHC/Cmm/Pipeline.hs ===================================== @@ -19,6 +19,7 @@ import GHC.Cmm.LayoutStack import GHC.Cmm.ProcPoint import GHC.Cmm.Sink import GHC.Cmm.Switch.Implement +import GHC.Cmm.ThreadSanitizer import GHC.Types.Unique.Supply @@ -98,6 +99,13 @@ cpsTop logger platform cfg proc = else pure g dump Opt_D_dump_cmm_switch "Post switch plan" g + ----------- ThreadSanitizer instrumentation ----------------------------- + g <- {-# SCC "annotateTSAN" #-} + if cmmOptThreadSanitizer cfg + then runUniqSM $ annotateTSAN platform g + else return g + dump Opt_D_dump_cmm_thread_sanitizer "ThreadSanitizer instrumentation" g + ----------- Proc points ------------------------------------------------- let call_pps :: ProcPointSet -- LabelMap ===================================== compiler/GHC/Cmm/ThreadSanitizer.hs ===================================== @@ -0,0 +1,285 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} + +-- | Annotate a CmmGraph with ThreadSanitizer instrumentation calls. +module GHC.Cmm.ThreadSanitizer (annotateTSAN) where + +import GHC.Prelude + +import GHC.StgToCmm.Utils (get_GlobalReg_addr) +import GHC.Platform +import GHC.Platform.Regs (activeStgRegs, callerSaves) +import GHC.Cmm +import GHC.Cmm.Utils +import GHC.Cmm.CLabel +import GHC.Cmm.Dataflow +import GHC.Cmm.Dataflow.Block +import GHC.Cmm.Dataflow.Graph +import GHC.Data.FastString +import GHC.Types.Basic +import GHC.Types.ForeignCall +import GHC.Types.Unique +import GHC.Types.Unique.Supply + +import Data.Maybe (fromMaybe) + +data Env = Env { platform :: Platform + , uniques :: [Unique] + } + +annotateTSAN :: Platform -> CmmGraph -> UniqSM CmmGraph +annotateTSAN platform graph = do + env <- Env platform <$> getUniquesM + return $ modifyGraph (mapGraphBlocks (annotateBlock env)) graph + +mapBlockList :: (forall e' x'. n e' x' -> Block n e' x') + -> Block n e x -> Block n e x +mapBlockList f (BlockCO n rest ) = f n `blockAppend` mapBlockList f rest +mapBlockList f (BlockCC n rest m) = f n `blockAppend` mapBlockList f rest `blockAppend` f m +mapBlockList f (BlockOC rest m) = mapBlockList f rest `blockAppend` f m +mapBlockList _ BNil = BNil +mapBlockList f (BMiddle blk) = f blk +mapBlockList f (BCat a b) = mapBlockList f a `blockAppend` mapBlockList f b +mapBlockList f (BSnoc a n) = mapBlockList f a `blockAppend` f n +mapBlockList f (BCons n a) = f n `blockAppend` mapBlockList f a + +annotateBlock :: Env -> Block CmmNode e x -> Block CmmNode e x +annotateBlock env = mapBlockList (annotateNode env) + +annotateNode :: Env -> CmmNode e x -> Block CmmNode e x +annotateNode env node = + case node of + CmmEntry{} -> BlockCO node BNil + CmmComment{} -> BMiddle node + CmmTick{} -> BMiddle node + CmmUnwind{} -> BMiddle node + CmmAssign{} -> annotateNodeOO env node + CmmStore lhs rhs align -> + let ty = cmmExprType (platform env) rhs + rhs_nodes = annotateLoads env (collectExprLoads rhs) + lhs_nodes = annotateLoads env (collectExprLoads lhs) + st = tsanStore env align ty lhs + in rhs_nodes `blockAppend` lhs_nodes `blockAppend` st `blockSnoc` node + CmmUnsafeForeignCall (PrimTarget op) formals args -> + let node' = fromMaybe (BMiddle node) (annotatePrim env op formals args) + arg_nodes = blockConcat $ map (annotateExpr env) args + in arg_nodes `blockAppend` node' + CmmUnsafeForeignCall{} -> annotateNodeOO env node + CmmBranch{} -> annotateNodeOC env node + CmmCondBranch{} -> annotateNodeOC env node + CmmSwitch{} -> annotateNodeOC env node + CmmCall{} -> annotateNodeOC env node + CmmForeignCall{} -> annotateNodeOC env node + +annotateNodeOO :: Env -> CmmNode O O -> Block CmmNode O O +annotateNodeOO env node = + annotateLoads env (collectLoadsNode node) `blockSnoc` node + +annotateNodeOC :: Env -> CmmNode O C -> Block CmmNode O C +annotateNodeOC env node = + annotateLoads env (collectLoadsNode node) `blockJoinTail` node + +annotateExpr :: Env -> CmmExpr -> Block CmmNode O O +annotateExpr env expr = + annotateLoads env (collectExprLoads expr) + +data Load = Load CmmType AlignmentSpec CmmExpr + +annotateLoads :: Env -> [Load] -> Block CmmNode O O +annotateLoads env loads = + blockConcat + [ tsanLoad env align ty addr + | Load ty align addr <- loads + ] + +collectLoadsNode :: CmmNode e x -> [Load] +collectLoadsNode node = + foldExp (\exp rest -> collectExprLoads exp ++ rest) node [] + +-- | Collect all of the memory locations loaded from by a 'CmmExpr'. +collectExprLoads :: CmmExpr -> [Load] +collectExprLoads (CmmLit _) = [] +collectExprLoads (CmmLoad e ty align) = [Load ty align e] +collectExprLoads (CmmReg _) = [] +collectExprLoads (CmmMachOp _op args) = foldMap collectExprLoads args +collectExprLoads (CmmStackSlot _ _) = [] +collectExprLoads (CmmRegOff _ _) = [] + +-- | Generate TSAN instrumentation for a 'CallishMachOp' occurrence. +annotatePrim :: Env + -> CallishMachOp -- ^ the applied operation + -> [CmmFormal] -- ^ results + -> [CmmActual] -- ^ arguments + -> Maybe (Block CmmNode O O) + -- ^ 'Just' a block of instrumentation, if applicable +annotatePrim env (MO_AtomicRMW w aop) [dest] [addr, val] = Just $ tsanAtomicRMW env MemOrderSeqCst aop w addr val dest +annotatePrim env (MO_AtomicRead w mord) [dest] [addr] = Just $ tsanAtomicLoad env mord w addr dest +annotatePrim env (MO_AtomicWrite w mord) [] [addr, val] = Just $ tsanAtomicStore env mord w val addr +annotatePrim env (MO_Xchg w) [dest] [addr, val] = Just $ tsanAtomicExchange env MemOrderSeqCst w val addr dest +annotatePrim env (MO_Cmpxchg w) [dest] [addr, expected, new] + = Just $ tsanAtomicCas env MemOrderSeqCst MemOrderSeqCst w addr expected new dest +annotatePrim _ _ _ _ = Nothing + +mkUnsafeCall :: Env + -> ForeignTarget -- ^ function + -> [CmmFormal] -- ^ results + -> [CmmActual] -- ^ arguments + -> Block CmmNode O O +mkUnsafeCall env ftgt formals args = + save `blockAppend` -- save global registers + bind_args `blockSnoc` -- bind arguments to local registers + call `blockAppend` -- perform call + restore -- restore global registers + where + -- We are rather conservative here and just save/restore all GlobalRegs. + (save, restore) = saveRestoreCallerRegs (platform env) + + -- We also must be careful not to mention caller-saved registers in + -- arguments as Cmm-Lint checks this. To accomplish this we instead bind + -- the arguments to local registers. + arg_regs :: [CmmReg] + arg_regs = zipWith arg_reg (uniques env) args + where + arg_reg :: Unique -> CmmExpr -> CmmReg + arg_reg u expr = CmmLocal $ LocalReg u (cmmExprType (platform env) expr) + + bind_args :: Block CmmNode O O + bind_args = blockConcat $ zipWith (\r e -> BMiddle $ CmmAssign r e) arg_regs args + + call = CmmUnsafeForeignCall ftgt formals (map CmmReg arg_regs) + +saveRestoreCallerRegs :: Platform + -> (Block CmmNode O O, Block CmmNode O O) +saveRestoreCallerRegs platform = + (save, restore) + where + regs = filter (callerSaves platform) (activeStgRegs platform) + + save = blockFromList (map saveReg regs) + saveReg reg = + CmmStore (get_GlobalReg_addr platform reg) + (CmmReg (CmmGlobal reg)) + NaturallyAligned + + restore = blockFromList (map restoreReg regs) + restoreReg reg = + CmmAssign (CmmGlobal reg) + (CmmLoad (get_GlobalReg_addr platform reg) + (globalRegType platform reg) + NaturallyAligned) + +-- | Mirrors __tsan_memory_order +-- +memoryOrderToTsanMemoryOrder :: Env -> MemoryOrdering -> CmmExpr +memoryOrderToTsanMemoryOrder env mord = + mkIntExpr (platform env) n + where + n = case mord of + MemOrderRelaxed -> 0 + MemOrderAcquire -> 2 + MemOrderRelease -> 3 + MemOrderSeqCst -> 5 + +tsanTarget :: FastString -- ^ function name + -> [ForeignHint] -- ^ formals + -> [ForeignHint] -- ^ arguments + -> ForeignTarget +tsanTarget fn formals args = + ForeignTarget (CmmLit (CmmLabel lbl)) conv + where + conv = ForeignConvention CCallConv args formals CmmMayReturn + lbl = mkForeignLabel fn Nothing ForeignLabelInExternalPackage IsFunction + +tsanStore :: Env + -> AlignmentSpec -> CmmType -> CmmExpr + -> Block CmmNode O O +tsanStore env align ty addr = + mkUnsafeCall env ftarget [] [addr] + where + ftarget = tsanTarget fn [] [AddrHint] + w = widthInBytes (typeWidth ty) + fn = case align of + Unaligned + | w > 1 -> fsLit $ "__tsan_unaligned_write" ++ show w + _ -> fsLit $ "__tsan_write" ++ show w + +tsanLoad :: Env + -> AlignmentSpec -> CmmType -> CmmExpr + -> Block CmmNode O O +tsanLoad env align ty addr = + mkUnsafeCall env ftarget [] [addr] + where + ftarget = tsanTarget fn [] [AddrHint] + w = widthInBytes (typeWidth ty) + fn = case align of + Unaligned + | w > 1 -> fsLit $ "__tsan_unaligned_read" ++ show w + _ -> fsLit $ "__tsan_read" ++ show w + +tsanAtomicStore :: Env + -> MemoryOrdering -> Width -> CmmExpr -> CmmExpr + -> Block CmmNode O O +tsanAtomicStore env mord w val addr = + mkUnsafeCall env ftarget [] [addr, val, mord'] + where + mord' = memoryOrderToTsanMemoryOrder env mord + ftarget = tsanTarget fn [] [AddrHint, NoHint, NoHint] + fn = fsLit $ "__tsan_atomic" ++ show (widthInBits w) ++ "_store" + +tsanAtomicLoad :: Env + -> MemoryOrdering -> Width -> CmmExpr -> LocalReg + -> Block CmmNode O O +tsanAtomicLoad env mord w addr dest = + mkUnsafeCall env ftarget [dest] [addr, mord'] + where + mord' = memoryOrderToTsanMemoryOrder env mord + ftarget = tsanTarget fn [NoHint] [AddrHint, NoHint] + fn = fsLit $ "__tsan_atomic" ++ show (widthInBits w) ++ "_load" + +tsanAtomicExchange :: Env + -> MemoryOrdering -> Width -> CmmExpr -> CmmExpr -> LocalReg + -> Block CmmNode O O +tsanAtomicExchange env mord w val addr dest = + mkUnsafeCall env ftarget [dest] [addr, val, mord'] + where + mord' = memoryOrderToTsanMemoryOrder env mord + ftarget = tsanTarget fn [NoHint] [AddrHint, NoHint, NoHint] + fn = fsLit $ "__tsan_atomic" ++ show (widthInBits w) ++ "_exchange" + +-- N.B. C11 CAS returns a boolean (to avoid the ABA problem) whereas Cmm's CAS +-- returns the expected value. We use define a shim in the RTS to provide +-- Cmm's semantics using the TSAN C11 primitive. +tsanAtomicCas :: Env + -> MemoryOrdering -- ^ success ordering + -> MemoryOrdering -- ^ failure ordering + -> Width + -> CmmExpr -- ^ address + -> CmmExpr -- ^ expected value + -> CmmExpr -- ^ new value + -> LocalReg -- ^ result destination + -> Block CmmNode O O +tsanAtomicCas env mord_success mord_failure w addr expected new dest = + mkUnsafeCall env ftarget [dest] [addr, expected, new, mord_success', mord_failure'] + where + mord_success' = memoryOrderToTsanMemoryOrder env mord_success + mord_failure' = memoryOrderToTsanMemoryOrder env mord_failure + ftarget = tsanTarget fn [NoHint] [AddrHint, NoHint, NoHint, NoHint, NoHint] + fn = fsLit $ "ghc_tsan_atomic" ++ show (widthInBits w) ++ "_compare_exchange" + +tsanAtomicRMW :: Env + -> MemoryOrdering -> AtomicMachOp -> Width -> CmmExpr -> CmmExpr -> LocalReg + -> Block CmmNode O O +tsanAtomicRMW env mord op w addr val dest = + mkUnsafeCall env ftarget [dest] [addr, val, mord'] + where + mord' = memoryOrderToTsanMemoryOrder env mord + ftarget = tsanTarget fn [NoHint] [AddrHint, NoHint, NoHint] + op' = case op of + AMO_Add -> "fetch_add" + AMO_Sub -> "fetch_sub" + AMO_And -> "fetch_and" + AMO_Nand -> "fetch_nand" + AMO_Or -> "fetch_or" + AMO_Xor -> "fetch_xor" + fn = fsLit $ "__tsan_atomic" ++ show (widthInBits w) ++ "_" ++ op' + ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -1533,8 +1533,8 @@ genCCall target dest_regs arg_regs bid = do -- -- Atomic read-modify-write. MO_AtomicRMW w amop -> mkCCall (atomicRMWLabel w amop) - MO_AtomicRead w -> mkCCall (atomicReadLabel w) - MO_AtomicWrite w -> mkCCall (atomicWriteLabel w) + MO_AtomicRead w _ -> mkCCall (atomicReadLabel w) + MO_AtomicWrite w _ -> mkCCall (atomicWriteLabel w) MO_Cmpxchg w -> mkCCall (cmpxchgLabel w) -- -- Should be an AtomicRMW variant eventually. -- -- Sequential consistent. ===================================== compiler/GHC/CmmToAsm/PPC/CodeGen.hs ===================================== @@ -1173,7 +1173,7 @@ genCCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n] (n_reg, n_code) <- getSomeReg n return (op dst dst (RIReg n_reg), n_code) -genCCall (PrimTarget (MO_AtomicRead width)) [dst] [addr] +genCCall (PrimTarget (MO_AtomicRead width _)) [dst] [addr] = do let fmt = intFormat width reg_dst = getLocalRegReg dst form = if widthInBits width == 64 then DS else D @@ -1200,7 +1200,7 @@ genCCall (PrimTarget (MO_AtomicRead width)) [dst] [addr] -- This is also what gcc does. -genCCall (PrimTarget (MO_AtomicWrite width)) [] [addr, val] = do +genCCall (PrimTarget (MO_AtomicWrite width _)) [] [addr, val] = do code <- assignMem_IntCode (intFormat width) addr val return $ unitOL HWSYNC `appOL` code @@ -2067,8 +2067,8 @@ genCCall' config gcp target dest_regs args MO_AtomicRMW {} -> unsupported MO_Cmpxchg w -> (cmpxchgLabel w, False) MO_Xchg w -> (xchgLabel w, False) - MO_AtomicRead _ -> unsupported - MO_AtomicWrite _ -> unsupported + MO_AtomicRead _ _ -> unsupported + MO_AtomicWrite _ _ -> unsupported MO_S_Mul2 {} -> unsupported MO_S_QuotRem {} -> unsupported ===================================== compiler/GHC/CmmToAsm/Wasm/FromCmm.hs ===================================== @@ -1304,7 +1304,7 @@ lower_CallishMachOp lbl (MO_AtomicRMW w0 op) rs xs = CmmMayReturn rs xs -lower_CallishMachOp lbl (MO_AtomicRead w0) [reg] [ptr] = do +lower_CallishMachOp lbl (MO_AtomicRead w0 _) [reg] [ptr] = do SomeWasmExpr ty (WasmExpr ret_instr) <- lower_CmmLoad lbl @@ -1313,7 +1313,7 @@ lower_CallishMachOp lbl (MO_AtomicRead w0) [reg] [ptr] = do NaturallyAligned ri <- onCmmLocalReg_Typed ty reg pure $ WasmStatements $ ret_instr `WasmConcat` WasmLocalSet ty ri -lower_CallishMachOp lbl (MO_AtomicWrite _) [] [ptr, val] = +lower_CallishMachOp lbl (MO_AtomicWrite _ _) [] [ptr, val] = lower_CmmStore lbl ptr val NaturallyAligned lower_CallishMachOp lbl (MO_Cmpxchg w0) rs xs = lower_MO_Cmpxchg lbl w0 rs xs lower_CallishMachOp lbl (MO_Xchg w0) rs xs = ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -2203,8 +2203,8 @@ genSimplePrim bid (MO_Pdep width) [dst] [src,mask] = genPdep bid widt genSimplePrim bid (MO_Pext width) [dst] [src,mask] = genPext bid width dst src mask genSimplePrim bid (MO_Clz width) [dst] [src] = genClz bid width dst src genSimplePrim bid (MO_UF_Conv width) [dst] [src] = genWordToFloat bid width dst src -genSimplePrim _ (MO_AtomicRead w) [dst] [addr] = genAtomicRead w dst addr -genSimplePrim _ (MO_AtomicWrite w) [] [addr,val] = genAtomicWrite w addr val +genSimplePrim _ (MO_AtomicRead w mo) [dst] [addr] = genAtomicRead w mo dst addr +genSimplePrim _ (MO_AtomicWrite w mo) [] [addr,val] = genAtomicWrite w mo addr val genSimplePrim bid (MO_Cmpxchg width) [dst] [addr,old,new] = genCmpXchg bid width dst addr old new genSimplePrim _ (MO_Xchg width) [dst] [addr, value] = genXchg width dst addr value genSimplePrim _ (MO_AddWordC w) [r,c] [x,y] = genAddSubRetCarry w ADD_CC (const Nothing) CARRY r c x y @@ -3962,15 +3962,20 @@ genWordToFloat bid width dst src = -- TODO: generate assembly instead genPrimCCall bid (word2FloatLabel width) [dst] [src] -genAtomicRead :: Width -> LocalReg -> CmmExpr -> NatM InstrBlock -genAtomicRead width dst addr = do +genAtomicRead :: Width -> MemoryOrdering -> LocalReg -> CmmExpr -> NatM InstrBlock +genAtomicRead width _mord dst addr = do load_code <- intLoadCode (MOV (intFormat width)) addr return (load_code (getLocalRegReg dst)) -genAtomicWrite :: Width -> CmmExpr -> CmmExpr -> NatM InstrBlock -genAtomicWrite width addr val = do +genAtomicWrite :: Width -> MemoryOrdering -> CmmExpr -> CmmExpr -> NatM InstrBlock +genAtomicWrite width mord addr val = do code <- assignMem_IntCode (intFormat width) addr val - return $ code `snocOL` MFENCE + let needs_fence = case mord of + MemOrderSeqCst -> True + MemOrderRelease -> True + MemOrderAcquire -> pprPanic "genAtomicWrite: acquire ordering on write" empty + MemOrderRelaxed -> False + return $ if needs_fence then code `snocOL` MFENCE else code genCmpXchg :: BlockId ===================================== compiler/GHC/CmmToC.hs ===================================== @@ -944,8 +944,9 @@ pprCallishMachOp_for_C mop MO_AtomicRMW w amop -> ftext (atomicRMWLabel w amop) MO_Cmpxchg w -> ftext (cmpxchgLabel w) MO_Xchg w -> ftext (xchgLabel w) - MO_AtomicRead w -> ftext (atomicReadLabel w) - MO_AtomicWrite w -> ftext (atomicWriteLabel w) + -- TODO: handle orderings + MO_AtomicRead w _ -> ftext (atomicReadLabel w) + MO_AtomicWrite w _ -> ftext (atomicWriteLabel w) MO_UF_Conv w -> ftext (word2FloatLabel w) MO_S_Mul2 {} -> unsupported ===================================== compiler/GHC/CmmToLlvm/CodeGen.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.Semigroup as Semigroup import Data.List ( nub ) import Data.Maybe ( catMaybes ) -type Atomic = Bool +type Atomic = Maybe MemoryOrdering type LlvmStatements = OrdList LlvmStatement data Signage = Signed | Unsigned deriving (Eq, Show) @@ -265,9 +265,9 @@ genCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n] = runStmtsDecls $ retVar <- doExprW targetTy $ AtomicRMW op ptrVar nVar SyncSeqCst statement $ Store retVar dstVar Nothing -genCall (PrimTarget (MO_AtomicRead _)) [dst] [addr] = runStmtsDecls $ do +genCall (PrimTarget (MO_AtomicRead _ mem_ord)) [dst] [addr] = runStmtsDecls $ do dstV <- getCmmRegW (CmmLocal dst) - v1 <- genLoadW True addr (localRegType dst) NaturallyAligned + v1 <- genLoadW (Just mem_ord) addr (localRegType dst) NaturallyAligned statement $ Store v1 dstV Nothing genCall (PrimTarget (MO_Cmpxchg _width)) @@ -294,13 +294,14 @@ genCall (PrimTarget (MO_Xchg _width)) [dst] [addr, val] = runStmtsDecls $ do resVar <- doExprW (getVarType valVar) (AtomicRMW LAO_Xchg ptrVar valVar SyncSeqCst) statement $ Store resVar dstV Nothing -genCall (PrimTarget (MO_AtomicWrite _width)) [] [addr, val] = runStmtsDecls $ do +genCall (PrimTarget (MO_AtomicWrite _width mem_ord)) [] [addr, val] = runStmtsDecls $ do addrVar <- exprToVarW addr valVar <- exprToVarW val let ptrTy = pLift $ getVarType valVar ptrExpr = Cast LM_Inttoptr addrVar ptrTy ptrVar <- doExprW ptrTy ptrExpr - statement $ Expr $ AtomicRMW LAO_Xchg ptrVar valVar SyncSeqCst + let ordering = convertMemoryOrdering mem_ord + statement $ Expr $ AtomicRMW LAO_Xchg ptrVar valVar ordering -- Handle memcpy function specifically since llvm's intrinsic version takes -- some extra parameters. @@ -1012,11 +1013,11 @@ cmmPrimOpFunctions mop = do MO_Touch -> unsupported MO_UF_Conv _ -> unsupported - MO_AtomicRead _ -> unsupported - MO_AtomicRMW _ _ -> unsupported - MO_AtomicWrite _ -> unsupported - MO_Cmpxchg _ -> unsupported - MO_Xchg _ -> unsupported + MO_AtomicRead _ _ -> unsupported + MO_AtomicRMW _ _ -> unsupported + MO_AtomicWrite _ _ -> unsupported + MO_Cmpxchg _ -> unsupported + MO_Xchg _ -> unsupported MO_I64_ToI -> dontReach64 MO_I64_FromI -> dontReach64 @@ -1368,7 +1369,7 @@ exprToVarOpt opt e = case e of -> genLit opt lit CmmLoad e' ty align - -> genLoad False e' ty align + -> genLoad Nothing e' ty align -- Cmmreg in expression is the value, so must load. If you want actual -- reg pointer, call getCmmReg directly. @@ -1890,7 +1891,8 @@ case we will need a more granular way of specifying alignment. mkLoad :: Atomic -> LlvmVar -> AlignmentSpec -> LlvmExpression mkLoad atomic vptr alignment - | atomic = ALoad SyncSeqCst False vptr + | Just mem_ord <- atomic + = ALoad (convertMemoryOrdering mem_ord) False vptr | otherwise = Load vptr align where ty = pLower (getVarType vptr) @@ -2027,6 +2029,12 @@ genLit _ CmmHighStackMark -- * Misc -- +convertMemoryOrdering :: MemoryOrdering -> LlvmSyncOrdering +convertMemoryOrdering MemOrderRelaxed = SyncUnord +convertMemoryOrdering MemOrderAcquire = SyncAcquire +convertMemoryOrdering MemOrderRelease = SyncRelease +convertMemoryOrdering MemOrderSeqCst = SyncSeqCst + -- | Find CmmRegs that get assigned and allocate them on the stack -- -- Any register that gets written needs to be allocated on the ===================================== compiler/GHC/Driver/Config/Cmm.hs ===================================== @@ -18,6 +18,7 @@ initCmmConfig dflags = CmmConfig , cmmDoLinting = gopt Opt_DoCmmLinting dflags , cmmOptElimCommonBlks = gopt Opt_CmmElimCommonBlocks dflags , cmmOptSink = gopt Opt_CmmSink dflags + , cmmOptThreadSanitizer = gopt Opt_CmmThreadSanitizer dflags , cmmGenStackUnwindInstr = debugLevel dflags > 0 , cmmExternalDynamicRefs = gopt Opt_ExternalDynamicRefs dflags , cmmDoCmmSwitchPlans = not (backendHasNativeSwitch (backend dflags)) ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -66,6 +66,7 @@ data DumpFlag | Opt_D_dump_cmm_split | Opt_D_dump_cmm_info | Opt_D_dump_cmm_cps + | Opt_D_dump_cmm_thread_sanitizer -- end cmm subflags | Opt_D_dump_cfg_weights -- ^ Dump the cfg used for block layout. | Opt_D_dump_asm @@ -354,6 +355,7 @@ data GeneralFlag | Opt_Ticky_Dyn_Thunk | Opt_Ticky_Tag | Opt_Ticky_AP -- ^ Use regular thunks even when we could use std ap thunks in order to get entry counts + | Opt_CmmThreadSanitizer | Opt_RPath | Opt_RelativeDynlibPaths | Opt_CompactUnwind -- ^ @-fcompact-unwind@ ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2434,6 +2434,8 @@ dynamic_flags_deps = [ (setDumpFlag Opt_D_dump_cmm_cps) , make_ord_flag defGhcFlag "ddump-cmm-opt" (setDumpFlag Opt_D_dump_opt_cmm) + , make_ord_flag defGhcFlag "ddump-cmm-thread-sanitizer" + (setDumpFlag Opt_D_dump_cmm_thread_sanitizer) , make_ord_flag defGhcFlag "ddump-cfg-weights" (setDumpFlag Opt_D_dump_cfg_weights) , make_ord_flag defGhcFlag "ddump-core-stats" @@ -3511,8 +3513,8 @@ fFlagsDeps = [ unless (platformOS (targetPlatform dflags) == OSDarwin && turn_on) (addWarn "-compact-unwind is only implemented by the darwin platform. Ignoring.") return dflags)), - flagSpec "show-error-context" Opt_ShowErrorContext - + flagSpec "show-error-context" Opt_ShowErrorContext, + flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer ] ++ fHoleFlags ===================================== compiler/GHC/StgToCmm/ExtCode.hs ===================================== @@ -231,8 +231,12 @@ emitLabel = code . F.emitLabel emitAssign :: CmmReg -> CmmExpr -> CmmParse () emitAssign l r = code (F.emitAssign l r) -emitStore :: CmmExpr -> CmmExpr -> CmmParse () -emitStore l r = code (F.emitStore l r) +emitStore :: Maybe MemoryOrdering -> CmmExpr -> CmmExpr -> CmmParse () +emitStore (Just mem_ord) l r = do + platform <- getPlatform + let w = typeWidth $ cmmExprType platform r + emit $ mkUnsafeCall (PrimTarget $ MO_AtomicWrite w mem_ord) [] [l,r] +emitStore Nothing l r = code (F.emitStore l r) getCode :: CmmParse a -> CmmParse CmmAGraph getCode (EC ec) = EC $ \c e s -> do ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -3011,7 +3011,7 @@ doAtomicReadAddr doAtomicReadAddr res addr ty = emitPrimCall [ res ] - (MO_AtomicRead (typeWidth ty)) + (MO_AtomicRead (typeWidth ty) MemOrderSeqCst) [ addr ] -- | Emit an atomic write to a byte array that acts as a memory barrier. @@ -3039,7 +3039,7 @@ doAtomicWriteAddr doAtomicWriteAddr addr ty val = emitPrimCall [ {- no results -} ] - (MO_AtomicWrite (typeWidth ty)) + (MO_AtomicWrite (typeWidth ty) MemOrderSeqCst) [ addr, val ] doCasByteArray ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -61,7 +61,7 @@ import GHC.Types.Basic ( UnboxedTupleOrSum(..), unboxedTupleOrSumExtension ) import GHC.Types.Name import GHC.Types.Var.Env import GHC.Types.Var.Set -import GHC.Types.Var ( VarBndr(..), mkTyVar ) +import GHC.Types.Var ( VarBndr(..), isInvisibleFunArg, mkTyVar ) import GHC.Utils.FV import GHC.Utils.Error import GHC.Driver.Session @@ -1731,6 +1731,13 @@ the instance head, we'll expand the synonym on fly, and it'll look like instance (%,%) (Show Int, Show Int) and we /really/ don't want that. So we carefully do /not/ expand synonyms, by matching on TyConApp directly. + +For similar reasons, we do not use tcSplitSigmaTy when decomposing the instance +context, as the looks through type synonyms. If we looked through type +synonyms, then it could be possible to write an instance for a type synonym +involving a quantified constraint (see #22570). Instead, we define +splitInstTyForValidity, a specialized version of tcSplitSigmaTy (local to +GHC.Tc.Validity) that does not expand type synonyms. -} checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM () @@ -1774,11 +1781,31 @@ checkValidInstance ctxt hs_type ty = case tau of ; return () } _ -> failWithTc (TcRnNoClassInstHead tau) where - (_tvs, theta, tau) = tcSplitSigmaTy ty + (theta, tau) = splitInstTyForValidity ty -- The location of the "head" of the instance head_loc = getLoc (getLHsInstDeclHead hs_type) +-- | Split an instance type of the form @forall tvbs. inst_ctxt => inst_head@ +-- and return @(inst_ctxt, inst_head)@. This function makes no attempt to look +-- through type synonyms. See @Note [Instances and constraint synonyms]@. +splitInstTyForValidity :: Type -> (ThetaType, Type) +splitInstTyForValidity = split_context [] . drop_foralls + where + -- This is like 'dropForAlls', except that it does not look through type + -- synonyms. + drop_foralls :: Type -> Type + drop_foralls (ForAllTy (Bndr _tv argf) ty) + | isInvisibleForAllTyFlag argf = drop_foralls ty + drop_foralls ty = ty + + -- This is like 'tcSplitPhiTy', except that it does not look through type + -- synonyms. + split_context :: ThetaType -> Type -> (ThetaType, Type) + split_context preds (FunTy { ft_af = af, ft_arg = pred, ft_res = tau }) + | isInvisibleFunArg af = split_context (pred:preds) tau + split_context preds ty = (reverse preds, ty) + {- Note [Paterson conditions] ~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/ghc.cabal.in ===================================== @@ -214,6 +214,7 @@ Library GHC.Cmm.Sink GHC.Cmm.Switch GHC.Cmm.Switch.Implement + GHC.Cmm.ThreadSanitizer GHC.CmmToAsm GHC.Cmm.LRegSet GHC.CmmToAsm.AArch64 ===================================== docs/users_guide/debugging.rst ===================================== @@ -551,6 +551,13 @@ These flags dump various phases of GHC's C-\\- pipeline. Dump the results of the C-\\- control flow optimisation pass. +.. ghc-flag:: -ddump-cmm-thread-sanitizer + :shortdesc: Dump the results of the C-\\- ThreadSanitizer elaboration pass. + :type: dynamic + + Dump the results of the C-\\- pass responsible for adding instrumentation + added by :ghc-flag:`-fcmm-thread-sanitizer`. + .. ghc-flag:: -ddump-cmm-cbe :shortdesc: Dump the results of common block elimination :type: dynamic @@ -1075,6 +1082,15 @@ Checking for consistency Note that this is only intended to be used as a debugging measure, not as the primary means of catching out-of-bounds accesses. +.. ghc-flag:: -fcmm-thread-sanitizer + :shortdesc: Enable ThreadSanitizer instrumentation of memory accesses. + :type: dynamic + + This enables generation of `ThreadSanitizer + ` + instrumentation of memory accesses. Requires use of ``-fsanitize=thread`` + or similar when compiling and linking. + .. _checking-determinism: Checking for determinism ===================================== hadrian/src/Flavour.hs ===================================== @@ -203,12 +203,14 @@ splitSections = splitSectionsIf (/=ghc) -- Disable section splitting for the GHC library. It takes too long and -- there is little benefit. +-- | Build GHC and libraries with ThreadSanitizer support. You likely want to +-- configure with @--disable-large-address-space@ when using this. enableThreadSanitizer :: Flavour -> Flavour -enableThreadSanitizer = addArgs $ mconcat - [ builder (Ghc CompileHs) ? 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" <> arg "-DTSAN_ENABLED") +enableThreadSanitizer = addArgs $ notStage0 ? mconcat + [ builder (Ghc CompileHs) ? (arg "-optc-fsanitize=thread" <> arg "-fcmm-thread-sanitizer") + , builder (Ghc CompileCWithGhc) ? arg "-optc-fsanitize=thread" + , builder (Ghc LinkHs) ? (arg "-optc-fsanitize=thread" <> arg "-optl-fsanitize=thread") + , builder Cc ? arg "-fsanitize=thread" , builder (Cabal Flags) ? arg "thread-sanitizer" , builder Testsuite ? arg "--config=have_thread_sanitizer=True" ] ===================================== rts/HeapStackCheck.cmm ===================================== @@ -569,7 +569,7 @@ stg_block_takemvar_finally W_ r1, r3; r1 = R1; r3 = R3; - unlockClosure(R3, stg_MVAR_DIRTY_info); + unlockClosure(r3, stg_MVAR_DIRTY_info); R1 = r1; R3 = r3; jump StgReturn [R1]; @@ -597,7 +597,7 @@ stg_block_readmvar_finally W_ r1, r3; r1 = R1; r3 = R3; - unlockClosure(R3, stg_MVAR_DIRTY_info); + unlockClosure(r3, stg_MVAR_DIRTY_info); R1 = r1; R3 = r3; jump StgReturn [R1]; @@ -625,7 +625,7 @@ stg_block_putmvar_finally W_ r1, r3; r1 = R1; r3 = R3; - unlockClosure(R3, stg_MVAR_DIRTY_info); + unlockClosure(r3, stg_MVAR_DIRTY_info); R1 = r1; R3 = r3; jump StgReturn [R1]; ===================================== rts/TSANUtils.c ===================================== @@ -0,0 +1,37 @@ +#include + +#if defined(TSAN_ENABLED) + +uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, uint64_t new_value, int success_memorder, int failure_memorder) +{ + __tsan_atomic64_compare_exchange_strong( + ptr, &expected, new_value, + success_memorder, failure_memorder); + return expected; +} + +uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, uint32_t new_value, int success_memorder, int failure_memorder) +{ + __tsan_atomic32_compare_exchange_strong( + ptr, &expected, new_value, + success_memorder, failure_memorder); + return expected; +} + +uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, uint16_t new_value, int success_memorder, int failure_memorder) +{ + __tsan_atomic16_compare_exchange_strong( + ptr, &expected, new_value, + success_memorder, failure_memorder); + return expected; +} + +uint8_t ghc_tsan_atomic8_compare_exchange(uint8_t *ptr, uint8_t expected, uint8_t new_value, int success_memorder, int failure_memorder) +{ + __tsan_atomic8_compare_exchange_strong( + ptr, &expected, new_value, + success_memorder, failure_memorder); + return expected; +} + +#endif ===================================== rts/include/rts/TSANUtils.h ===================================== @@ -65,3 +65,10 @@ void AnnotateBenignRaceSized(const char *file, #define TSAN_ANNOTATE_BENIGN_RACE(addr,desc) \ TSAN_ANNOTATE_BENIGN_RACE_SIZED((void*)(addr), sizeof(*addr), desc) + + +uint64_t ghc_tsan_atomic64_compare_exchange(uint64_t *ptr, uint64_t expected, uint64_t new_value, int success_memorder, int failure_memorder); +uint32_t ghc_tsan_atomic32_compare_exchange(uint32_t *ptr, uint32_t expected, uint32_t new_value, int success_memorder, int failure_memorder); +uint16_t ghc_tsan_atomic16_compare_exchange(uint16_t *ptr, uint16_t expected, uint16_t new_value, int success_memorder, int failure_memorder); +uint8_t ghc_tsan_atomic8_compare_exchange(uint8_t *ptr, uint8_t expected, uint8_t new_value, int success_memorder, int failure_memorder); + ===================================== rts/rts.cabal.in ===================================== @@ -588,6 +588,7 @@ library Trace.c TraverseHeap.c TraverseHeapTest.c + TSANUtils.c WSDeque.c Weak.c eventlog/EventLog.c ===================================== testsuite/tests/typecheck/should_fail/T22570.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE QuantifiedConstraints #-} +module T22570 where + +import Data.Kind + +class SomeClass a +class OtherClass + +type SomeClassUnit = OtherClass => SomeClass () :: Constraint + +instance SomeClassUnit + +type SomeClassSyn a = OtherClass => SomeClass a :: Constraint + +instance SomeClassSyn () ===================================== testsuite/tests/typecheck/should_fail/T22570.stderr ===================================== @@ -0,0 +1,10 @@ + +T22570.hs:11:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassUnit’ + +T22570.hs:15:10: error: [GHC-53946] + • Illegal instance for a type synonym + A class instance must be for a class + • In the instance declaration for ‘SomeClassSyn ()’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -665,3 +665,4 @@ test('MissingDefaultMethodBinding', normal, compile_fail, ['']) test('T21447', normal, compile_fail, ['']) test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) +test('T22570', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/490b79cb641e8927a2341b63153926cc64482919...de68c3dd38d8aca5e0b44d48545a9e101a2e9fd3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/490b79cb641e8927a2341b63153926cc64482919...de68c3dd38d8aca5e0b44d48545a9e101a2e9fd3 You're receiving 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 Dec 14 13:37:53 2022 From: gitlab at gitlab.haskell.org (Richard Eisenberg (@rae)) Date: Wed, 14 Dec 2022 08:37:53 -0500 Subject: [Git][ghc/ghc][wip/p547] 127 commits: Fix a trivial typo in dataConNonlinearType Message-ID: <6399d1b1f3eb4_389fe25265c6081d@gitlab.mail> Richard Eisenberg pushed to branch wip/p547 at Glasgow Haskell Compiler / GHC Commits: 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - 8a4c499b by Richard Eisenberg at 2022-12-14T08:36:32-05:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/ProcPoint.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs - compiler/GHC/CmmToAsm/Reg/Target.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1591f26bad5afb4f1f6c1a9acfd56806025eb3a9...8a4c499ba068972c4656f807444777d17754a5b2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1591f26bad5afb4f1f6c1a9acfd56806025eb3a9...8a4c499ba068972c4656f807444777d17754a5b2 You're receiving 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 Dec 14 13:48:17 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 14 Dec 2022 08:48:17 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/lsp-crash Message-ID: <6399d4216ed57_389fe2ec1afd0612651@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/lsp-crash at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/lsp-crash You're receiving 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 Dec 14 14:31:23 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 14 Dec 2022 09:31:23 -0500 Subject: [Git][ghc/ghc][wip/ghc-9.6] base: Ensure that utf8DecodeCharPtr can inline Message-ID: <6399de3bf4062_389fe2202f1ac8617135@gitlab.mail> Ben Gamari pushed to branch wip/ghc-9.6 at Glasgow Haskell Compiler / GHC Commits: 5838edde by Ben Gamari at 2022-12-14T09:30:41-05:00 base: Ensure that utf8DecodeCharPtr can inline - - - - - 1 changed file: - libraries/base/GHC/Encoding/UTF8.hs Changes: ===================================== libraries/base/GHC/Encoding/UTF8.hs ===================================== @@ -146,6 +146,7 @@ utf8DecodeCharPtr :: Ptr Word8 -> (Char, Int) utf8DecodeCharPtr !(Ptr a#) = case utf8DecodeCharAddr# a# 0# of (# c#, nBytes# #) -> ( C# c#, I# nBytes# ) +{-# INLINEABLE utf8DecodeCharPtr #-} -- | Decode a single codepoint starting at the given byte offset into a -- 'ByteArray#'. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5838eddefaa2e458c36a034ae6d4255538bf7b07 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5838eddefaa2e458c36a034ae6d4255538bf7b07 You're receiving 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 Dec 14 15:08:56 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 14 Dec 2022 10:08:56 -0500 Subject: [Git][ghc/ghc][wip/andreask/spark-gc] Only gc sparks locally when we can ensure marking is done. Message-ID: <6399e70882cda_389fe223e00934624575@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/spark-gc at Glasgow Haskell Compiler / GHC Commits: 84cb36e2 by Andreas Klebinger at 2022-12-14T16:08:07+01:00 Only gc sparks locally when we can ensure marking is done. When performing GC without work stealing there was no guarantee that spark pruning was happening after marking of the sparks. This could cause us to GC live sparks under certain circumstances. Fixes #22528. - - - - - 3 changed files: - docs/users_guide/9.6.1-notes.rst - rts/Sparks.c - rts/sm/GC.c Changes: ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -126,6 +126,9 @@ Runtime system Previously only live blocks were taken into account. This makes it more likely to trigger promptly when the heap is highly fragmented. +- Fixed a bug that sometimes caused live sparks to be GC'ed too early either during + minor GC or major GC with workstealing disabled. See #22528. + ``base`` library ~~~~~~~~~~~~~~~~ @@ -146,9 +149,9 @@ Runtime system - Updated to `Unicode 15.0.0 `_. -- Add standard Unicode case predicates :base-ref:`Data.Char.isUpperCase` and - :base-ref:`Data.Char.isLowerCase`. These predicates use the standard Unicode - case properties and are more intuitive than :base-ref:`Data.Char.isUpper` and +- Add standard Unicode case predicates :base-ref:`Data.Char.isUpperCase` and + :base-ref:`Data.Char.isLowerCase`. These predicates use the standard Unicode + case properties and are more intuitive than :base-ref:`Data.Char.isUpper` and :base-ref:`Data.Char.isLower`. ``ghc-prim`` library ===================================== rts/Sparks.c ===================================== @@ -79,6 +79,34 @@ newSpark (StgRegTable *reg, StgClosure *p) return 1; } +/* Note [Pruning the spark pool] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +pruneSparkQueue checks if closures have been evacuated to know weither or +not a spark can be GCed. If it was evacuated it's live and we keep the spark +alive. If it hasn't been evacuated at the end of GC we can assume it's dead and +remove the spark from the pool. + +To make this sound we must ensure GC has finished evacuating live objects before +we prune the spark pool. Otherwise we might GC a spark before it has been evaluated. + +* If we run sequential GC then the GC Lead simply prunes after +everything has been evacuated. + +* If we run parallel gc without work stealing then GC workers are not synchronized +at any point before the worker returns. So we leave it to the GC Lead to prune +sparks once evacuation has been finished and all workers returned. + +* If work stealing is enabled all GC threads will be running +scavenge_until_all_done until regular heap marking is done. After which +all workers will converge on a synchronization point. This means +we can perform spark pruning inside the GC workers at this point. +The only wart is that if we prune sparks locally we might +miss sparks reachable via weak pointers as these are marked in the main +thread concurrently to the calls to pruneSparkQueue. To fix this problem would +require a GC barrier but that seems to high a price to pay. +*/ + + /* -------------------------------------------------------------------------- * Remove all sparks from the spark queues which should not spark any * more. Called after GC. We assume exclusive access to the structure @@ -181,7 +209,7 @@ pruneSparkQueue (bool nonmovingMarkFinished, Capability *cap) cap->spark_stats.fizzled++; traceEventSparkFizzle(cap); } else { - info = spark->header.info; + info = RELAXED_LOAD(&spark->header.info); load_load_barrier(); if (IS_FORWARDING_PTR(info)) { tmp = (StgClosure*)UN_FORWARDING_PTR(info); ===================================== rts/sm/GC.c ===================================== @@ -292,6 +292,7 @@ GarbageCollect (uint32_t collect_gen, any_work, scav_find_work, max_n_todo_overflow; #if defined(THREADED_RTS) gc_thread *saved_gct; + bool gc_sparks_all_caps; #endif uint32_t g, n; // The time we should report our heap census as occurring at, if necessary. @@ -559,6 +560,9 @@ GarbageCollect (uint32_t collect_gen, StgTSO *resurrected_threads = END_TSO_QUEUE; // must be last... invariant is that everything is fully // scavenged at this point. +#if defined(THREADED_RTS) + gc_sparks_all_caps = !work_stealing || !is_par_gc(); +#endif work_stealing = false; while (traverseWeakPtrList(&dead_weak_ptr_list, &resurrected_threads)) { @@ -571,7 +575,8 @@ GarbageCollect (uint32_t collect_gen, gcStableNameTable(); #if defined(THREADED_RTS) - if (!is_par_gc()) { + // See Note [Pruning the spark pool] + if(gc_sparks_all_caps) { for (n = 0; n < n_capabilities; n++) { pruneSparkQueue(false, capabilities[n]); } @@ -1387,7 +1392,6 @@ void gcWorkerThread (Capability *cap) { gc_thread *saved_gct; - // necessary if we stole a callee-saves register for gct: saved_gct = gct; @@ -1418,13 +1422,10 @@ gcWorkerThread (Capability *cap) scavenge_until_all_done(); #if defined(THREADED_RTS) - // Now that the whole heap is marked, we discard any sparks that - // were found to be unreachable. The main GC thread is currently - // marking heap reachable via weak pointers, so it is - // non-deterministic whether a spark will be retained if it is - // only reachable via weak pointers. To fix this problem would - // require another GC barrier, which is too high a price. - pruneSparkQueue(false, cap); + // See Note [Pruning the spark pool] + if(work_stealing && is_par_gc()) { + pruneSparkQueue(false, cap); + } #endif // Wait until we're told to continue View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84cb36e2d8037603e9f55460a2ed558b35c068c6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84cb36e2d8037603e9f55460a2ed558b35c068c6 You're receiving 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 Dec 14 16:27:46 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 14 Dec 2022 11:27:46 -0500 Subject: [Git][ghc/ghc][ghc-9.4] 18 commits: ApplicativeDo: Set pattern location before running exhaustiveness checker Message-ID: <6399f9823eb05_389fe21bc707846534e8@gitlab.mail> Matthew Pickering pushed to branch ghc-9.4 at Glasgow Haskell Compiler / GHC Commits: 51c6051b by Matthew Pickering at 2022-12-13T09:30:47+00:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 (cherry picked from commit 74c767df770766d8d52e87b9ff7da10f94620a91) - - - - - 13040bf0 by Matthew Pickering at 2022-12-13T09:30:47+00:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 (cherry picked from commit 1d3a8b8ec98e6eedf8943e19780ec374c2491e7f) - - - - - 127dcc49 by Ian-Woo Kim at 2022-12-13T09:30:47+00:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. (cherry picked from commit 2057c77d08cb8422857d182a3691f98dccd0c7d6) - - - - - f84d7562 by Simon Peyton Jones at 2022-12-13T09:30:47+00:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! (cherry picked from commit afc2540daf6ca6baa09ab147b792da08d66d878c) - - - - - 8c85afe3 by sheaf at 2022-12-13T09:30:47+00:00 Fix @since annotations on WithDict and Coercible Fixes #22453 (cherry picked from commit 68c966cd3c9d581bac4573807e433fe8d063445f) - - - - - 7fbcb2c6 by Ben Gamari at 2022-12-13T09:30:47+00:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. (cherry picked from commit 268a3ce952f6be00a1dd164dc4d7acb346045e90) - - - - - ea7fb64d by Matthew Pickering at 2022-12-13T09:30:47+00:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 (cherry picked from commit 6dab0046b575e102bf3245fd63d5ac6bc6f4204d) - - - - - 5912ca80 by Ben Gamari at 2022-12-13T09:30:47+00:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. (cherry picked from commit a4dbd102af1989526ca87f4dd949f72231284e68) - - - - - f34261f3 by Ben Gamari at 2022-12-13T09:30:47+00:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. (cherry picked from commit 30f0d9a9ded55a822e094847d5ac8087262fb8da) - - - - - 3e648642 by Andreas Klebinger at 2022-12-13T09:30:47+00:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. (cherry picked from commit 31462d98c31e3ef48af2f6c6f2d379d74ccc63f5) - - - - - 7a40261f by Dai at 2022-12-13T09:30:47+00:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 (cherry picked from commit 5b3a992f5d166007c3c5a22f120ed08e0a27f01a) - - - - - 19d7a5fc by sheaf at 2022-12-13T09:30:47+00:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 (cherry picked from commit 6d7d91817795d7ee7f45557411368a1738daa488) - - - - - 2e778abc by sheaf at 2022-12-13T09:30:48+00:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. (cherry picked from commit 3be48877e204fca8e5d5ab984186e0d20d81f262) - - - - - 052dc022 by sheaf at 2022-12-13T09:30:48+00:00 Disable some SIMD tests on non-X86 architectures (cherry picked from commit f7b7a3122185222d5059e37315991afcf319e43c) - - - - - 3cc20a1a by Andreas Klebinger at 2022-12-13T09:30:48+00:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. (cherry picked from commit 8d2dbe2db4cc7c8b6d39b1ea64b0508304a3273c) - - - - - fcce6b7e by Simon Peyton Jones at 2022-12-13T09:30:48+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 (cherry picked from commit 294f907370fadd3313f8c5e6aa87a93c8b86f139) - - - - - c43e5681 by Gabriella Gonzalez at 2022-12-13T09:30:48+00:00 Serialize builds of `rts` and `system-cxx-std-lib` Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/22099 I cannot say for sure that this will fix the linked issue, but I explained why I believe this fixes the root problem in: https://gitlab.haskell.org/ghc/ghc/-/issues/22099#note_461386 … and when we applied this patch internally the problem appeared to disappear for a few builds in a row with a large number of cores. The short summary of the above comment is that the `Makefile` serializes the package registrations using `ghc-pkgs`, with the exception of two packages (`rts` and `system-cxx-std-lib`) and we expect that this one instance of parallelism that was still left in the `Makefile` was the root cause of the flaky build failure. This fix would be consistent with two known things about the failure: - The build failure only occurs for parallel `Make` builds … and these are the only two `ghc-pkg` calls that run concurrently - The error first appeared in the GHC 9.4 branch and was absent in GHC 9.2 … and GHC 9.4 was the first release that included `system-cxx-std-lib` (as far as I know), which would explain why this problem didn't happen before. The change here forces the two packages to be registered in sequence. This problem will of course go away in GHC 9.6 by virtue of dropping the `make`-based build, but since the GHC 9.4 branch is supported and active we wanted to upstream this patch to the 9.4 development branch. - - - - - 5e9ac694 by Matthew Pickering at 2022-12-14T16:19:58+00:00 Package Imports: Get candidate packages also from re-exported modules Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333 (cherry picked from commit 58a138d0f62c057333e4fd15fe20df64492b1dac) - - - - - 30 changed files: - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Linker/Windows.hs - compiler/GHC/Stg/Lint.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools/Process.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/State.hs - compiler/GHC/Utils/Outputable.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - ghc.mk - libraries/base/Data/Coerce.hs - 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/81cae7b73588ad77ef2e8e0e1dbe4052ecd0155f...5e9ac6946d7082502fe05546d32429e2f3aca9b6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81cae7b73588ad77ef2e8e0e1dbe4052ecd0155f...5e9ac6946d7082502fe05546d32429e2f3aca9b6 You're receiving 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 Dec 14 16:32:44 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Dec 2022 11:32:44 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 15 commits: hadrian: Don't enable TSAN in stage0 build Message-ID: <6399faac22a70_389fe2202f1ac8685046@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ab26eaf6 by Ben Gamari at 2022-12-14T11:32:35-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - dfd64c8d by Ben Gamari at 2022-12-14T11:32:35-05:00 cmm: Introduce blockConcat - - - - - 16a2212f by Ben Gamari at 2022-12-14T11:32:35-05:00 cmm: Introduce MemoryOrderings - - - - - 906b75f0 by Ben Gamari at 2022-12-14T11:32:35-05:00 llvm: Respect memory specified orderings - - - - - 315cdea0 by Ben Gamari at 2022-12-14T11:32:35-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 13fb39e0 by Ben Gamari at 2022-12-14T11:32:35-05:00 cmm/Parser: Reduce some repetition - - - - - ea0292ce by Ben Gamari at 2022-12-14T11:32:35-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 6052fc7f by Ben Gamari at 2022-12-14T11:32:35-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - a353dc3e by Ben Gamari at 2022-12-14T11:32:35-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 74d9df9d by Ben Gamari at 2022-12-14T11:32:35-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 8a6f80fb by Ben Gamari at 2022-12-14T11:32:35-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 116211c9 by Ben Gamari at 2022-12-14T11:32:35-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - f7a32c4f by Matthew Pickering at 2022-12-14T11:32:36-05:00 Package Imports: Get candidate packages also from re-exported modules Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333 - - - - - d6ba1944 by Simon Peyton Jones at 2022-12-14T11:32:37-05:00 Fix bogus test in Lint The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation. - - - - - 43bdca74 by Ryan Scott at 2022-12-14T11:32:37-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/State.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - hadrian/src/Flavour.hs - rts/HeapStackCheck.cmm The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de68c3dd38d8aca5e0b44d48545a9e101a2e9fd3...43bdca74d2b22a78409e36f9fdbc1726dee2296a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de68c3dd38d8aca5e0b44d48545a9e101a2e9fd3...43bdca74d2b22a78409e36f9fdbc1726dee2296a You're receiving 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 Dec 14 16:34:38 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 14 Dec 2022 11:34:38 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/submodule-bumps Message-ID: <6399fb1ed60c9_389fe25265c69453@gitlab.mail> Ben Gamari pushed new branch wip/submodule-bumps at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/submodule-bumps You're receiving 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 Dec 14 18:41:59 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 14 Dec 2022 13:41:59 -0500 Subject: [Git][ghc/ghc][wip/various-hadrian-fixes] 53 commits: Fix bounds-checking buglet in Data.Array.Byte Message-ID: <639a18f76c2c9_1704975260c782d4@gitlab.mail> Ben Gamari pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC Commits: e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00 JS: fix object file name comparison (#22578) - - - - - e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - 14f0bcfb by Matthew Pickering at 2022-12-14T13:39:19-05:00 compiler: Add -f[no-]split-sections flags Here we add a `-fsplit-sections` flag which may some day replace `-split-sections`. This has the advantage of automatically providing a `-fno-split-sections` flag, which is useful for our packaging because we enable `-split-sections` by default but want to disable it in certain configurations. - - - - - aa06bc73 by Matthew Pickering at 2022-12-14T13:40:45-05:00 hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b - - - - - 2664e5a1 by Matthew Pickering at 2022-12-14T13:40:45-05:00 hadrian: Add test:all_deps to build just testsuite dependencies Fixes #22534 - - - - - 606b82b4 by Matthew Pickering at 2022-12-14T13:41:37-05:00 hadrian: Add no_split_sections tranformer This transformer reverts the effect of `split_sections`, which we intend to use for platforms which don't support split sections. - - - - - a3b95d4f by Matthew Pickering at 2022-12-14T13:41:43-05:00 check-exact: Fix build with -Werror - - - - - c1e02a64 by Matthew Pickering at 2022-12-14T13:41:43-05:00 ci: Build all test dependencies with in-tree compiler This means that these executables will honour flavour transformers such as "werror". Fixes #22555 - - - - - d8a6912b by Matthew Pickering at 2022-12-14T13:41:43-05:00 hadrian: Document using GHC environment variable to select boot compiler Fixes #22340 - - - - - 68220510 by Matthew Pickering at 2022-12-14T13:41:43-05:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/CodeGen.Platform.h - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Seq.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Data/Unboxed.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline/Execute.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/b6659bbeb64540bf783833c5b8f465316ff068e7...6822051009ddb8a98ff99a7ffb85a01121871932 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b6659bbeb64540bf783833c5b8f465316ff068e7...6822051009ddb8a98ff99a7ffb85a01121871932 You're receiving 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 Dec 14 19:33:05 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Dec 2022 14:33:05 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 15 commits: hadrian: Don't enable TSAN in stage0 build Message-ID: <639a24f152b3c_17049759eac9547b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 15982af8 by Ben Gamari at 2022-12-14T14:32:56-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - 91c679e7 by Ben Gamari at 2022-12-14T14:32:56-05:00 cmm: Introduce blockConcat - - - - - 638e5219 by Ben Gamari at 2022-12-14T14:32:56-05:00 cmm: Introduce MemoryOrderings - - - - - afe3c969 by Ben Gamari at 2022-12-14T14:32:56-05:00 llvm: Respect memory specified orderings - - - - - 5e28d1a7 by Ben Gamari at 2022-12-14T14:32:56-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - b18c288d by Ben Gamari at 2022-12-14T14:32:56-05:00 cmm/Parser: Reduce some repetition - - - - - 81fda5c2 by Ben Gamari at 2022-12-14T14:32:56-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 36d94c96 by Ben Gamari at 2022-12-14T14:32:56-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 469351aa by Ben Gamari at 2022-12-14T14:32:56-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 7b303230 by Ben Gamari at 2022-12-14T14:32:56-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - ea8824da by Ben Gamari at 2022-12-14T14:32:56-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - e2fa3045 by Ben Gamari at 2022-12-14T14:32:56-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 45922e95 by Matthew Pickering at 2022-12-14T14:32:56-05:00 Package Imports: Get candidate packages also from re-exported modules Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333 - - - - - dd3c1cb7 by Simon Peyton Jones at 2022-12-14T14:32:57-05:00 Fix bogus test in Lint The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation. - - - - - 969c3c03 by Ryan Scott at 2022-12-14T14:32:57-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/State.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - hadrian/src/Flavour.hs - rts/HeapStackCheck.cmm The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43bdca74d2b22a78409e36f9fdbc1726dee2296a...969c3c0360818d6d728575ce24b39ac571b24e55 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43bdca74d2b22a78409e36f9fdbc1726dee2296a...969c3c0360818d6d728575ce24b39ac571b24e55 You're receiving 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 Dec 14 22:53:27 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Dec 2022 17:53:27 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 15 commits: hadrian: Don't enable TSAN in stage0 build Message-ID: <639a53e7f8f6_17049759e701202a8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 04645084 by Ben Gamari at 2022-12-14T17:53:14-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - 9d96d103 by Ben Gamari at 2022-12-14T17:53:14-05:00 cmm: Introduce blockConcat - - - - - 8af764cb by Ben Gamari at 2022-12-14T17:53:14-05:00 cmm: Introduce MemoryOrderings - - - - - 869281d8 by Ben Gamari at 2022-12-14T17:53:14-05:00 llvm: Respect memory specified orderings - - - - - ee563beb by Ben Gamari at 2022-12-14T17:53:14-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - b9576f31 by Ben Gamari at 2022-12-14T17:53:15-05:00 cmm/Parser: Reduce some repetition - - - - - 23f0903a by Ben Gamari at 2022-12-14T17:53:15-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 2497123c by Ben Gamari at 2022-12-14T17:53:15-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - e6704719 by Ben Gamari at 2022-12-14T17:53:15-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 6f2c716e by Ben Gamari at 2022-12-14T17:53:15-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 61dff6ca by Ben Gamari at 2022-12-14T17:53:15-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 0e989d73 by Ben Gamari at 2022-12-14T17:53:15-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 5e12e7b3 by Matthew Pickering at 2022-12-14T17:53:15-05:00 Package Imports: Get candidate packages also from re-exported modules Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333 - - - - - f0454f15 by Simon Peyton Jones at 2022-12-14T17:53:16-05:00 Fix bogus test in Lint The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation. - - - - - fdcba2cf by Ryan Scott at 2022-12-14T17:53:16-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/State.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - hadrian/src/Flavour.hs - rts/HeapStackCheck.cmm The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/969c3c0360818d6d728575ce24b39ac571b24e55...fdcba2cfbd09937edbe915b59497d67237661505 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/969c3c0360818d6d728575ce24b39ac571b24e55...fdcba2cfbd09937edbe915b59497d67237661505 You're receiving 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 Dec 15 00:58:23 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 14 Dec 2022 19:58:23 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22561 Message-ID: <639a712f3216_17049715fcaac136565@gitlab.mail> Ben Gamari pushed new branch wip/T22561 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22561 You're receiving 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 Dec 15 00:59:54 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 14 Dec 2022 19:59:54 -0500 Subject: [Git][ghc/ghc][wip/various-hadrian-fixes] packaging: Build perf builds with -split-sections Message-ID: <639a718a30049_17049759ec01387b4@gitlab.mail> Ben Gamari pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC Commits: e8069bef by Matthew Pickering at 2022-12-14T19:59:33-05:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135 - - - - - 6 changed files: - .gitlab-ci.yml - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Driver/Session.hs - hadrian/doc/flavours.md - hadrian/src/Settings/Flavours/Performance.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -501,7 +501,7 @@ doc-tarball: optional: true - job: nightly-x86_64-windows-validate optional: true - - job: release-x86_64-windows-release + - job: release-x86_64-windows-release+no_split_sections optional: true tags: @@ -525,7 +525,7 @@ doc-tarball: || mv "ghc-x86_64-linux-deb10-release.tar.xz" "$LINUX_BINDIST" \ || true mv "ghc-x86_64-windows-validate.tar.xz" "$WINDOWS_BINDIST" \ - || mv "ghc-x86_64-windows-release.tar.xz" "$WINDOWS_BINDIST" \ + || mv "ghc-x86_64-windows-release+no_split_sections.tar.xz" "$WINDOWS_BINDIST" \ || true if [ ! -f "$LINUX_BINDIST" ]; then echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?" ===================================== .gitlab/gen_ci.hs ===================================== @@ -130,6 +130,7 @@ data BuildConfig , fullyStatic :: Bool , tablesNextToCode :: Bool , threadSanitiser :: Bool + , noSplitSections :: Bool } -- Extra arguments to pass to ./configure due to the BuildConfig @@ -146,13 +147,14 @@ mkJobFlavour BuildConfig{..} = Flavour buildFlavour opts opts = [Llvm | llvmBootstrap] ++ [Dwarf | withDwarf] ++ [FullyStatic | fullyStatic] ++ - [ThreadSanitiser | threadSanitiser] + [ThreadSanitiser | threadSanitiser] ++ + [NoSplitSections | noSplitSections, buildFlavour == Release ] data Flavour = Flavour BaseFlavour [FlavourTrans] -data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser +data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser | NoSplitSections -data BaseFlavour = Release | Validate | SlowValidate +data BaseFlavour = Release | Validate | SlowValidate deriving Eq ----------------------------------------------------------------------------- -- Build Configs @@ -174,8 +176,12 @@ vanilla = BuildConfig , fullyStatic = False , tablesNextToCode = True , threadSanitiser = False + , noSplitSections = False } +splitSectionsBroken :: BuildConfig -> BuildConfig +splitSectionsBroken bc = bc { noSplitSections = True } + nativeInt :: BuildConfig nativeInt = vanilla { bignumBackend = Native } @@ -290,6 +296,7 @@ flavourString (Flavour base trans) = baseString base ++ concatMap (("+" ++) . fl flavourString Dwarf = "debug_info" flavourString FullyStatic = "fully_static" flavourString ThreadSanitiser = "thread_sanitizer" + flavourString NoSplitSections = "no_split_sections" -- The path to the docker image (just for linux builders) dockerImage :: Arch -> Opsys -> Maybe String @@ -792,23 +799,23 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , disableValidate (standardBuilds Amd64 (Linux Debian11)) -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 -- not being at EOL until April 2023 and they still need tinfo5. - , disableValidate (standardBuilds Amd64 (Linux Debian9)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) (splitSectionsBroken vanilla)) , disableValidate (standardBuilds Amd64 (Linux Ubuntu2004)) - , disableValidate (standardBuilds Amd64 (Linux Centos7)) + , disableValidate (standardBuildsWithConfig Amd64 (Linux Centos7) (splitSectionsBroken vanilla)) -- Fedora33 job is always built with perf so there's one job in the normal -- validate pipeline which is built with perf. , (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig) -- This job is only for generating head.hackage docs , hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig)) , disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf) - , fastCI (standardBuilds Amd64 Windows) - , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt) + , fastCI (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla)) + , disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt)) , standardBuilds Amd64 Darwin , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13)) , standardBuilds AArch64 Darwin , standardBuilds AArch64 (Linux Debian10) - , standardBuilds I386 (Linux Debian9) - , standardBuildsWithConfig Amd64 (Linux Alpine) static + , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla) + , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static) , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure") ===================================== .gitlab/jobs.yaml ===================================== @@ -1869,7 +1869,7 @@ "XZ_OPT": "-9" } }, - "release-i386-linux-deb9-release": { + "release-i386-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1879,7 +1879,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-i386-linux-deb9-release.tar.xz", + "ghc-i386-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -1921,11 +1921,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-i386-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "i386-linux-deb9-release", + "TEST_ENV": "i386-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2120,7 +2120,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-linux-alpine3_12-release+fully_static": { + "release-x86_64-linux-alpine3_12-release+fully_static+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2130,7 +2130,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-alpine3_12-release+fully_static.tar.xz", + "ghc-x86_64-linux-alpine3_12-release+fully_static+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2172,18 +2172,18 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+fully_static", + "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+fully_static+no_split_sections", "BROKEN_TESTS": "encoding004 T10458 ghcilink002 linker_unload_native", - "BUILD_FLAVOUR": "release+fully_static", + "BUILD_FLAVOUR": "release+fully_static+no_split_sections", "CONFIGURE_ARGS": "--disable-ld-override ", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", "INSTALL_CONFIGURE_ARGS": "--disable-ld-override", - "TEST_ENV": "x86_64-linux-alpine3_12-release+fully_static", + "TEST_ENV": "x86_64-linux-alpine3_12-release+fully_static+no_split_sections", "XZ_OPT": "-9" } }, - "release-x86_64-linux-centos7-release": { + "release-x86_64-linux-centos7-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2193,7 +2193,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-centos7-release.tar.xz", + "ghc-x86_64-linux-centos7-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2235,12 +2235,12 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "HADRIAN_ARGS": "--docs=no-sphinx", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "x86_64-linux-centos7-release", + "TEST_ENV": "x86_64-linux-centos7-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2424,7 +2424,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-linux-deb9-release": { + "release-x86_64-linux-deb9-release+no_split_sections": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -2434,7 +2434,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-linux-deb9-release.tar.xz", + "ghc-x86_64-linux-deb9-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2476,11 +2476,11 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CONFIGURE_ARGS": "", "IGNORE_PERF_FAILURES": "all", - "TEST_ENV": "x86_64-linux-deb9-release", + "TEST_ENV": "x86_64-linux-deb9-release+no_split_sections", "XZ_OPT": "-9" } }, @@ -2731,7 +2731,7 @@ "XZ_OPT": "-9" } }, - "release-x86_64-windows-int_native-release": { + "release-x86_64-windows-int_native-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2740,7 +2740,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-int_native-release.tar.xz", + "ghc-x86_64-windows-int_native-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2778,8 +2778,8 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2787,11 +2787,11 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-int_native-release", + "TEST_ENV": "x86_64-windows-int_native-release+no_split_sections", "XZ_OPT": "-9" } }, - "release-x86_64-windows-release": { + "release-x86_64-windows-release+no_split_sections": { "after_script": [ "bash .gitlab/ci.sh save_cache", "bash .gitlab/ci.sh clean" @@ -2800,7 +2800,7 @@ "artifacts": { "expire_in": "1 year", "paths": [ - "ghc-x86_64-windows-release.tar.xz", + "ghc-x86_64-windows-release+no_split_sections.tar.xz", "junit.xml" ], "reports": { @@ -2838,8 +2838,8 @@ ], "variables": { "BIGNUM_BACKEND": "gmp", - "BIN_DIST_NAME": "ghc-x86_64-windows-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections", + "BUILD_FLAVOUR": "release+no_split_sections", "CABAL_INSTALL_VERSION": "3.2.0.0", "CONFIGURE_ARGS": "", "GHC_VERSION": "9.2.2", @@ -2847,7 +2847,7 @@ "IGNORE_PERF_FAILURES": "all", "LANG": "en_US.UTF-8", "MSYSTEM": "MINGW64", - "TEST_ENV": "x86_64-windows-release", + "TEST_ENV": "x86_64-windows-release+no_split_sections", "XZ_OPT": "-9" } }, ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -4797,7 +4797,7 @@ makeDynFlagsConsistent dflags | gopt Opt_SplitSections dflags , platformHasSubsectionsViaSymbols (targetPlatform dflags) - = let dflags' = gopt_unuset dflags Opt_SplitSections + = let dflags' = gopt_unset dflags Opt_SplitSections warn = "-fsplit-sections is not useful on this platform " ++ "since it uses subsections-via-symbols. Ignoring." in loop dflags' warn ===================================== hadrian/doc/flavours.md ===================================== @@ -15,6 +15,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
FlavourSplit Sections Extra arguments
default
+
-O
-H32m
-O2
-H32m
quick + -O0
-H64m
-O0
-H64m
quick-validate + -O0
-H64m
-Werror
-O0
-H64m
-Werror
quick-debug + -O0
-H64m
-O0
-H64m
quickest + -O0
-H64m
-O0
-H64m
perf + Yes (on supported platforms) -O
-H64m
-O
-H64m
bench + -O
-H64m
-O
-H64m
devel1 + -O
-H64m
-O
-H64m
devel2 + -O
-H64m
-O
-H64m
validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
slow-validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
static + -O
-H64m
-fPIC -static
-O
-H64m
-fPIC -static
+ @@ -35,6 +36,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -46,6 +48,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -57,6 +60,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -68,6 +72,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -79,6 +84,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -90,6 +96,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -112,6 +119,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -123,6 +131,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -134,6 +143,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -145,6 +155,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -156,6 +167,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH @@ -167,6 +179,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH ===================================== hadrian/src/Settings/Flavours/Performance.hs ===================================== @@ -6,7 +6,7 @@ import {-# SOURCE #-} Settings.Default -- Please update doc/flavours.md when changing this file. performanceFlavour :: Flavour -performanceFlavour = defaultFlavour +performanceFlavour = splitSections $ defaultFlavour { name = "perf" , args = defaultBuilderArgs <> performanceArgs <> defaultPackageArgs } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8069bef782ba42ffbf71d1fcec8899c8a540625 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8069bef782ba42ffbf71d1fcec8899c8a540625 You're receiving 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 Dec 15 01:02:06 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 14 Dec 2022 20:02:06 -0500 Subject: [Git][ghc/ghc][wip/T22561] 1127 commits: Drop the app invariant Message-ID: <639a720eb4ac2_1704975d65574139679@gitlab.mail> Ben Gamari pushed to branch wip/T22561 at Glasgow Haskell Compiler / GHC Commits: dcf30da8 by Joachim Breitner at 2022-04-09T13:02:19-04:00 Drop the app invariant previously, GHC had the "let/app-invariant" which said that the RHS of a let or the argument of an application must be of lifted type or ok for speculation. We want this on let to freely float them around, and we wanted that on app to freely convert between the two (e.g. in beta-reduction or inlining). However, the app invariant meant that simple code didn't stay simple and this got in the way of rules matching. By removing the app invariant, this thus fixes #20554. The new invariant is now called "let-can-float invariant", which is hopefully easier to guess its meaning correctly. Dropping the app invariant means that everywhere where we effectively do beta-reduction (in the two simplifiers, but also in `exprIsConApp_maybe` and other innocent looking places) we now have to check if the argument must be evaluated (unlifted and side-effecting), and analyses have to be adjusted to the new semantics of `App`. Also, `LetFloats` in the simplifier can now also carry such non-floating bindings. The fix for DmdAnal, refine by Sebastian, makes functions with unlifted arguments strict in these arguments, which changes some signatures. This causes some extra calls to `exprType` and `exprOkForSpeculation`, so some perf benchmarks regress a bit (while others improve). Metric Decrease: T9020 Metric Increase: LargeRecord T12545 T15164 T16577 T18223 T5642 T9961 Co-authored-by: Sebastian Graf <sebastian.graf at kit.edu> - - - - - 6c6c5379 by Philip Hazelden at 2022-04-09T13:02:59-04:00 Add functions traceWith, traceShowWith, traceEventWith. As discussed at https://github.com/haskell/core-libraries-committee/issues/36 - - - - - 8fafacf7 by Philip Hazelden at 2022-04-09T13:02:59-04:00 Add tests for several trace functions. - - - - - 20bbf3ac by Philip Hazelden at 2022-04-09T13:02:59-04:00 Update changelog. - - - - - 47d18b0b by Andreas Klebinger at 2022-04-09T13:03:35-04:00 Add regression test for #19569 - - - - - 5f8d6e65 by sheaf at 2022-04-09T13:04:14-04:00 Fix missing SymCo in pushCoercionIntoLambda There was a missing SymCo in pushCoercionIntoLambda. Currently this codepath is only used with rewrite rules, so this bug managed to slip by, but trying to use pushCoercionIntoLambda in other contexts revealed the bug. - - - - - 20eca489 by Vladislav Zavialov at 2022-04-09T13:04:50-04:00 Refactor: simplify lexing of the dot Before this patch, the lexer did a truly roundabout thing with the dot: 1. look up the varsym in reservedSymsFM and turn it into ITdot 2. under OverloadedRecordDot, turn it into ITvarsym 3. in varsym_(prefix|suffix|...) turn it into ITvarsym, ITdot, or ITproj, depending on extensions and whitespace Turns out, the last step is sufficient to handle the dot correctly. This patch removes the first two steps. - - - - - 5440f63e by Hécate Moonlight at 2022-04-12T11:11:06-04:00 Document that DuplicateRecordFields doesn't tolerates ambiguous fields Fix #19891 - - - - - 0090ad7b by Sebastian Graf at 2022-04-12T11:11:42-04:00 Eta reduction based on evaluation context (#21261) I completely rewrote our Notes surrounding eta-reduction. The new entry point is `Note [Eta reduction makes sense]`. Then I went on to extend the Simplifier to maintain an evaluation context in the form of a `SubDemand` inside a `SimplCont`. That `SubDemand` is useful for doing eta reduction according to `Note [Eta reduction based on evaluation context]`, which describes how Demand analysis, Simplifier and `tryEtaReduce` interact to facilitate eta reduction in more scenarios. Thus we fix #21261. ghc/alloc perf marginally improves (-0.0%). A medium-sized win is when compiling T3064 (-3%). It seems that haddock improves by 0.6% to 1.0%, too. Metric Decrease: T3064 - - - - - 4d2ee313 by Sebastian Graf at 2022-04-12T17:54:57+02:00 Specialising through specialised method calls (#19644) In #19644, we discovered that the ClassOp/DFun rules from Note [ClassOp/DFun selection] inhibit transitive specialisation in a scenario like ``` class C a where m :: Show b => a -> b -> ...; n :: ... instance C Int where m = ... -- $cm :: Show b => Int -> b -> ... f :: forall a b. (C a, Show b) => ... f $dC $dShow = ... m @a $dC @b $dShow ... main = ... f @Int @Bool ... ``` After we specialise `f` for `Int`, we'll see `m @a $dC @b $dShow` in the body of `$sf`. But before this patch, Specialise doesn't apply the ClassOp/DFun rule to rewrite to a call of the instance method for `C Int`, e.g., `$cm @Bool $dShow`. As a result, Specialise couldn't further specialise `$cm` for `Bool`. There's a better example in `Note [Specialisation modulo dictionary selectors]`. This patch enables proper Specialisation, as follows: 1. In the App case of `specExpr`, try to apply the CalssOp/DictSel rule on the head of the application 2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and `$dShow` in `bindAuxiliaryDict` NB: Without (2), (1) would be pointless, because `lookupRule` wouldn't be able to look into the RHS of `$dC` to see the DFun. (2) triggered #21332, because the Specialiser floats around dictionaries without accounting for them in the `SpecEnv`'s `InScopeSet`, triggering a panic when rewriting dictionary unfoldings. Fixes #19644 and #21332. - - - - - b06f4f47 by Sebastian Graf at 2022-04-12T17:54:58+02:00 Specialise: Check `typeDeterminesValue` before specialising on an interesting dictionary I extracted the checks from `Note [Type determines value]` into its own function, so that we share the logic properly. Then I made sure that we actually call `typeDeterminesValue` everywhere we check for `interestingDict`. - - - - - a42dbc55 by Matthew Pickering at 2022-04-13T06:24:52-04:00 Refine warning about defining rules in SAFE modules This change makes it clear that it's the definition rather than any usage which is a problem, and that rules defined in other modules will still be used to do rewrites. Fixes #20923 - - - - - df893f66 by Andreas Klebinger at 2022-04-14T08:18:37-04:00 StgLint: Lint constructor applications and strict workers for arity. This will mean T9208 when run with lint will return a lint error instead of resulting in a panic. Fixes #21117 - - - - - 426ec446 by sheaf at 2022-04-14T08:19:16-04:00 Hadrian: use a set to keep track of ways The order in which ways are provided doesn't matter, so we use a data structure with the appropriate semantics to represent ways. Fixes #21378 - - - - - 7c639b9a by Dylan Yudaken at 2022-04-15T13:55:59-04:00 Only enable PROF_SPIN in DEBUG - - - - - 96b9e5ea by Ben Gamari at 2022-04-15T13:56:34-04:00 testsuite: Add test for #21390 - - - - - d8392f6a by Ben Gamari at 2022-04-15T13:56:34-04:00 rts: Ensure that the interpreter doesn't disregard tags Previously the interpreter's handling of `RET_BCO` stack frames would throw away the tag of the returned closure. This resulted in #21390. - - - - - 83c67f76 by Alan Zimmerman at 2022-04-20T11:49:28-04:00 Add -dkeep-comments flag to keep comments in the parser This provides a way to set the Opt_KeepRawTokenStream from the command line, allowing exact print annotation users to see exactly what is produced for a given parsed file, when used in conjunction with -ddump-parsed-ast Discussed in #19706, but this commit does not close the issue. - - - - - a5ea65c9 by Krzysztof Gogolewski at 2022-04-20T11:50:04-04:00 Remove LevityInfo Every Id was storing a boolean whether it could be levity-polymorphic. This information is no longer needed since representation-checking has been moved to the typechecker. - - - - - 49bd7584 by Andreas Klebinger at 2022-04-20T11:50:39-04:00 Fix a shadowing issue in StgUnarise. For I assume performance reasons we don't record no-op replacements during unarise. This lead to problems with code like this: f = \(Eta_B0 :: VoidType) x1 x2 -> ... let foo = \(Eta_B0 :: LiftedType) -> g x y Eta_B0 in ... Here we would record the outer Eta_B0 as void rep, but would not shadow Eta_B0 inside `foo` because this arg is single-rep and so doesn't need to replaced. But this means when looking at occurence sites we would check the env and assume it's void rep based on the entry we made for the (no longer in scope) outer `Eta_B0`. Fixes #21396 and the ticket has a few more details. - - - - - 0c02c919 by Simon Peyton Jones at 2022-04-20T11:51:15-04:00 Fix substitution in bindAuxiliaryDict In GHC.Core.Opt.Specialise.bindAuxiliaryDict we were unnecessarily calling `extendInScope` to bring into scope variables that were /already/ in scope. Worse, GHC.Core.Subst.extendInScope strangely deleted the newly-in-scope variables from the substitution -- and that was fatal in #21391. I removed the redundant calls to extendInScope. More ambitiously, I changed GHC.Core.Subst.extendInScope (and cousins) to stop deleting variables from the substitution. I even changed the names of the function to extendSubstInScope (and cousins) and audited all the calls to check that deleting from the substitution was wrong. In fact there are very few such calls, and they are all about introducing a fresh non-in-scope variable. These are "OutIds"; it is utterly wrong to mess with the "InId" substitution. I have not added a Note, because I'm deleting wrong code, and it'd be distracting to document a bug. - - - - - 0481a6af by Cheng Shao at 2022-04-21T11:06:06+00:00 [ci skip] Drop outdated TODO in RtsAPI.c - - - - - 1e062a8a by Ben Gamari at 2022-04-22T02:12:59-04:00 rts: Introduce ip_STACK_FRAME While debugging it is very useful to be able to determine whether a given info table is a stack frame or not. We have spare bits in the closure flags array anyways, use one for this information. - - - - - 08a6a2ee by Ben Gamari at 2022-04-22T02:12:59-04:00 rts: Mark closureFlags array as const - - - - - 8f9b8282 by Krzysztof Gogolewski at 2022-04-22T02:13:35-04:00 Check for zero-bit types in sizeExpr Fixes #20940 Metric Decrease: T18698a - - - - - fcf22883 by Andreas Klebinger at 2022-04-22T02:14:10-04:00 Include the way string in the file name for dump files. This can be disabled by `-fno-dump-with-ways` if not desired. Finally we will be able to look at both profiled and non-profiled dumps when compiling with dump flags and we compile in both ways. - - - - - 252394ce by Bodigrim at 2022-04-22T02:14:48-04:00 Improve error messages from GHC.IO.Encoding.Failure - - - - - 250f57c1 by Bodigrim at 2022-04-22T02:14:48-04:00 Update test baselines to match new error messages from GHC.IO.Encoding.Failure - - - - - 5ac9b321 by Ben Gamari at 2022-04-22T02:15:25-04:00 get-win32-tarballs: Drop i686 architecture As of #18487 we no longer support 32-bit Windows. Fixes #21372. - - - - - dd5fecb0 by Ben Gamari at 2022-04-22T02:16:00-04:00 hadrian: Don't rely on xxx not being present in installation path Previously Hadrian's installation makefile would assume that the string `xxx` did not appear in the installation path. This would of course break for some users. Fixes #21402. - - - - - 09e98859 by Ben Gamari at 2022-04-22T02:16:35-04:00 testsuite: Ensure that GHC doesn't pick up environment files Here we set GHC_ENVIRONMENT="-" to ensure that GHC invocations of tests don't pick up a user's local package environment. Fixes #21365. Metric Decrease: T10421 T12234 T12425 T13035 T16875 T9198 - - - - - 76bb8cb3 by Ben Gamari at 2022-04-22T02:17:11-04:00 hadrian: Enable -dlint in devel2 flavour Previously only -dcore-lint was enabled. - - - - - f435d55f by Krzysztof Gogolewski at 2022-04-22T08:00:18-04:00 Fixes to rubbish literals * In CoreToStg, the application 'RUBBISH[rep] x' was simplified to 'RUBBISH[rep]'. But it is possible that the result of the function is represented differently than the function. * In Unarise, 'LitRubbish (primRepToType prep)' is incorrect: LitRubbish takes a RuntimeRep such as IntRep, while primRepToType returns a type such as Any @(TYPE IntRep). Use primRepToRuntimeRep instead. This code is never run in the testsuite. * In StgToByteCode, all rubbish literals were assumed to be boxed. This code predates representation-polymorphic RubbishLit and I think it was not updated. I don't have a testcase for any of those issues, but the code looks wrong. - - - - - 93c16b94 by sheaf at 2022-04-22T08:00:57-04:00 Relax "suppressing errors" assert in reportWanteds The assertion in reportWanteds that we aren't suppressing all the Wanted constraints was too strong: it might be the case that we are inside an implication, and have already reported an unsolved Wanted from outside the implication. It is possible that all Wanteds inside the implication have been rewritten by the outer Wanted, so we shouldn't throw an assertion failure in that case. Fixes #21405 - - - - - 78ec692d by Andreas Klebinger at 2022-04-22T08:01:33-04:00 Mention new MutableByteArray# wrapper in base changelog. - - - - - 56d7cb53 by Eric Lindblad at 2022-04-22T14:13:32-04:00 unlist announce - - - - - 1e4dcf23 by sheaf at 2022-04-22T14:14:12-04:00 decideMonoTyVars: account for CoVars in candidates The "candidates" passed to decideMonoTyVars can contain coercion holes. This is because we might well decide to quantify over some unsolved equality constraints, as long as they are not definitely insoluble. In that situation, decideMonoTyVars was passing a set of type variables that was not closed over kinds to closeWrtFunDeps, which was tripping up an assertion failure. Fixes #21404 - - - - - 2c541f99 by Simon Peyton Jones at 2022-04-22T14:14:47-04:00 Improve floated dicts in Specialise Second fix to #21391. It turned out that we missed calling bringFloatedDictsIntoScope when specialising imports, which led to the same bug as before. I refactored to move that call to a single place, in specCalls, so we can't forget it. This meant making `FloatedDictBinds` into its own type, pairing the dictionary bindings themselves with the set of their binders. Nicer this way. - - - - - 0950e2c4 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Ensure that --extra-lib-dirs are used Previously we only took `extraLibDirs` and friends from the package description, ignoring any contribution from the `LocalBuildInfo`. Fix this. Fixes #20566. - - - - - 53cc93ae by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Drop redundant include directories The package-specific include directories in Settings.Builders.Common.cIncludeDirs are now redundant since they now come from Cabal. Closes #20566. - - - - - b2721819 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Clean up handling of libffi dependencies - - - - - 18e5103f by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: More robust library way detection Previously `test.mk` would try to determine whether the dynamic, profiling, and vanilla library ways are available by searching for `PrimOpWrappers.{,dyn_,p_}hi` in directory reported by `ghc-pkg field ghc-prim library-dirs`. However, this is extremely fragile as there is no guarantee that there is only one library directory. To handle the case of multiple `library-dirs` correct we would have to carry out the delicate task of tokenising the directory list (in shell, no less). Since this isn't a task that I am eager to solve, I have rather moved the detection logic into the testsuite driver and instead perform a test compilation in each of the ways. This should be more robust than the previous approach. I stumbled upon this while fixing #20579. - - - - - 6c7a4913 by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: Cabalify ghc-config To ensure that the build benefits from Hadrian's usual logic for building packages, avoiding #21409. Closes #21409. - - - - - 9af091f7 by Ben Gamari at 2022-04-25T10:18:53-04:00 rts: Factor out built-in GC roots - - - - - e7c4719d by Ben Gamari at 2022-04-25T10:18:54-04:00 Ensure that wired-in exception closures aren't GC'd As described in Note [Wired-in exceptions are not CAFfy], a small set of built-in exception closures get special treatment in the code generator, being declared as non-CAFfy despite potentially containing CAF references. The original intent of this treatment for the RTS to then add StablePtrs for each of the closures, ensuring that they are not GC'd. However, this logic was not applied consistently and eventually removed entirely in 951c1fb0. This lead to #21141. Here we fix this bug by reintroducing the StablePtrs and document the status quo. Closes #21141. - - - - - 9587726f by Ben Gamari at 2022-04-25T10:18:54-04:00 testsuite: Add testcase for #21141 - - - - - cb71226f by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop dead code in GHC.Linker.Static.linkBinary' Previously we supported building statically-linked executables using libtool. However, this was dropped in 91262e75dd1d80f8f28a3922934ec7e59290e28c in favor of using ar/ranlib directly. Consequently we can drop this logic. Fixes #18826. - - - - - 9420d26b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop libtool path from settings file GHC no longers uses libtool for linking and therefore this is no longer necessary. - - - - - 41cf758b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop remaining vestiges of libtool Drop libtool logic from gen-dll, allowing us to drop the remaining logic from the `configure` script. Strangely, this appears to reliably reduce compiler allocations of T16875 on Windows. Closes #18826. Metric Decrease: T16875 - - - - - e09afbf2 by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - e76705cf by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Improve documentation of closure types Also drops the unused TREC_COMMITTED transaction state. - - - - - f2c08124 by Bodigrim at 2022-04-25T10:20:44-04:00 Document behaviour of RULES with KnownNat - - - - - 360dc2bc by Li-yao Xia at 2022-04-25T19:13:06+00:00 Fix rendering of liftA haddock - - - - - 16df6058 by Ben Gamari at 2022-04-27T10:02:25-04:00 testsuite: Report minimum and maximum stat changes As suggested in #20733. - - - - - e39cab62 by Fabian Thorand at 2022-04-27T10:03:03-04:00 Defer freeing of mega block groups Solves the quadratic worst case performance of freeing megablocks that was described in issue #19897. During GC runs, we now keep a secondary free list for megablocks that is neither sorted, nor coalesced. That way, free becomes an O(1) operation at the expense of not being able to reuse memory for larger allocations. At the end of a GC run, the secondary free list is sorted and then merged into the actual free list in a single pass. That way, our worst case performance is O(n log(n)) rather than O(n^2). We postulate that temporarily losing coalescense during a single GC run won't have any adverse effects in practice because: - We would need to release enough memory during the GC, and then after that (but within the same GC run) allocate a megablock group of more than one megablock. This seems unlikely, as large objects are not copied during GC, and so we shouldn't need such large allocations during a GC run. - Allocations of megablock groups of more than one megablock are rare. They only happen when a single heap object is large enough to require that amount of space. Any allocation areas that are supposed to hold more than one heap object cannot use megablock groups, because only the first megablock of a megablock group has valid `bdescr`s. Thus, heap object can only start in the first megablock of a group, not in later ones. - - - - - 5de6be0c by Fabian Thorand at 2022-04-27T10:03:03-04:00 Add note about inefficiency in returnMemoryToOS - - - - - 8bef471a by sheaf at 2022-04-27T10:03:43-04:00 Ensure that Any is Boxed in FFI imports/exports We should only accept the type `Any` in foreign import/export declarations when it has type `Type` or `UnliftedType`. This patch adds a kind check, and a special error message triggered by occurrences of `Any` in foreign import/export declarations at other kinds. Fixes #21305 - - - - - ba3d4e1c by Ben Gamari at 2022-04-27T10:04:19-04:00 Basic response file support Here we introduce support into our command-line parsing infrastructure and driver for handling gnu-style response file arguments, typically used to work around platform command-line length limitations. Fixes #16476. - - - - - 3b6061be by Ben Gamari at 2022-04-27T10:04:19-04:00 testsuite: Add test for #16476 - - - - - 75bf1337 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix cabal-reinstall job It's quite nice we can do this by mostly deleting code Fixes #21373 - - - - - 2c00d904 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add test to check that release jobs have profiled libs - - - - - 50d78d3b by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Explicitly handle failures in test_hadrian We also disable the stage1 testing which is broken. Related to #21072 - - - - - 2dcdf091 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix shell command - - - - - 55c84123 by Matthew Pickering at 2022-04-27T10:04:55-04:00 bootstrap: Add bootstrapping files for ghc-9_2_2 Fixes #21373 - - - - - c7ee0be6 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add linting job which checks authors are not GHC CI - - - - - 23aad124 by Adam Sandberg Ericsson at 2022-04-27T10:05:31-04:00 rts: state explicitly what evacuate and scavange mean in the copying gc - - - - - 318e0005 by Ben Gamari at 2022-04-27T10:06:07-04:00 rts/eventlog: Don't attempt to flush if there is no writer If the user has not configured a writer then there is nothing to flush. - - - - - ee11d043 by Ben Gamari at 2022-04-27T10:06:07-04:00 Enable eventlog support in all ways by default Here we deprecate the eventlogging RTS ways and instead enable eventlog support in the remaining ways. This simplifies packaging and reduces GHC compilation times (as we can eliminate two whole compilations of the RTS) while simplifying the end-user story. The trade-off is a small increase in binary sizes in the case that the user does not want eventlogging support, but we think that this is a fine trade-off. This also revealed a latent RTS bug: some files which included `Cmm.h` also assumed that it defined various macros which were in fact defined by `Config.h`, which `Cmm.h` did not include. Fixing this in turn revealed that `StgMiscClosures.cmm` failed to import various spinlock statistics counters, as evidenced by the failed unregisterised build. Closes #18948. - - - - - a2e5ab70 by Andreas Klebinger at 2022-04-27T10:06:43-04:00 Change `-dsuppress-ticks` to only suppress non-code ticks. This means cost centres and coverage ticks will still be present in output. Makes using -dsuppress-all more convenient when looking at profiled builds. - - - - - ec9d7e04 by Ben Gamari at 2022-04-27T10:07:21-04:00 Bump text submodule. This should fix #21352 - - - - - c3105be4 by Bodigrim at 2022-04-27T10:08:01-04:00 Documentation for setLocaleEncoding - - - - - 7f618fd3 by sheaf at 2022-04-27T10:08:40-04:00 Update docs for change to type-checking plugins There was no mention of the changes to type-checking plugins in the 9.4.1 notes, and the extending_ghc documentation contained a reference to an outdated type. - - - - - 4419dd3a by Adam Sandberg Ericsson at 2022-04-27T10:09:18-04:00 rts: add some more documentation to StgWeak closure type - - - - - 5a7f0dee by Matthew Pickering at 2022-04-27T10:09:54-04:00 Give Cmm files fake ModuleNames which include full filepath This fixes the initialisation functions when using -prof or -finfo-table-map. Fixes #21370 - - - - - 81cf52bb by sheaf at 2022-04-27T10:10:33-04:00 Mark GHC.Prim.PtrEq as Unsafe This module exports unsafe pointer equality operations, so we accordingly mark it as Unsafe. Fixes #21433 - - - - - f6a8185d by Ben Gamari at 2022-04-28T09:10:31+00:00 testsuite: Add performance test for #14766 This distills the essence of the Sigs.hs program found in the ticket. - - - - - c7a3dc29 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Add Monoid instance to Way - - - - - 654bafea by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Enrich flavours to build profiled/debugged/threaded ghcs per stage - - - - - 4ad559c8 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: add debug_ghc and debug_stage1_ghc flavour transformers - - - - - f9728fdb by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Don't pass -rtsopts when building libraries - - - - - 769279e6 by Matthew Pickering at 2022-04-28T18:54:44-04:00 testsuite: Fix calculation about whether to pass -dynamic to compiler - - - - - da8ae7f2 by Ben Gamari at 2022-04-28T18:55:20-04:00 hadrian: Clean up flavour transformer definitions Previously the `ipe` and `omit_pragmas` transformers were hackily defined using the textual key-value syntax. Fix this. - - - - - 61305184 by Ben Gamari at 2022-04-28T18:55:56-04:00 Bump process submodule - - - - - a8c99391 by sheaf at 2022-04-28T18:56:37-04:00 Fix unification of ConcreteTvs, removing IsRefl# This patch fixes the unification of concrete type variables. The subtlety was that unifying concrete metavariables is more subtle than other metavariables, as decomposition is possible. See the Note [Unifying concrete metavariables], which explains how we unify a concrete type variable with a type 'ty' by concretising 'ty', using the function 'GHC.Tc.Utils.Concrete.concretise'. This can be used to perform an eager syntactic check for concreteness, allowing us to remove the IsRefl# special predicate. Instead of emitting two constraints `rr ~# concrete_tv` and `IsRefl# rr concrete_tv`, we instead concretise 'rr'. If this succeeds we can fill 'concrete_tv', and otherwise we directly emit an error message to the typechecker environment instead of deferring. We still need the error message to be passed on (instead of directly thrown), as we might benefit from further unification in which case we will need to zonk the stored types. To achieve this, we change the 'wc_holes' field of 'WantedConstraints' to 'wc_errors', which stores general delayed errors. For the moement, a delayed error is either a hole, or a syntactic equality error. hasFixedRuntimeRep_MustBeRefl is now hasFixedRuntimeRep_syntactic, and hasFixedRuntimeRep has been refactored to directly return the most useful coercion for PHASE 2 of FixedRuntimeRep. This patch also adds a field ir_frr to the InferResult datatype, holding a value of type Maybe FRROrigin. When this value is not Nothing, this means that we must fill the ir_ref field with a type which has a fixed RuntimeRep. When it comes time to fill such an ExpType, we ensure that the type has a fixed RuntimeRep by performing a representation-polymorphism check with the given FRROrigin This is similar to what we already do to ensure we fill an Infer ExpType with a type of the correct TcLevel. This allows us to properly perform representation-polymorphism checks on 'Infer' 'ExpTypes'. The fillInferResult function had to be moved to GHC.Tc.Utils.Unify to avoid a cyclic import now that it calls hasFixedRuntimeRep. This patch also changes the code in matchExpectedFunTys to make use of the coercions, which is now possible thanks to the previous change. This implements PHASE 2 of FixedRuntimeRep in some situations. For example, the test cases T13105 and T17536b are now both accepted. Fixes #21239 and #21325 ------------------------- Metric Decrease: T18223 T5631 ------------------------- - - - - - 43bd897d by Simon Peyton Jones at 2022-04-28T18:57:13-04:00 Add INLINE pragmas for Enum helper methods As #21343 showed, we need to be super-certain that the "helper methods" for Enum instances are actually inlined or specialised. I also tripped over this when I discovered that numericEnumFromTo and friends had no pragmas at all, so their performance was very fragile. If they weren't inlined, all bets were off. So I've added INLINE pragmas for them too. See new Note [Inline Enum method helpers] in GHC.Enum. I also expanded Note [Checking for INLINE loop breakers] in GHC.Core.Lint to explain why an INLINE function might temporarily be a loop breaker -- this was the initial bug report in #21343. Strangely we get a 16% runtime allocation decrease in perf/should_run/T15185, but only on i386. Since it moves in the right direction I'm disinclined to investigate, so I'll accept it. Metric Decrease: T15185 - - - - - ca1434e3 by Ben Gamari at 2022-04-28T18:57:49-04:00 configure: Bump GHC version to 9.5 Bumps haddock submodule. - - - - - 292e3971 by Teo Camarasu at 2022-04-28T18:58:28-04:00 add since annotation for GHC.Stack.CCS.whereFrom - - - - - 905206d6 by Tamar Christina at 2022-04-28T22:19:34-04:00 winio: add support to iserv. - - - - - d182897e by Tamar Christina at 2022-04-28T22:19:34-04:00 Remove unused line - - - - - 22cf4698 by Matthew Pickering at 2022-04-28T22:20:10-04:00 Revert "rts: Refactor handling of dead threads' stacks" This reverts commit e09afbf2a998beea7783e3de5dce5dd3c6ff23db. - - - - - 8ed57135 by Matthew Pickering at 2022-04-29T04:11:29-04:00 Provide efficient unionMG function for combining two module graphs. This function is used by API clients (hls). This supercedes !6922 - - - - - 0235ff02 by Ben Gamari at 2022-04-29T04:12:05-04:00 Bump bytestring submodule Update to current `master`. - - - - - 01988418 by Matthew Pickering at 2022-04-29T04:12:05-04:00 testsuite: Normalise package versions in UnusedPackages test - - - - - 724d0dc0 by Matthew Pickering at 2022-04-29T08:59:42+00:00 testsuite: Deduplicate ways correctly This was leading to a bug where we would run a profasm test twice which led to invalid junit.xml which meant the test results database was not being populated for the fedora33-perf job. - - - - - 5630dde6 by Ben Gamari at 2022-04-29T13:06:20-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - 0cdef807 by parsonsmatt at 2022-04-30T16:51:12-04:00 Add a note about instance visibility across component boundaries In principle, the *visible* instances are * all instances defined in a prior top-level declaration group (see docs on `newDeclarationGroup`), or * all instances defined in any module transitively imported by the module being compiled However, actually searching all modules transitively below the one being compiled is unreasonably expensive, so `reifyInstances` will report only the instance for modules that GHC has had some cause to visit during this compilation. This is a shortcoming: `reifyInstances` might fail to report instances for a type that is otherwise unusued, or instances defined in a different component. You can work around this shortcoming by explicitly importing the modules whose instances you want to be visible. GHC issue #20529 has some discussion around this. Fixes #20529 - - - - - e2dd884a by Ryan Scott at 2022-04-30T16:51:47-04:00 Make mkFunCo take AnonArgFlags into account Previously, whenever `mkFunCo` would produce reflexive coercions, it would use `mkVisFunTy` to produce the kind of the coercion. However, `mkFunCo` is also used to produce coercions between types of the form `ty1 => ty2` in certain places. This has the unfortunate side effect of causing the type of the coercion to appear as `ty1 -> ty2` in certain error messages, as spotted in #21328. This patch address this by changing replacing the use of `mkVisFunTy` with `mkFunctionType` in `mkFunCo`. `mkFunctionType` checks the kind of `ty1` and makes the function arrow `=>` instead of `->` if `ty1` has kind `Constraint`, so this should always produce the correct `AnonArgFlag`. As a result, this patch fixes part (2) of #21328. This is not the only possible way to fix #21328, as the discussion on that issue lists some possible alternatives. Ultimately, it was concluded that the alternatives would be difficult to maintain, and since we already use `mkFunctionType` in `coercionLKind` and `coercionRKind`, using `mkFunctionType` in `mkFunCo` is consistent with this choice. Moreover, using `mkFunctionType` does not regress the performance of any test case we have in GHC's test suite. - - - - - 170da54f by Ben Gamari at 2022-04-30T16:52:27-04:00 Convert More Diagnostics (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors. - - - - - 39edc7b4 by Marius Ghita at 2022-04-30T16:53:06-04:00 Update user guide example rewrite rules formatting Change the rewrite rule examples to include a space between the composition of `f` and `g` in the map rewrite rule examples. Without this change, if the user has locally enabled the extension OverloadedRecordDot the copied example will result in a compile time error that `g` is not a field of `f`. ``` • Could not deduce (GHC.Records.HasField "g" (a -> b) (a1 -> b)) arising from selecting the field ‘g’ ``` - - - - - 2e951e48 by Adam Sandberg Ericsson at 2022-04-30T16:53:42-04:00 ghc-boot: export typesynonyms from GHC.Utils.Encoding This makes the Haddocks easier to understand. - - - - - d8cbc77e by Adam Sandberg Ericsson at 2022-04-30T16:54:18-04:00 users guide: add categories to some flags - - - - - d0f14fad by Chris Martin at 2022-04-30T16:54:57-04:00 hacking guide: mention the core libraries committee - - - - - 34b28200 by Matthew Pickering at 2022-04-30T16:55:32-04:00 Revert "Make the specialiser handle polymorphic specialisation" This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8. See ticket #21229 ------------------------- Metric Decrease: T15164 Metric Increase: T13056 ------------------------- - - - - - ee891c1e by Matthew Pickering at 2022-04-30T16:55:32-04:00 Add test for T21229 - - - - - ab677cc8 by Matthew Pickering at 2022-04-30T16:56:08-04:00 Hadrian: Update README about the flavour/testsuite contract There have been a number of tickets about non-tested flavours not passing the testsuite.. this is expected and now noted in the documentation. You use other flavours to run the testsuite at your own risk. Fixes #21418 - - - - - b57b5b92 by Ben Gamari at 2022-04-30T16:56:44-04:00 rts/m32: Fix assertion failure This fixes an assertion failure in the m32 allocator due to the imprecisely specified preconditions of `m32_allocator_push_filled_list`. Specifically, the caller must ensure that the page type is set to filled prior to calling `m32_allocator_push_filled_list`. While this issue did result in an assertion failure in the debug RTS, the issue is in fact benign. - - - - - a7053a6c by sheaf at 2022-04-30T16:57:23-04:00 Testsuite driver: don't crash on empty metrics The testsuite driver crashed when trying to display minimum/maximum performance changes when there are no metrics (i.e. there is no baseline available). This patch fixes that. - - - - - 636f7c62 by Andreas Klebinger at 2022-05-01T22:21:17-04:00 StgLint: Check that functions are applied to compatible runtime reps We use compatibleRep to compare reps, and avoid checking functions with levity polymorphic types because of #21399. - - - - - 60071076 by Hécate Moonlight at 2022-05-01T22:21:55-04:00 Add documentation to the ByteArray# primetype. close #21417 - - - - - 2b2e3020 by Andreas Klebinger at 2022-05-01T22:22:31-04:00 exprIsDeadEnd: Use isDeadEndAppSig to check if a function appliction is bottoming. We used to check the divergence and that the number of arguments > arity. But arity zero represents unknown arity so this was subtly broken for a long time! We would check if the saturated function diverges, and if we applied >=arity arguments. But for unknown arity functions any number of arguments is >=idArity. This fixes #21440. - - - - - 4eaf0f33 by Eric Lindblad at 2022-05-01T22:23:11-04:00 typos - - - - - fc58df90 by Niklas Hambüchen at 2022-05-02T08:59:27+00:00 libraries/base: docs: Explain relationshipt between `finalizeForeignPtr` and `*Conc*` creation Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/21420 - - - - - 3e400f20 by Krzysztof Gogolewski at 2022-05-02T18:29:23-04:00 Remove obsolete code in CoreToStg Note [Nullary unboxed tuple] was removed in e9e61f18a548b70693f4. This codepath is tested by T15696_3. - - - - - 4a780928 by Krzysztof Gogolewski at 2022-05-02T18:29:24-04:00 Fix several note references - - - - - 15ffe2b0 by Sebastian Graf at 2022-05-03T20:11:51+02:00 Assume at least one evaluation for nested SubDemands (#21081, #21133) See the new `Note [SubDemand denotes at least one evaluation]`. A demand `n :* sd` on a let binder `x=e` now means > "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is > evaluated deeply in sub-demand `sd`." The "any time it is evaluated" premise is what this patch adds. As a result, we get better nested strictness. For example (T21081) ```hs f :: (Bool, Bool) -> (Bool, Bool) f pr = (case pr of (a,b) -> a /= b, True) -- before: <MP(L,L)> -- after: <MP(SL,SL)> g :: Int -> (Bool, Bool) g x = let y = let z = odd x in (z,z) in f y ``` The change in demand signature "before" to "after" allows us to case-bind `z` here. Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`, albeit). We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand expansion. In an attempt to fix a regression caused by less inlining due to eta-reduction in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus fixing #21345 on the go. The main point of this patch is that it fixes #21081 and #21133. Annoyingly, I discovered that more precise demand signatures for join points can transform a program into a lazier program if that join point gets floated to the top-level, see #21392. There is no simple fix at the moment, but !5349 might. Thus, we accept a ~5% regression in `MultiLayerModulesTH_OneShot`, where #21392 bites us in `addListToUniqDSet`. T21392 reliably reproduces the issue. Surprisingly, ghc/alloc perf on Windows improves much more than on other jobs, by 0.4% in the geometric mean and by 2% in T16875. Metric Increase: MultiLayerModulesTH_OneShot Metric Decrease: T16875 - - - - - 948c7e40 by Andreas Klebinger at 2022-05-04T09:57:34-04:00 CoreLint - When checking for levity polymorphism look through more ticks. For expressions like `(scc<cc_name> primOp#) arg1` we should also look at arg1 to determine if we call primOp# at a fixed runtime rep. This is what corePrep already does but CoreLint didn't yet. This patch will bring them in sync in this regard. It also uses tickishFloatable in CorePrep instead of CorePrep having it's own slightly differing definition of when a tick is floatable. - - - - - 85bc73bd by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Support Unicode properly - - - - - 063d485e by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Replace LaTeX documentation syntax with Haddock The LaTeX documentation generator does not seem to have been used for quite some time, so the LaTeX-to-Haddock preprocessing step has become a pointless complication that makes documenting the contents of GHC.Prim needlessly difficult. This commit replaces the LaTeX syntax with the Haddock it would have been converted into, anyway, though with an additional distinction: it uses single quotes in places to instruct Haddock to generate hyperlinks to bindings. This improves the quality of the generated output. - - - - - d61f7428 by Ben Gamari at 2022-05-04T09:58:50-04:00 rts/ghc.mk: Only build StgCRunAsm.S when it is needed Previously the make build system unconditionally included StgCRunAsm.S in the link, meaning that the RTS would require an execstack unnecessarily. Fixes #21478. - - - - - 934a90dd by Simon Peyton Jones at 2022-05-04T16:15:34-04:00 Improve error reporting in generated code Our error reporting in generated code (via desugaring before typechecking) only worked when the generated code was just a simple call. This commit makes it work in nested cases. - - - - - 445d3657 by sheaf at 2022-05-04T16:16:12-04:00 Ensure Any is not levity-polymorphic in FFI The previous patch forgot to account for a type such as Any @(TYPE (BoxedRep l)) for a quantified levity variable l. - - - - - ddd2591c by Ben Gamari at 2022-05-04T16:16:48-04:00 Update supported LLVM versions Pull forward minimum version to match 9.2. (cherry picked from commit c26faa54c5fbe902ccb74e79d87e3fa705e270d1) - - - - - f9698d79 by Ben Gamari at 2022-05-04T16:16:48-04:00 testsuite/T7275: Use sed -r Darwin requires the `-r` flag to be compatible with GNU sed. (cherry picked from commit 512338c8feec96c38ef0cf799f3a01b77c967c56) - - - - - 8635323b by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Use ld.lld on ARMv7/Linux Due to #16177. Also cleanup some code style issues. (cherry picked from commit cc1c3861e2372f464bf9e3c9c4d4bd83f275a1a6) - - - - - 4f6370c7 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Always preserve artifacts, even in failed jobs (cherry picked from commit fd08b0c91ea3cab39184f1b1b1aafcd63ce6973f) - - - - - 6f662754 by Ben Gamari at 2022-05-04T16:16:48-04:00 configure: Make sphinx version check more robust It appears that the version of sphinx shipped on CentOS 7 reports a version string of `Sphinx v1...`. Accept the `v`. (cherry picked from commit a9197a292fd4b13308dc6664c01351c7239357ed) - - - - - 0032dc38 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Don't run make job in release pipelines (cherry picked from commit 16d6a8ff011f2194485387dcca1c00f8ddcdbdeb) - - - - - 27f9aab3 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab/ci: Fix name of bootstrap compiler directory Windows binary distributions built with Hadrian have a target platform suffix in the name of their root directory. Teach `ci.sh` about this fact. (cherry picked from commit df5752f39671f6d04d8cd743003469ae5eb67235) - - - - - b528f0f6 by Krzysztof Gogolewski at 2022-05-05T09:05:43-04:00 Fix several note references, part 2 - - - - - 691aacf6 by Adam Sandberg Ericsson at 2022-05-05T09:06:19-04:00 adjustors: align comment about number of integer like arguments with implementation for Amd4+MinGW implementation - - - - - f050557e by Simon Jakobi at 2022-05-05T12:47:32-04:00 Remove two uses of IntMap.size IntMap.size is O(n). The new code should be slightly more efficient. The transformation of GHC.CmmToAsm.CFG.calcFreqs.nodeCount can be described formally as the transformation: (\sum_{0}^{n-1} \sum_{0}^{k-1} i_nk) + n ==> (\sum_{0}^{n-1} 1 + \sum_{0}^{k-1} i_nk) - - - - - 7da90ae3 by Tom Ellis at 2022-05-05T12:48:09-04:00 Explain that 'fail s' should run in the monad itself - - - - - 610d0283 by Matthew Craven at 2022-05-05T12:48:47-04:00 Add a test for the bracketing in rules for (^) - - - - - 016f9ca6 by Matthew Craven at 2022-05-05T12:48:47-04:00 Fix broken rules for (^) with known small powers - - - - - 9372aaab by Matthew Craven at 2022-05-05T12:48:47-04:00 Give the two T19569 tests different names - - - - - 61901b32 by Andreas Klebinger at 2022-05-05T12:49:23-04:00 SpecConstr: Properly create rules for call patterns representing partial applications The main fix is that in addVoidWorkerArg we now add the argument to the front. This fixes #21448. ------------------------- Metric Decrease: T16875 ------------------------- - - - - - 71278dc7 by Teo Camarasu at 2022-05-05T12:50:03-04:00 add since annotations for instances of ByteArray - - - - - 962ff90b by sheaf at 2022-05-05T12:50:42-04:00 Start 9.6.1-notes Updates the documentation notes to start tracking changes for the 9.6.1 release (instead of 9.4). - - - - - aacb15a3 by Matthew Pickering at 2022-05-05T20:24:01-04:00 ci: Add job to check that jobs.yaml is up-to-date There have been quite a few situations where jobs.yaml has been out of date. It's better to add a CI job which checks that it's right. We don't want to use a staged pipeline because it obfuscates the structure of the pipeline. - - - - - be7102e5 by Ben Gamari at 2022-05-05T20:24:37-04:00 rts: Ensure that XMM registers are preserved on Win64 Previously we only preserved the bottom 64-bits of the callee-saved 128-bit XMM registers, in violation of the Win64 calling convention. Fix this. Fixes #21465. - - - - - 73b22ff1 by Ben Gamari at 2022-05-05T20:24:37-04:00 testsuite: Add test for #21465 - - - - - e2ae9518 by Ziyang Liu at 2022-05-06T19:22:22-04:00 Allow `let` just before pure/return in ApplicativeDo The following is currently rejected: ```haskell -- F is an Applicative but not a Monad x :: F (Int, Int) x = do a <- pure 0 let b = 1 pure (a, b) ``` This has bitten me multiple times. This MR contains a simple fix: only allow a "let only" segment to be merged with the next (and not the previous) segment. As a result, when the last one or more statements before pure/return are `LetStmt`s, there will be one more segment containing only those `LetStmt`s. Note that if the `let` statement mentions a name bound previously, then the program is still rejected, for example ```haskell x = do a <- pure 0 let b = a + 1 pure (a, b) ``` or the example in #18559. To support this would require a more complex approach, but this is IME much less common than the previous case. - - - - - 0415449a by Matthew Pickering at 2022-05-06T19:22:58-04:00 template-haskell: Fix representation of OPAQUE pragmas There is a mis-match between the TH representation of OPAQUE pragmas and GHC's internal representation due to how OPAQUE pragmas disallow phase annotations. It seemed most in keeping to just fix the wired in name issue by adding a special case to the desugaring of INLINE pragmas rather than making TH/GHC agree with how the representation should look. Fixes #21463 - - - - - 4de887e2 by Simon Peyton Jones at 2022-05-06T19:23:34-04:00 Comments only: Note [AppCtxt] - - - - - 6e69964d by Matthew Pickering at 2022-05-06T19:24:10-04:00 Fix name of windows release bindist in doc-tarball job - - - - - ced4689e by Matthew Pickering at 2022-05-06T19:24:46-04:00 ci: Generate source-tarball in release jobs We need to distribute the source tarball so we should generate it in the CI pipeline. - - - - - 3c91de21 by Rob at 2022-05-08T13:40:53+02:00 Change Specialise to use OrdList. Fixes #21362 Metric Decrease: T16875 - - - - - 67072c31 by Simon Jakobi at 2022-05-08T12:23:43-04:00 Tweak GHC.CmmToAsm.CFG.delEdge mapAdjust is more efficient than mapAlter. - - - - - 374554bb by Teo Camarasu at 2022-05-09T16:24:37-04:00 Respect -po when heap profiling (#21446) - - - - - 1ea414b6 by Teo Camarasu at 2022-05-09T16:24:37-04:00 add test case for #21446 - - - - - c7902078 by Jens Petersen at 2022-05-09T16:25:17-04:00 avoid hadrian/bindist/Makefile install_docs error when --docs=none When docs are disabled the bindist does not have docs/ and hence docs-utils/ is not generated. Here we just test that docs-utils exists before attempting to install prologue.txt and gen_contents_index to avoid the error: /usr/bin/install: cannot stat 'docs-utils/prologue.txt': No such file or directory make: *** [Makefile:195: install_docs] Error 1 - - - - - 158bd659 by Hécate Moonlight at 2022-05-09T16:25:56-04:00 Correct base's changelog for 4.16.1.0 This commit reaffects the new Ix instances of the foreign integral types from base 4.17 to 4.16.1.0 closes #21529 - - - - - a4fbb589 by Sylvain Henry at 2022-05-09T16:26:36-04:00 STG: only print cost-center if asked to - - - - - 50347ded by Gergo ERDI at 2022-05-10T11:43:33+00:00 Improve "Glomming" note Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order references, and thus needing to glom, is not a cause for concern when its root cause is rewrite rules. - - - - - df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00 update INSTALL - - - - - dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00 driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode It seems like it was just an oversight to use the incorrect DynFlags (global rather than local) when implementing these two options. Using the local flags allows users to request these intermediate files get cleaned up, which works fine in --make mode because 1. Interface files are stored in memory 2. Object files are only cleaned at the end of session (after link) Fixes #21349 - - - - - 35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00 configure: Check for ffi.h As noted in #21485, we checked for ffi.h yet then failed to throw an error if it is missing. Fixes #21485. - - - - - bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00 Check for uninferrable variables in tcInferPatSynDecl This fixes #21479 See Note [Unquantified tyvars in a pattern synonym] While doing this, I found that some error messages pointed at the pattern synonym /name/, rather than the /declaration/ so I widened the SrcSpan to encompass the declaration. - - - - - 142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00 hadrian: Fix split-sections transformer The splitSections transformer has been broken since -dynamic-too support was implemented in hadrian. This is because we actually build the dynamic way when building the dynamic way, so the predicate would always fail. The fix is to just always pass `split-sections` even if it doesn't do anything for a particular way. Fixes #21138 - - - - - 699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. Closes #21135 - - - - - 21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00 Use the wrapper for an unlifted binding We assumed the wrapper for an unlifted binding is the identity, but as #21516 showed, that is no always true. Solution is simple: use it. - - - - - 68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00 docs: Fix path to GHC API docs in index.html In the make bindists we generate documentation in docs/ghc-<VER> but the hadrian bindists generate docs/ghc/ so the path to the GHC API docs was wrong in the index.html file. Rather than make the hadrian and make bindists the same it was easier to assume that if you're using the mkDocs script that you're using hadrian bindists. Fixes #21509 - - - - - 9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00 hadrian: Don't pass -j to haddock This has high potential for oversubcribing as many haddock jobs can be spawned in parralel which will each request the given number of capabilities. Once -jsem is implemented (#19416, !5176) we can expose that haddock via haddock and use that to pass a semaphore. Ticket #21136 - - - - - fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00 hadrian: Only copy and install libffi headers when using in-tree libffi When passed `--use-system-libffi` then we shouldn't copy and install the headers from the system package. Instead the headers are expected to be available as a runtime dependency on the users system. Fixes #21485 #21487 - - - - - 5b791ed3 by mikael at 2022-05-11T08:22:13-04:00 FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10. - - - - - 8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00 Make floating-point abs IEEE 754 compliant The old code used by via-C backend didn't handle the sign bit of NaN. See #21043. - - - - - 4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00 EPA: do statement with leading semicolon has wrong anchor The code do; a <- doAsync; b Generated an incorrect Anchor for the statement list that starts after the first semicolon. This commit fixes it. Closes #20256 - - - - - e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00 Specialiser: saturate DFuns correctly Ticket #21489 showed that the saturation mechanism for DFuns (see Note Specialising DFuns) should use both UnspecType and UnspecArg. We weren't doing that; but this MR fixes that problem. No test case because it's hard to tickle, but it showed up in Gergo's work with GHC-as-a-library. - - - - - fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00 gitlab-ci: Check for dynamic msys2 dependencies Both #20878 and #21196 were caused by unwanted dynamic dependencies being introduced by boot libraries. Ensure that we catch this in CI by attempting to run GHC in an environment with a minimal PATH. - - - - - 3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00 Add back Debian9 CI jobs We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 not being at EOL until April 2023 and they still need tinfo5. Fixes #21469 - - - - - dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00 rts: Drop setExecutable Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been dead code. Drop it. - - - - - 32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00 Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat This missing guard gave rise to #21519. - - - - - 2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00 Add mention of -hi to RTS --help Fixes #21546 - - - - - a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00 Decouple dynflags in Cmm parser (related to #17957) - - - - - 3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00 Remove Module argument from initCmmParserConfig - - - - - 2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00 Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config - - - - - b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00 Decouple dynflags in GHC.Core.Opt.Arity (related to #17957) Metric Decrease: T16875 - - - - - 3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00 Update extending_ghc for TcPlugin changes The documentation still mentioned Derived constraints and an outdated datatype TcPluginResult. - - - - - 668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00 Fix printing of brackets in multiplicities (#20315) Change mulArrow to allow for printing of correct application precedence where necessary and update callers of mulArrow to reflect this. As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type. Fixes #20315 - - - - - 30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00 rts: Add debug output on ocResolve failure This makes it easier to see how resolution failures nest. - - - - - 53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00 rts/PEi386: Fix handling of weak symbols Previously we would flag the symbol as weak but failed to set its address, which must be computed from an "auxiliary" symbol entry the follows the weak symbol. Fixes #21556. - - - - - 5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00 testsuite: Add tests for #21556 - - - - - 49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00 Re-export augment and build from GHC.List Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127 - - - - - aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00 Comments only around HsWrapper - - - - - 27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00 hadrian: Introduce linting flavour transformer (+lint) The linting flavour enables -dlint uniformly across anything build by the stage1 compiler. -dcmm-lint is not currently enabled because it fails on i386 (see #21563) - - - - - 3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00 hadrian: Uniformly enable -dlint with enableLinting transformer This fixes some bugs where * -dcore-lint was being passed when building stage1 libraries with the boot compiler * -dcore-lint was not being passed when building executables. Fixes #20135 - - - - - 3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00 Make closure macros EXTERN_INLINE to make debugging easier Implements #21424. The RTS macros get_itbl and friends are extremely helpful during debugging. However only a select few of those were available in the compiled RTS as actual symbols as the rest were INLINE macros. This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites but allow us to use their compiled counterparts during debugging. This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell since `get_fun_itbl` will now be available as symbol! - - - - - 93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00 packaging: Introduce CI job for generating hackage documentation This adds a CI job (hackage-doc-tarball) which generates the necessary tarballs for uploading libraries and documentation to hackage. The release script knows to download this folder and the upload script will also upload the release to hackage as part of the release. The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs There are two modes, preparation and upload. * The `prepare` mode takes a link to a bindist and creates a folder containing the source and doc tarballs ready to upload to hackage. * The `upload` mode takes the folder created by prepare and performs the upload to hackage. Fixes #21493 Related to #21512 - - - - - 65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00 Add arity to the INLINE pragmas for pattern synonyms The lack of INLNE arity was exposed by #21531. The fix is simple enough, if a bit clumsy. - - - - - 43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00 Misc cleanup - Remove groupWithName (unused) - Use the RuntimeRepType synonym where possible - Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM No functional changes. - - - - - 8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00 TcPlugin: access to irreducible givens + fix passed ev_binds_var - - - - - fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00 driver: Introduce pgmcxx Here we introduce proper support for compilation of C++ objects. This includes: * logic in `configure` to detect the C++ toolchain and propagating this information into the `settings` file * logic in the driver to use the C++ toolchain when compiling C++ sources - - - - - 43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Build T20918 with HC, not CXX - - - - - 0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00 Introduce package to capture dependency on C++ stdlib Here we introduce a new "virtual" package into the initial package database, `system-cxx-std-lib`. This gives users a convenient, platform agnostic way to link against C++ libraries, addressing #20010. Fixes #20010. - - - - - 03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Add tests for system-cxx-std-lib package Test that we can successfully link against C++ code both in GHCi and batch compilation. See #20010 - - - - - 5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00 OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420) - - - - - eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00 Adjust flags for pprTrace We were using defaultSDocContext for pprTrace, which suppresses lots of useful infomation. This small MR adds GHC.Utils.Outputable.traceSDocContext and uses it for pprTrace and pprTraceUserWarning. traceSDocContext is a global, and hence not influenced by flags, but that seems unavoidable. But I made the sdocPprDebug bit controlled by unsafeHasPprDebug, since we have the latter for exactly this purpose. Fixes #21569 - - - - - d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00 Fix bad interaction between withDict and the Specialiser This MR fixes a bad bug, where the withDict was inlined too vigorously, which in turn made the type-class Specialiser generate a bogus specialisation, because it saw the same overloaded function applied to two /different/ dictionaries. Solution: inline `withDict` later. See (WD8) of Note [withDict] in GHC.HsToCore.Expr See #21575, which is fixed by this change. - - - - - 70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00 Bump time submodule to 1.12.2 This bumps the time submodule to the 1.12.2 release. Fixes #21571 - - - - - 2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00 Remove unused test files (#21582) Those files were moved to the perf/ subtree in 11c9a469, and then accidentally reintroduced in 680ef2c8. - - - - - cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00 CafAnal: Improve code clarity Here we implement a few measures to improve the clarity of the CAF analysis implementation. Specifically: * Use CafInfo instead of Bool since the former is more descriptive * Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact CAFs * Add numerous comments - - - - - b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00 codeGen: Ensure that static datacon apps are included in SRTs When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT filters out recursive references, as described in Note [recursive SRTs]. However, doing so for static functions would be unsound, for the reason described in Note [Invalid optimisation: shortcutting]. However, the same argument applies to static data constructor applications, as we discovered in #20959. Fix this by ensuring that static data constructor applications are included in recursive SRTs. The approach here is not entirely satisfactory, but it is a starting point. Fixes #20959. - - - - - 0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00 Add test for #21558 This is now fixed on master and 9.2 branch. Closes #21558 - - - - - ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00 Don't store LlvmConfig into DynFlags LlvmConfig contains information read from llvm-passes and llvm-targets files in GHC's top directory. Reading these files is done only when needed (i.e. when the LLVM backend is used) and cached for the whole compiler session. This patch changes the way this is done: - Split LlvmConfig into LlvmConfig and LlvmConfigCache - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no good reason to store it in DynFlags. As it is fixed per session, we store it in the session state instead (HscEnv). - Initializing LlvmConfigCache required some changes to driver functions such as newHscEnv. I've used the opportunity to untangle initHscEnv from initGhcMonad (in top-level GHC module) and to move it to GHC.Driver.Main, close to newHscEnv. - I've also made `cmmPipeline` independent of HscEnv in order to remove the call to newHscEnv in regalloc_unit_tests. - - - - - 828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00 Give all EXTERN_INLINE closure macros prototypes - - - - - cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Introduce [sg]etFinalizerExceptionHandler This introduces a global hook which is called when an exception is thrown during finalization. - - - - - 372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Throw exceptions raised while closing finalized Handles Fixes #21336. - - - - - 3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00 testsuite: Add tests for #21336 - - - - - 297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00 Add release flavour and use it for the release jobs The release flavour is essentially the same as the perf flavour currently but also enables `-haddock`. I have hopefully updated all the relevant places where the `-perf` flavour was hardcoded. Fixes #21486 - - - - - a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Don't build sphinx documentation on centos The centos docker image lacks the sphinx builder so we disable building sphinx docs for these jobs. Fixes #21580 - - - - - 209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Use correct syntax when args list is empty This seems to fail on the ancient version of bash present on CentOS - - - - - 02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00 hadrian: Don't attempt to build dynamic profiling libraries We only support building static profiling libraries, the transformer was requesting things like a dynamic, threaded, debug, profiling RTS, which we have never produced nor distributed. Fixes #21567 - - - - - 35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00 configure: Check CC_STAGE0 for --target support We previously only checked the stage 1/2 compiler for --target support. We got away with this for quite a while but it eventually caught up with us in #21579, where `bytestring`'s new NEON implementation was unbuildable on Darwin due to Rosetta's seemingly random logic for determining which executable image to execute. This lead to a confusing failure to build `bytestring`'s cbits, when `clang` tried to compile NEON builtins while targetting x86-64. Fix this by checking CC_STAGE0 for --target support. Fixes #21579. - - - - - 0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator analysis of `CmmGraph` This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper around two existing algorithms in GHC: the Lengauer-Tarjan dominator analysis from the X86 back end and the reverse postorder ordering from the Cmm Dataflow framework. Issue #20726 proposes that we evaluate some alternatives for dominator analysis, but for the time being, the best path forward is simply to use the existing analysis on `CmmGraph`s. This commit addresses a bullet in #21200. - - - - - 54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator-tree function - - - - - 05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add HasDebugCallStack; remove unneeded extensions - - - - - 0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00 document fields of `DominatorSet` - - - - - 8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00 nonmoving: Fix documentation of GC statistics fields These were previously incorrect. Fixes #21553. - - - - - c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00 Remove pprTrace from pushCoercionIntoLambda (#21555) This firstly caused spurious output to be emitted (as evidenced by #21555) but even worse caused a massive coercion to be attempted to be printed (> 200k terms) which would invariably eats up all the memory of your computer. The good news is that removing this trace allows the program to compile to completion, the bad news is that the program exhibits a core lint error (on 9.0.2) but not any other releases it seems. Fixes #21577 and #21555 - - - - - a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00 docs: Fix LlvmVersion in manpage (#21280) - - - - - 36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00 validate: Use $make rather than make In the validate script we are careful to use the $make variable as this stores whether we are using gmake, make, quiet mode etc. There was just this one place where we failed to use it. Fixes #21598 - - - - - 4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00 Change `Backend` type and remove direct dependencies With this change, `Backend` becomes an abstract type (there are no more exposed value constructors). Decisions that were formerly made by asking "is the current back end equal to (or different from) this named value constructor?" are now made by interrogating the back end about its properties, which are functions exported by `GHC.Driver.Backend`. There is a description of how to migrate code using `Backend` in the user guide. Clients using the GHC API can find a backdoor to access the Backend datatype in GHC.Driver.Backend.Internal. Bumps haddock submodule. Fixes #20927 - - - - - ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00 Respect DESTDIR in hadrian bindist Makefile, fixes #19646 - - - - - 7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00 Test DESTDIR in test_hadrian() - - - - - ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00 Consider the stage of typeable evidence when checking stage restriction We were considering all Typeable evidence to be "BuiltinInstance"s which meant the stage restriction was going unchecked. In-fact, typeable has evidence and so we need to apply the stage restriction. This is complicated by the fact we don't generate typeable evidence and the corresponding DFunIds until after typechecking is concluded so we introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which records whether the evidence is going to be local or not. Fixes #21547 - - - - - ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00 Modularize GHC.Core.Opt.LiberateCase Progress towards #17957 - - - - - bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00 Improve FloatOut and SpecConstr This patch addresses a relatively obscure situation that arose when chasing perf regressions in !7847, which itself is fixing It does two things: * SpecConstr can specialise on ($df d1 d2) dictionary arguments * FloatOut no longer checks argument strictness See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr. A test case is difficult to construct, but it makes a big difference in nofib/real/eff/VSM, at least when we have the patch for #21286 installed. (The latter stops worker/wrapper for dictionary arguments). There is a spectacular, but slightly illusory, improvement in runtime perf on T15426. I have documented the specifics in T15426 itself. Metric Decrease: T15426 - - - - - 1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00 Make debug a `Bool` not an `Int` in `StgToCmmConfig` We don't need any more resolution than this. Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer conveying any "level" information. - - - - - e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00 EPA : Remove duplicate comments in DataFamInstD The code data instance Method PGMigration = MigrationQuery Query -- ^ Run a query against the database | MigrationCode (Connection -> IO (Either String ())) -- ^ Run any arbitrary IO code Resulted in two instances of the "-- ^ Run a query against the database" comment appearing in the Exact Print Annotations when it was parsed. Ensure only one is kept. Closes #20239 - - - - - e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00 EPA: Comment Order Reversed Make sure comments captured in the exact print annotations are in order of increasing location Closes #20718 - - - - - 4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Add test for T21455 - - - - - e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Allow passing -po outside profiling way Resolves #21455 - - - - - 3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00 Fix haddock_*_perf tests on non-GNU-grep systems Using regexp pattern requires `egrep` and straight up `+`. The haddock_parser_perf and haddock_renamer_perf tests now pass on OpenBSD. They previously incorrectly parsed the files and awk complained about invalid syntax. - - - - - 1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00 hadrian/bindist: Drop redundant include of install.mk `install.mk` is already included by `config.mk`. Moreover, `install.mk` depends upon `config.mk` to set `RelocatableBuild`, making this first include incorrect. - - - - - f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00 Remove -z wxneeded for OpenBSD With all the recent W^X fixes in the loader this workaround is not necessary any longer. I verified that the only tests failing for me on OpenBSD 7.1-current are the same (libc++ related) before and after this commit (with --fast). - - - - - 7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00 Use UnionListsOrd instead of UnionLists in most places. This should get rid of most, if not all "Overlong lists" errors and fix #20016 - - - - - 81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00 Fix #21563 by using Word64 for 64bit shift code. We use the 64bit shifts only on 64bit platforms. But we compile the code always so compiling it on 32bit caused a lint error. So use Word64 instead. - - - - - 2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00 Fix compilation with -haddock on GHC <= 8.10 -haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors when it encounters invalid haddock syntax. This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b enabled -haddock by default on many flavours. Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem managed to slip throught the cracks. - - - - - cfb9faff by sheaf at 2022-05-24T22:15:12-04:00 Hadrian: don't add "lib" for relocatable builds The conditional in hadrian/bindist/Makefile depended on the target OS, but it makes more sense to use whether we are using a relocatable build. (Currently this only gets set to true on Windows, but this ensures that the logic stays correctly coupled.) - - - - - 9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00 Remove HscEnv from GHC.HsToCore.Usage (related to #17957) Metric Decrease: T16875 - - - - - 2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00 SimpleOpt: beta-reduce through casts The simple optimiser would sometimes fail to beta-reduce a lambda when there were casts in between the lambda and its arguments. This can cause problems because we rely on representation-polymorphic lambdas getting beta-reduced away (for example, those that arise from newtype constructors with representation-polymorphic arguments, with UnliftedNewtypes). - - - - - e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00 Desugar RecordUpd in `tcExpr` This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule - - - - - 2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00 update README - - - - - 3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00 Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602) - - - - - ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00 Add Haddocks for `WwOpts` - - - - - da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00 Avoid global compiler state for `GHC.Core.Opt.WorkWrap` Progress towards #17957 - - - - - 3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00 Optimiser: avoid introducing bad rep-poly The functions `pushCoValArg` and `pushCoercionIntoLambda` could introduce bad representation-polymorphism. Example: type RR :: RuntimeRep type family RR where { RR = IntRep } type F :: TYPE RR type family F where { F = Int# } co = GRefl F (TYPE RR[0]) :: (F :: TYPE RR) ~# (F |> TYPE RR[0] :: TYPE IntRep) f :: F -> () `pushCoValArg` would transform the unproblematic application (f |> (co -> <()>)) (arg :: F |> TYPE RR[0]) into an application in which the argument does not have a fixed `RuntimeRep`: f ((arg |> sym co) :: (F :: TYPE RR)) - - - - - b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00 executablePath test: fix file extension treatment The executablePath test strips the file extension (if any) when comparing the query result with the expected value. This is to handle platforms where GHC adds a file extension to the output program file (e.g. .exe on Windows). After the initial check, the file gets deleted (if supported). However, it tries to delete the *stripped* filename, which is incorrect. The test currently passes only because Windows does not allow deleting the program while any process created from it is alive. Make the test program correct in general by deleting the *non-stripped* executable filename. - - - - - afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00 fix executablePath test for NetBSD executablePath support for NetBSD was added in a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not updated. Update the test so that it works for NetBSD. This requires handling some quirks: - The result of getExecutablePath could include "./" segments. Therefore use System.FilePath.equalFilePath to compare paths. - The sysctl(2) call returns the original executable name even after it was deleted. Add `canQueryAfterDelete :: [FilePath]` and adjust expectations for the post-delete query accordingly. Also add a note to the `executablePath` haddock to advise that NetBSD behaves differently from other OSes when the file has been deleted. Also accept a decrease in memory usage for T16875. On Windows, the metric is -2.2% of baseline, just outside the allowed ±2%. I don't see how this commit could have influenced this metric, so I suppose it's something in the CI environment. Metric Decrease: T16875 - - - - - d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00 Factor out `initArityOps` to `GHC.Driver.Config.*` module We want `DynFlags` only mentioned in `GHC.Driver`. - - - - - 44bb7111 by romes at 2022-05-26T16:27:57+00:00 TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs - - - - - 88e58600 by sheaf at 2022-05-26T17:38:43-04:00 Add tests for eta-expansion of data constructors This patch adds several tests relating to the eta-expansion of data constructors, including UnliftedNewtypes and DataTypeContexts. - - - - - d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00 Generalize breakTyVarCycle to work with TyFamLHS The function breakTyVarCycle_maybe has been installed in a dark corner of GHC to catch some gremlins (a.k.a. occurs-check failures) who lurk there. But it previously only caught gremlins of the form (a ~ ... F a ...), where some of our intrepid users have spawned gremlins of the form (G a ~ ... F (G a) ...). This commit improves breakTyVarCycle_maybe (and renames it to breakTyEqCycle_maybe) to catch the new gremlins. Happily, the change is remarkably small. The gory details are in Note [Type equality cycles]. Test cases: typecheck/should_compile/{T21515,T21473}. - - - - - ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00 [base] Fix the links in the Data.Data module fix #21658 fix #21657 fix #21657 - - - - - 3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00 Use a class to check validity of withDict This moves handling of the magic 'withDict' function from the desugarer to the typechecker. Details in Note [withDict]. I've extracted a part of T16646Fail to a separate file T16646Fail2, because the new error in 'reify' hides the errors from 'f' and 'g'. WithDict now works with casts, this fixes #21328. Part of #19915 - - - - - b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00 Fix FreeVars computation for mdo Commit acb188e0 introduced a regression in the computation of free variables in mdo statements, as the logic in GHC.Rename.Expr.segmentRecStmts was slightly different depending on whether the recursive do block corresponded to an mdo statement or a rec statment. This patch restores the previous computation for mdo blocks. Fixes #21654 - - - - - 0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00 T16875: Stabilise (temporarily) by increasing acceptance threshold The theory is that on windows there is some difference in the environment between pipelines on master and merge requests which affects all tests equally but because T16875 barely allocates anything it is the test which is affected the most. See #21557 - - - - - 6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00 make: Fix make maintainer-clean deleting a file tracked by source control Fixes #21659 - - - - - fbf2f254 by Bodigrim at 2022-05-28T21:01:58-04:00 Expand documentation of hIsTerminalDevice - - - - - 0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00 export IsList from GHC.IsList it is still re-exported from GHC.Exts - - - - - 91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00 MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR ARM64_RELOC_SUBTRACTOR relocations are paired with an AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2 The linker was doing it in two steps, basically: *addend <- *addend - sym2 *addend <- *addend + sym1 The first operation was likely to overflow. For example when the relocation target was 32-bit and both sym1/sym2 were 64-bit addresses. With the small memory model, (sym1-sym2) would fit in 32 bits but (*addend-sym2) may not. Now the linker does it in one step: *addend <- *addend + sym1 - sym2 - - - - - acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Some fixes to SRT documentation - reordered the 3 SRT implementation cases from the most general to the most specific one: USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD - added requirements for each - found and documented a confusion about "SRT inlining" not supported with MachO. (It is fixed in the following commit) - - - - - 5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Enable USE_INLINE_SRT_FIELD on ARM64 It was previously disabled because of: - a confusion about "SRT inlining" (see removed comment in this commit) - a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR relocation: fixed by a previous commit. - - - - - 59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00 ci: Make sure to exit promptly if `make install` fails. Due to the vageries of bash, you have to explicitly handle the failure and exit when in a function. This failed to exit promptly when !8247 was failing. See #21358 for the general issue - - - - - 5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00 Split GHC.HsToCore.Foreign.Decl This is preliminary work for JavaScript support. It's better to put the code handling the desugaring of Prim, C and JavaScript declarations into separate modules. - - - - - 6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00 Bump hadrian to LTS-19.8 (GHC 9.0.2) - - - - - f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00 Hadrian: remove unused code - - - - - 2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Eta reduction with casted function We want to be able to eta-reduce \x y. ((f x) |> co) y by pushing 'co' inwards. A very small change accommodates this See Note [Eta reduction with casted function] - - - - - f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Do arity trimming at bindings, rather than in exprArity Sometimes there are very large casts, and coercionRKind can be slow. - - - - - 610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make findRhsArity take RecFlag This avoids a fixpoint iteration for the common case of non-recursive bindings. - - - - - 80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Comments and white space - - - - - 0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make PrimOpId record levity This patch concerns #20155, part (1) The general idea is that since primops have curried bindings (currently in PrimOpWrappers.hs) we don't need to eta-expand them. But we /do/ need to eta-expand the levity-polymorphic ones, because they /don't/ have bindings. This patch makes a start in that direction, by identifying the levity-polymophic primops in the PrimOpId IdDetails constructor. For the moment, I'm still eta-expanding all primops (by saying that hasNoBinding returns True for all primops), because of the bug reported in #20155. But I hope that before long we can tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding. - - - - - 6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: * Move state-hack stuff from GHC.Types.Id (where it never belonged) to GHC.Core.Opt.Arity (which seems much more appropriate). * Add a crucial mkCast in the Cast case of GHC.Core.Opt.Arity.eta_expand; helps with T18223 * Add clarifying notes about eta-reducing to PAPs. See Note [Do not eta reduce PAPs] * I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity, where it properly belongs. See Note [Eta reduce PAPs] * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for when eta-expansion is wanted, to make wantEtaExpansion, and all that same function in GHC.Core.Opt.Simplify.simplStableUnfolding. It was previously inconsistent, but it's doing the same thing. * I did a substantial refactor of ArityType; see Note [ArityType]. This allowed me to do away with the somewhat mysterious takeOneShots; more generally it allows arityType to describe the function, leaving its clients to decide how to use that information. I made ArityType abstract, so that clients have to use functions to access it. * Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called mkLam before) aware of the floats that the simplifier builds up, so that it can still do eta-reduction even if there are some floats. (Previously that would not happen.) That means passing the floats to rebuildLam, and an extra check when eta-reducting (etaFloatOk). * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info in the idDemandInfo of the binder, as well as the CallArity info. The occurrence analyser did this but we were failing to take advantage here. In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity; see Note [Combining arityType with demand info], and functions idDemandOneShots and combineWithDemandOneShots. (These changes partly drove my refactoring of ArityType.) * In GHC.Core.Opt.Arity.findRhsArity * I'm now taking account of the demand on the binder to give extra one-shot info. E.g. if the fn is always called with two args, we can give better one-shot info on the binders than if we just look at the RHS. * Don't do any fixpointing in the non-recursive case -- simple short cut. * Trim arity inside the loop. See Note [Trim arity inside the loop] * Make SimpleOpt respect the eta-reduction flag (Some associated refactoring here.) * I made the CallCtxt which the Simplifier uses distinguish between recursive and non-recursive right-hand sides. data CallCtxt = ... | RhsCtxt RecFlag | ... It affects only one thing: - We call an RHS context interesting only if it is non-recursive see Note [RHS of lets] in GHC.Core.Unfold * Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification. See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep. Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. * Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg Metrics: compile_time/bytes allocated Test Metric Baseline New value Change --------------------------------------------------------------------------------------- MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,743,297,692 2,619,762,992 -4.5% GOOD T18223(normal) ghc/alloc 1,103,161,360 972,415,992 -11.9% GOOD T3064(normal) ghc/alloc 201,222,500 184,085,360 -8.5% GOOD T8095(normal) ghc/alloc 3,216,292,528 3,254,416,960 +1.2% T9630(normal) ghc/alloc 1,514,131,032 1,557,719,312 +2.9% BAD parsing001(normal) ghc/alloc 530,409,812 525,077,696 -1.0% geo. mean -0.1% Nofib: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- banner +0.0% +0.4% -8.9% -8.7% 0.0% exact-reals +0.0% -7.4% -36.3% -37.4% 0.0% fannkuch-redux +0.0% -0.1% -1.0% -1.0% 0.0% fft2 -0.1% -0.2% -17.8% -19.2% 0.0% fluid +0.0% -1.3% -2.1% -2.1% 0.0% gg -0.0% +2.2% -0.2% -0.1% 0.0% spectral-norm +0.1% -0.2% 0.0% 0.0% 0.0% tak +0.0% -0.3% -9.8% -9.8% 0.0% x2n1 +0.0% -0.2% -3.2% -3.2% 0.0% -------------------------------------------------------------------------------- Min -3.5% -7.4% -58.7% -59.9% 0.0% Max +0.1% +2.2% +32.9% +32.9% 0.0% Geometric Mean -0.0% -0.1% -14.2% -14.8% -0.0% Metric Decrease: MultiLayerModulesTH_OneShot T18223 T3064 T15185 T14766 Metric Increase: T9630 - - - - - cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00 hadrian: Fix building from source-dist without alex/happy This fixes two bugs which were adding dependencies on alex/happy when building from a source dist. * When we try to pass `--with-alex` and `--with-happy` to cabal when configuring but the builders are not set. This is fixed by making them optional. * When we configure, cabal requires alex/happy because of the build-tool-depends fields. These are now made optional with a cabal flag (build-tool-depends) for compiler/hpc-bin/genprimopcode. Fixes #21627 - - - - - a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test the bootstrap without ALEX/HAPPY on path - - - - - 0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test bootstrapping in release jobs - - - - - d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label - - - - - 18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00 rts: Remove explicit timescale for deprecating -h flag We originally planned to remove the flag in 9.4 but there's actually no great rush to do so and it's probably less confusing (forever) to keep the message around suggesting an explicit profiling option. Fixes #21545 - - - - - eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00 Enable -dlint in hadrian lint transformer Now #21563 is fixed we can properly enable `-dlint` in CI rather than a subset of the flags. - - - - - 0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00 upload-ghc-libs: Allow candidate-only upload - - - - - 83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00 Avoid using DynFlags in GHC.Linker.Unit (#17957) - - - - - 5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00 hadrian: Introduce new package database for executables needed to build stage0 These executables (such as hsc2hs) are built using the boot compiler and crucially, most libraries from the global package database. We also move other build-time executables to be built in this stage such as linters which also cleans up which libraries end up in the global package database. This allows us to remove hacks where linters-common is removed from the package database when a bindist is created. This fixes issues caused by infinite recursion due to bytestring adding a dependency on template-haskell. Fixes #21634 - - - - - 0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00 Build stage1 with -V as well This helps tracing errors which happen when building stage1 - - - - - 15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00 Revert "packaging: Build perf builds with -split-sections" This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f. Split sections causes segfaults in profiling way with old toolchains (deb9) and on windows (#21670) Fixes #21670 - - - - - d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00 Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard Progress towards #17957 Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other modules as thoroughly as I usually do. This does mean that risk of `DynFlags` "creeping back in" is higher than it usually is. After we do the same process to the other Core passes, and then figure out what we want to do about `CoreM`, we can finish the job started here. That is a good deal more work, however, so it certainly makes sense to land this now. - - - - - a720322f by romes at 2022-06-01T07:44:44-04:00 Restore Note [Quasi-quote overview] - - - - - 392ce3fc by romes at 2022-06-01T07:44:44-04:00 Move UntypedSpliceFlavour from L.H.S to GHC.Hs UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr` but was defined in the client-independent L.H.S.Expr. - - - - - 7975202b by romes at 2022-06-01T07:44:44-04:00 TTG: Rework and improve splices This commit redefines the structure of Splices in the AST. We get rid of `HsSplice` which used to represent typed and untyped splices, quasi quotes, and the result of splicing either an expression, a type or a pattern. Instead we have `HsUntypedSplice` which models an untyped splice or a quasi quoter, which works in practice just like untyped splices. The `HsExpr` constructor `HsSpliceE` which used to be constructed with an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The former is directly constructed with an `HsExpr` and the latter now takes an `HsUntypedSplice`. Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now take an `HsUntypedSplice` instead of a `HsSplice` (remember only /untyped splices/ can be spliced as types or patterns). The result of splicing an expression, type, or pattern is now comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`, `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult (HsExpr GhcRn)` Overall the TTG extension points are now better used to make invalid states unrepresentable and model the progression between stages better. See Note [Lifecycle of an untyped splice, and PendingRnSplice] and Note [Lifecycle of an typed splice, and PendingTcSplice] for more details. Updates haddock submodule Fixes #21263 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - 320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00 Add test for #21619 Fixes #21619 - - - - - ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00 Pure Haskell implementation of GHC.Unicode Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/). Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691. - Remove current Unicode cbits. - Add generator for Unicode property files from Unicode Character Database. - Generate internal modules. - Update GHC.Unicode. - Add unicode003 test for general categories and case mappings. - Add Python scripts to check 'base' Unicode tests outputs and characters properties. Fixes #21375 ------------------------- Metric Decrease: T16875 Metric Increase: T4029 T18304 haddock.base ------------------------- - - - - - 514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00 typos - - - - - 9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00 source-dist: Copy in files created by ./boot Since we started producing source dists with hadrian we stopped copying in the files created by ./boot which adds a dependency on python3 and autoreconf. This adds back in the files which were created by running configure. Fixes #21673 #21672 and #21626 - - - - - a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00 ci: Don't try to run ./boot when testing bootstrap of source dist - - - - - e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00 Language.Haskell.Syntax: Fix docs for PromotedConsT etc. Fixes ghc/ghc#21675. - - - - - 87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump bytestring, process, and text submodules Metric Decrease: T5631 Metric Increase: T18223 (cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af) - - - - - 24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump Cabal submodule To current `master`. (cherry picked from commit fbb59c212415188486aafd970eafef170516356a) - - - - - 5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00 hadrian/tool-args: Write output to intermediate file rather than via stdout This allows us to see the output of hadrian while it is doing the setup. - - - - - 468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00 Make -fcompact-unwind the default This is a follow-up to !7247 (closed) making the inclusion of compact unwinding sections the default. Also a slight refactoring/simplification of the flag handling to add -fno-compact-unwind. - - - - - 819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00 hadrian bootstrap: add plans for 9.0.2 and 9.2.3 - - - - - 9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00 ci: Add matrix for bootstrap sources - - - - - ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00 HsToCore.Coverage: Improve haddocks - - - - - f065804e by John Ericson at 2022-06-02T15:42:59+00:00 Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller No need to inline traversing a maybe for `mkModBreaks`. And better to make each function do one thing and let the caller deside when than scatter the decision making and make the caller seem more imperative. - - - - - d550d907 by John Ericson at 2022-06-02T15:42:59+00:00 Rename `HsToCore.{Coverage -> Ticks}` The old name made it confusing why disabling HPC didn't disable the entire pass. The name makes it clear --- there are other reasons to add ticks in addition. - - - - - 6520da95 by John Ericson at 2022-06-02T15:42:59+00:00 Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq` As proposed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676, `GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and backend-specific (only for the bytecode interpreter), and mix entry writing is just for HPC. With this split we separate out those interpreter- and HPC-specific its, and keep the main `GHC.HsToCore.Ticks` agnostic. Also, instead of passing the reversed list and count around, we use `SizedSeq` which abstracts over the algorithm. This is much nicer to avoid noise and prevents bugs. (The bugs are not just hypothetical! I missed up the reverses on an earlier draft of this commit.) - - - - - 1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00 GHC.HsToCore.Breakpoints: Slightly improve perf We have the length already, so we might as well use that rather than O(n) recomputing it. - - - - - 5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00 HsToCore.Coverage: Purge DynFlags Finishes what !7467 (closed) started. Progress towards #17957 - - - - - 9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00 Deprecate TypeInType extension This commit fixes #20312 It deprecates "TypeInType" extension according to the following proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst It has been already implemented. The migration strategy: 1. Disable TypeInType 2. Enable both DataKinds and PolyKinds extensions Metric Decrease: T16875 - - - - - f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00 Diagnostics conversions, part 6 (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and `GHC.Tc.Gen.Sig`. - - - - - 04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00 Ensure floated dictionaries are in scope (again) In the Specialiser, we missed one more call to bringFloatedDictsIntoScope (see #21391). This omission led to #21689. The problem is that the call to `rewriteClassOps` needs to have in scope any dictionaries floated out of the arguments we have just specialised. Easy fix. - - - - - a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00 Don't print the number of deps in count-deps tests It is redundant information and a source of needless version control conflicts when multiple MRs are changing the deps list. Just printing the list and not also its length is fine. - - - - - a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00 Core.Lint: Reduce `DynFlags` and `HscEnv` Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com> - - - - - 56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00 Fix a CSE shadowing bug. We used to process the rhs of non-recursive bindings and their body using the same env. If we had something like let x = ... x ... this caused trouble because the two xs refer to different binders but we would substitute both for a new binder x2 causing out of scope errors. We now simply use two different envs for the rhs and body in cse_bind. It's all explained in the Note [Separate envs for let rhs and body] Fixes #21685 - - - - - 28880828 by sheaf at 2022-06-09T09:12:19-04:00 Typecheck remaining ValArgs in rebuildHsApps This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it to tcRemainingValArgs. The logic is moved to rebuildHsApps, which ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg. This patch also refactors the treatment of stupid theta for data constructors, changing the place we drop stupid theta arguments from dsConLike to mkDataConRep (now the datacon wrapper drops these arguments). We decided not to implement PHASE 2 of the FixedRuntimeRep plan for these remaining ValArgs. Future directions are outlined on the wiki: https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs Fixes #21544 and #21650 - - - - - 1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00 Add test for T21682 Fixes #21682 - - - - - 8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00 Document dataToTag# primop - - - - - 7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00 Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115 - - - - - 46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00 Fix TcRnPragmaWarning meaning - - - - - 69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00 getProcessCPUTime: Fix the getrusage fallback to account for system CPU time clock_gettime reports the combined total or user AND system time so in order to replicate it with getrusage we need to add both system and user time together. See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime Some sample measurements when building Cabal with this patch t1: rusage t2: clock_gettime t1: 62347518000; t2: 62347520873 t1: 62395687000; t2: 62395690171 t1: 62432435000; t2: 62432437313 t1: 62478489000; t2: 62478492465 t1: 62514990000; t2: 62514992534 t1: 62515479000; t2: 62515480327 t1: 62515485000; t2: 62515486344 Fixes #21656 - - - - - 722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00 Use <br> instead of newline character - - - - - dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00 Use (fixed_lev = True) in mkDataTyConRhs - - - - - ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00 hadrian: Fix testing stage1 compiler There were various issues with testing the stage1 compiler.. 1. The wrapper was not being built 2. The wrapper was picking up the stage0 package database and trying to load prelude from that. 3. The wrappers never worked on windows so just don't support that for now. Fixes #21072 - - - - - ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00 validate: Ensure that $make variable is set Currently the `$make` variable is used without being set in `validate`'s Hadrian path, which uses make to install the binary distribution. Fix this. Fixes #21687. - - - - - 59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00 CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv` The call sites in `Driver.Main` are duplicative, but this is good, because the next step is to remove `InteractiveContext` from `Core.Lint` into `Core.Lint.Interactive`. Also further clean up `Core.Lint` to use a better configuration record than the one we initially added. - - - - - aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00 hadrian: Run xattr -rc . on bindist tarball Fixes #21506. - - - - - cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00 configure: Hide spurious warning from ld Previously the check_for_gold_t22266 configure check could result in spurious warnings coming from the linker being blurted to stderr. Suppress these by piping stderr to /dev/null. - - - - - e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00 cmm: Add surface syntax for MO_MulMayOflo - - - - - bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00 configure: Don't attempt to override linker on Darwin Configure's --enable-ld-override functionality is intended to ensure that we don't rely on ld.bfd, which tends to be slow and buggy, on Linux and Windows. However, on Darwin the lack of sensible package management makes it extremely easy for users to have awkward mixtures of toolchain components from, e.g., XCode, the Apple Command-Line Tools package, and homebrew. This leads to extremely confusing problems like #21712. Here we avoid this by simply giving up on linker selection on Darwin altogether. This isn't so bad since the Apple ld64 linker has decent performance and AFAICT fairly reliable. Closes #21712. - - - - - 25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00 replace quadratic nub to fight byte code gen perf explosion Despite this code having been present in the core-to-bytecode implementation, I have observed it in the wild starting with 9.2, causing enormous slowdown in certain situations. My test case produces the following profiles: Before: ``` total time = 559.77 secs (559766 ticks @ 1000 us, 1 processor) total alloc = 513,985,665,640 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes elem_by Data.OldList libraries/base/Data/OldList.hs:429:1-7 67.6 92.9 378282 477447404296 eqInt GHC.Classes libraries/ghc-prim/GHC/Classes.hs:275:8-14 12.4 0.0 69333 32 $c>>= GHC.Data.IOEnv <no location info> 6.9 0.6 38475 3020371232 ``` After: ``` total time = 89.83 secs (89833 ticks @ 1000 us, 1 processor) total alloc = 39,365,306,360 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes $c>>= GHC.Data.IOEnv <no location info> 43.6 7.7 39156 3020403424 doCase GHC.StgToByteCode compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53) 2.5 7.4 2246 2920777088 ``` - - - - - aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00 hadrian: Don't install `include/` directory in bindist. The install_includes for the RTS package used to be put in the top-level ./include folder but this would lead to confusing things happening if you installed multiple GHC versions side-by-side. We don't need this folder anymore because install-includes is honoured properly by cabal and the relevant header files already copied in by the cabal installation process. If you want to depend on the header files for the RTS in a Haskell project then you just have to depend on the `rts` package and the correct include directories will be provided for you. If you want to depend on the header files in a standard C project then you should query ghc-pkg to get the right paths. ``` ghc-pkg field rts include-dirs --simple-output ``` Fixes #21609 - - - - - 03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00 Enable eventlogs on nightly perf job - - - - - ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00 Repair dead link in TH haddocks Closes #21724 - - - - - 99ff3818 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian: allow configuring Hsc2Hs This patch adds the ability to pass options to Hsc2Hs as Hadrian key/value settings, in the same way as cabal configure options, using the syntax: *.*.hsc2hs.run.opts += ... - - - - - 9c575f24 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian bootstrap: look up hsc2hs Hadrian bootstrapping looks up where to find ghc_pkg, but the same logic was not in place for hsc2hs which meant we could fail to find the appropriate hsc2hs executabe when bootstrapping Hadrian. This patch adds that missing logic. - - - - - 229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Add (broken) test for #21622 - - - - - cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Don't Box NULL pointers Previously we could construct a `Box` of a NULL pointer from the `link` field of `StgWeak`. Now we take care to avoid ever introducing such pointers in `collect_pointers` and ensure that the `link` field is represented as a `Maybe` in the `Closure` type. Fixes #21622 - - - - - 31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00 winio: Add support to console handles to handleToHANDLE - - - - - 711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Add SMUL[LH] instructions These will be needed to fix #21624. - - - - - d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Fix syntax of OpRegShift operands Previously this produced invalid assembly containing a redundant comma. - - - - - a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00 ncg/aarch64: Fix implementation of IntMulMayOflo The code generated for IntMulMayOflo was previously wrong as it depended upon the overflow flag, which the AArch64 MUL instruction does not set. Fix this. Fixes #21624. - - - - - 26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00 testsuite: Add test for #21624 Ensuring that mulIntMayOflo# behaves as expected. - - - - - 94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00 CprAnal: Set signatures of DFuns to top The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal that is observable in a debug build. The CPR signature of a recursive DFunId was never updated and hence the optimistic arity 0 bottom signature triggered a mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any code because WW doesn't exploit bottom CPR signatures. - - - - - b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00 CorePrep: Don't speculatively evaluate recursive calls (#20836) In #20836 we have optimised a terminating program into an endless loop, because we speculated the self-recursive call of a recursive DFun. Now we track the set of enclosing recursive binders in CorePrep to prevent speculation of such self-recursive calls. See the updates to Note [Speculative evaluation] for details. Fixes #20836. - - - - - 49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00 Simplify: Take care with eta reduction in recursive RHSs (#21652) Similar to the fix to #20836 in CorePrep, we now track the set of enclosing recursive binders in the SimplEnv and SimpleOptEnv. See Note [Eta reduction in recursive RHSs] for details. I also updated Note [Arity robustness] with the insights Simon and I had in a call discussing the issue. Fixes #21652. Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation of a large list literal at the top-level that didn't happen before (presumably because it was too interesting to float to the top-level). There's not much we can do about that. Metric Increase: T16577 - - - - - 2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00 Ignore .hie-bios - - - - - e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00 Instantiate top level foralls in partial type signatures The main fix for #21667 is the new call to tcInstTypeBnders in tcHsPartialSigType. It was really a simple omission before. I also moved the decision about whether we need to apply the Monomorphism Restriction, from `decideGeneralisationPlan` to `tcPolyInfer`. That removes a flag from the InferGen constructor, which is good. But more importantly, it allows the new function, checkMonomorphismRestriction called from `tcPolyInfer`, to "see" the `Types` involved rather than the `HsTypes`. And that in turn matters because we invoke the MR for partial signatures if none of the partial signatures in the group have any overloading context; and we can't answer that question for HsTypes. See Note [Partial type signatures and the monomorphism restriction] in GHC.Tc.Gen.Bind. This latter is really a pre-existing bug. - - - - - 262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00 Make Outputable instance for InlineSig print the InlineSpec Fix ghc/ghc#21739 Squash fix ghc/ghc#21739 - - - - - b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00 Add NO_BOOT to hackage_doc_tarball job We were attempting to boot a src-tarball which doesn't work as ./boot is not included in the source tarball. This slipped through as the job is only run on nightly. - - - - - d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00 HsToken for @-patterns and TypeApplications (#19623) One more step towards the new design of EPA. - - - - - 159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00 linker: only keep rtl exception tables if they have been relocated - - - - - da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00 Ticky:Make json info a separate field. - - - - - 1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00 Revert "Ticky:Make json info a separate field." This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862. This was pushed directly without review. - - - - - f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00 Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags These flags affect the behaviour of local let floating. If `-flocal-float-out` is disabled (the default) then we disable all local floating. ``` …(let x = let y = e in (a,b) in body)... ===> …(let y = e; x = (a,b) in body)... ``` Further to this, top-level local floating can be disabled on it's own by passing -fno-local-float-out-top-level. ``` x = let y = e in (a,b) ===> y = e; x = (a,b) ``` Note that this is only about local floating, ie, floating two adjacent lets past each other and doesn't say anything about the global floating pass which is controlled by `-fno-float`. Fixes #13663 - - - - - 4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00 Check for Int overflows in Data.Array.Byte - - - - - 2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00 Add a basic test for ByteArray's Monoid instance - - - - - fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00 Rename `copyByteArray` to `unsafeCopyByteArray` - - - - - ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00 testsuite: Add test for #21719 Happily, this has been fixed since 9.2. - - - - - 19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Use lookupNameCache instead of lookupOrigIO - - - - - 4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Break out thNameToGhcNameIO (ref. #21730) - - - - - eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00 Add laws for 'toInteger' and 'toRational' CLC discussion here: https://github.com/haskell/core-libraries-committee/issues/58 - - - - - c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00 Correct documentation of defaults of the `-V` RTS option - - - - - b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00 Transcribe discussion from #21483 into a Note In #21483 I had a discussion with Simon Marlow about the memory retention behaviour of -Fd. I have just transcribed that conversation here as it elucidates the potentially subtle assumptions which led to the design of the memory retention behaviours of -Fd. Fixes #21483 - - - - - 980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00 eventlog: Don't leave dangling pointers hanging around Previously we failed to reset pointers to various eventlog buffers to NULL after freeing them. In principle we shouldn't look at them after they are freed but nevertheless it is good practice to set them to a well-defined value. - - - - - 575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00 runhaskell - - - - - e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00 re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45 - - - - - 5d45aa97 by Gergo ERDI at 2022-06-22T22:00:46-04:00 When specialising, look through floatable ticks. Fixes #21697. - - - - - 531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00 TagCheck.hs: Properly check if arguments are boxed types. For one by mistake I had been checking against the kind of runtime rep instead of the boxity. This uncovered another bug, namely that we tried to generate the checking code before we had associated the function arguments with a register, so this could never have worked to begin with. This fixes #21729 and both of the above issues. - - - - - c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00 Use correct arch for the FreeBSD triple in gen-data-layout.sh Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798 Relevant upstream issue: #15718 - - - - - 75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00 Bump nofib submodule. Allows the shake runner to build with 9.2.3 among other things. Fixes #21772 - - - - - 0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00 Bump ghc-prim and base versions To 0.9.0 and 4.17.0 respectively. Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm, terminfo, text, unix, haddock, and hsc2hs submodules. (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095) - - - - - 4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00 testsuite: Use normalise_version more consistently Previously several tests' output were unnecessarily dependent on version numbers, particularly of `base`. Fix this. - - - - - d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00 linters: Fix lint-submodule-refs when crashing trying to find plausible branches - - - - - 38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 hadrian: Improve haddocks for ghcDebugAssertions - - - - - ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 Don't mark lambda binders as OtherCon We used to put OtherCon unfoldings on lambda binders of workers and sometimes also join points/specializations with with the assumption that since the wrapper would force these arguments once we execute the RHS they would indeed be in WHNF. This was wrong for reasons detailed in #21472. So now we purge evaluated unfoldings from *all* lambda binders. This fixes #21472, but at the cost of sometimes not using as efficient a calling convention. It can also change inlining behaviour as some occurances will no longer look like value arguments when they did before. As consequence we also change how we compute CBV information for arguments slightly. We now *always* determine the CBV convention for arguments during tidy. Earlier in the pipeline we merely mark functions as candidates for having their arguments treated as CBV. As before the process is described in the relevant notes: Note [CBV Function Ids] Note [Attaching CBV Marks to ids] Note [Never put `OtherCon` unfoldigns on lambda binders] ------------------------- Metric Decrease: T12425 T13035 T18223 T18223 T18923 MultiLayerModulesTH_OneShot Metric Increase: WWRec ------------------------- - - - - - 06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00 Add suggestions for unrecognised pragmas (#21589) In case of a misspelled pragma, offer possible corrections as to what the user could have meant. Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589 - - - - - 3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00 Remove the traces of i386-*-openbsd, long live amd64 OpenBSD will not ship any ghc packages on i386 starting with 7.2 release. This means there will not be a bootstrap compiler easily available. The last available binaries are ghc-8.10.6 which is already not supported as bootstrap for HEAD. See here for more information: https://marc.info/?l=openbsd-ports&m=165060700222580&w=2 - - - - - 58530271 by Bodigrim at 2022-06-27T08:03:34-04:00 Add Foldable1 and Bifoldable1 type classes Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9 Instances roughly follow https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1 but the API of `Foldable1` was expanded in comparison to `semigroupoids`. Compatibility shim is available from https://github.com/phadej/foldable1 (to be released). Closes #13573. - - - - - a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00 add levity polymorphism to addrToAny# - - - - - f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00 add tests for addrToAny# levity - - - - - 07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00 hadrian: Update main README page This README had some quite out-of-date content about the build system so I did a complete pass deleting old material. I also made the section about flavours more prominent and mentioned flavour transformers. - - - - - 79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00 testsuite: Hide output from test compilations with verbosity==2 Previously the output from test compilations used to determine whether, e.g., profiling libraries are available was shown with verbosity levels >= 2. However, the default level is 2, meaning that most users were often spammed with confusing errors. Fix this by bumping the verbosity threshold for this output to >=3. Fixes #21760. - - - - - 995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00 configure: Only probe for LD in FIND_LD Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD rather early in `configure`. However, it turns out that this breaks `configure`'s `ld`-override logic, which assumes that `LD` was set by the user and aborts. Fixes #21778. - - - - - b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00 `.hs-boot` make rules: add missing order-only dependency on target directory Noticed missing target directory dependency as a build failure in `make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100): "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254 make: *** [Makefile:128: all] Error 2 shuffle=1656129254 Note that `cp` complains about inability to create target file. The change adds order-only dependency on a target directory (similar to the rest of rules in that file). The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build system megapatch`.) where upfront directory creation was never added to `.hs-boot` files. - - - - - 57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00 Mark AArch64/Darwin as requiring sign-extension Apple's AArch64 ABI requires that the caller sign-extend small integer arguments. Set platformCConvNeedsExtension to reflect this fact. Fixes #21773. - - - - - df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00 -ddump-llvm shouldn't imply -fllvm Previously -ddump-llvm would change the backend used, which contrasts with all other dump flags. This is quite surprising and cost me quite a bit of time. Dump flags should not change compiler behavior. Fixes #21776. - - - - - 70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Re-format argument handling logic Previously there were very long, hard to parse lines. Fix this. - - - - - 696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Sign-extend narrow C arguments The AArch64/Darwin ABI requires that function arguments narrower than 32-bits must be sign-extended by the caller. We neglected to do this, resulting in #20735. Fixes #20735. - - - - - c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00 testsuite: Add test for #20735 - - - - - 16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00 integer-gmp: Fix cabal file Evidently fields may not come after sections in a cabal file. - - - - - 03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00 ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist) before the change `make install` was failing as: ``` "mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc" make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'. Stop. ``` I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf` is created (somewhat manually), but not the .install varianlt of it. The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere. Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784 - - - - - eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00 Comments only, about join points This MR just adds some documentation about why casts destroy join points, following #21716. - - - - - 251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00 Cleanup BuiltInSyntax vs UserSyntax There was some confusion about whether FUN/TYPE/One/Many should be BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as BuiltInSyntax is for things which are directly constructed by the parser rather than going through normal renaming channels. I fixed all the obviously wrong places I could find and added a test for the original bug which was caused by this (#21752) Fixes #21752 #20695 #18302 - - - - - 0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00 template-haskell: Bump version to 2.19.0.0 Bumps text and exceptions submodules due to bounds. - - - - - bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00 Tiny tweak to `IOPort#` documentation The exclamation mark and bracket don’t seem to make sense here. I’ve looked through the history, and I don’t think they’re deliberate – possibly a copy-and-paste error. - - - - - 70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00 Remove `CoreOccurAnal` constructor of the `CoreToDo` type It was dead code since the last occurence in an expression context got removed in 71916e1c018dded2e68d6769a2dbb8777da12664. - - - - - d0722170 by nineonine at 2022-07-01T08:15:56-04:00 Fix panic with UnliftedFFITypes+CApiFFI (#14624) When declaring foreign import using CAPI calling convention, using unlifted unboxed types would result in compiler panic. There was an attempt to fix the situation in #9274, however it only addressed some of the ByteArray cases. This patch fixes other missed cases for all prims that may be used as basic foreign types. - - - - - eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00 rts: gc stats: account properly for copied bytes in sequential collections We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow] counters during sequential collections. As well, we were double counting for parallel collections. To fix this we add an `else` clause to the `if (is_par_gc())`. The par_* counters do not need to be updated in the sequential case because they must be 0. - - - - - f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00 desugar: Look through ticks when warning about possible literal overflow Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up between the appliation of `neg` to its argument. This defeated the special logic which looks for `NegApp ... (HsOverLit` to warn about possible overflow if a user writes a negative literal (without out NegativeLiterals) in their code. Fixes #21701 - - - - - f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00 ci: Fix definition of slow-validate flavour (so that -dlint) is passed In this embarassing sequence of events we were running slow-validate without -dlint. - - - - - bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00 Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411 - - - - - 9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00 Data.Foldable1: Remove references to Foldable-specific note ...as discussed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455. - - - - - 3a8970ac by romes at 2022-07-03T14:11:31-04:00 TTG: Move HsModule to L.H.S Move the definition of HsModule defined in GHC.Hs to Language.Haskell.Syntax with an added TTG parameter and corresponding extension fields. This is progress towards having the haskell-syntax package, as described in #21592 - - - - - f9f80995 by romes at 2022-07-03T14:11:31-04:00 TTG: Move ImpExp client-independent bits to L.H.S.ImpExp Move the GHC-independent definitions from GHC.Hs.ImpExp to Language.Haskell.Syntax.ImpExp with the required TTG extension fields such as to keep the AST independent from GHC. This is progress towards having the haskell-syntax package, as described in #21592 Bumps haddock submodule - - - - - c43dbac0 by romes at 2022-07-03T14:11:31-04:00 Refactor ModuleName to L.H.S.Module.Name ModuleName used to live in GHC.Unit.Module.Name. In this commit, the definition of ModuleName and its associated functions are moved to Language.Haskell.Syntax.Module.Name according to the current plan towards making the AST GHC-independent. The instances for ModuleName for Outputable, Uniquable and Binary were moved to the module in which the class is defined because these instances depend on GHC. The instance of Eq for ModuleName is slightly changed to no longer depend on unique explicitly and instead uses FastString's instance of Eq. - - - - - 2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00 Expand `Ord` instance for `Down` Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610 - - - - - 36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00 Add applyWhen to Data.Function per CLC prop Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233 - - - - - 3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00 hadrian: Don't read package environments in ghc-stage1 wrapper The stage1 compiler may be on the brink of existence and not have even a working base library. You may have installed packages globally with a similar stage2 compiler which will then lead to arguments such as --show-iface not even working because you are passing too many package flags. The solution is simple, don't read these implicit files. Fixes #21803 - - - - - aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00 Ticky:Make json info a separate field. Fixes #21233 - - - - - 74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00 Add docs:<pkg> command to hadrian to build docs for just one package - - - - - 418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00 upload-docs: propagate publish correctly in upload_sdist - - - - - ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00 docs-upload: Fix upload script when no packages are listed - - - - - d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00 hadrian: Add --haddock-base-url option for specifying base-url when generating docs The motiviation for this flag is to be able to produce documentation which is suitable for uploading for hackage, ie, the cross-package links work correctly. There are basically three values you want to set this to: * off - default, base_url = ../%pkg% which works for local browsing * on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload * on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation. The `%pkg%` string is a template variable which is replaced with the package identifier for the relevant package. This is one step towards fixing #21749 - - - - - 41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00 Add nightly job for generating docs suitable for hackage upload - - - - - 620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00 ghci: Support :set prompt in multi repl This adds supports for various :set commands apart from `:set <FLAG>` in multi repl, this includes `:set prompt` and so-on. Fixes #21796 - - - - - b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00 Vendor filepath inside template-haskell Adding filepath as a dependency of template-haskell means that it can't be reinstalled if any build-plan depends on template-haskell. This is a temporary solution for the 9.4 release. A longer term solution is to split-up the template-haskell package into the wired-in part and a non-wired-in part which can be reinstalled. This was deemed quite risky on the 9.4 release timescale. Fixes #21738 - - - - - c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00 Factor fields of `CoreDoSimplify` into separate data type This avoids some partiality. The work @mmhat is doing cleaning up and modularizing `Core.Opt` will build on this nicely. - - - - - d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00 https urls - - - - - 803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00 options and typos - - - - - 5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00 grammar - - - - - 4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00 sources - - - - - c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00 Fix lint warnings in bootstrap.py - - - - - 86ced2ad by romes at 2022-07-06T01:36:23-04:00 Restore Eq instance of ImportDeclQualifiedStyle Fixes #21819 - - - - - 3547e264 by romes at 2022-07-06T13:50:27-04:00 Prune L.H.S modules of GHC dependencies Move around datatypes, functions and instances that are GHC-specific out of the `Language.Haskell.Syntax.*` modules to reduce the GHC dependencies in them -- progressing towards #21592 Creates a module `Language.Haskell.Syntax.Basic` to hold basic definitions required by the other L.H.S modules (and don't belong in any of them) - - - - - e4eea07b by romes at 2022-07-06T13:50:27-04:00 TTG: Move CoreTickish out of LHS.Binds Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and move them to the extension point instance, according to the plan outlined in #21592 to separate the base AST from the GHC specific bits. - - - - - acc1816b by romes at 2022-07-06T13:50:27-04:00 TTG for ForeignImport/Export Add a TTG parameter to both `ForeignImport` and `ForeignExport` and, according to #21592, move the GHC-specific bits in them and in the other AST data types related to foreign imports and exports to the TTG extension point. - - - - - 371c5ecf by romes at 2022-07-06T13:50:27-04:00 TTG for HsTyLit Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText` fields to the extension point and out of the base AST. Progress towards #21592 - - - - - fd379d1b by romes at 2022-07-06T13:50:27-04:00 Remove many GHC dependencies from L.H.S Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC imports according to the plan in the linked issue. Moves more GHC-specific declarations to `GHC.*` and brings more required GHC-independent declarations to `Language.Haskell.Syntax.*` (extending e.g. `Language.Haskell.Syntax.Basic`). Progress towards #21592 Bump haddock submodule for !8308 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00 Fix exact printing of the HsRule name Prior to this branch, the HsRule name was XRec pass (SourceText,RuleName) and there is an ExactPrint instance for (SourceText, RuleName). The SourceText has moved to a different location, so synthesise the original to trigger the correct instance when printing. We need both the SourceText and RuleName when exact printing, as it is possible to have a NoSourceText variant, in which case we fall back to the FastString. - - - - - 665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00 driver: Fix issue with module loops and multiple home units We were attempting to rehydrate all dependencies of a particular module, but we actually only needed to rehydrate those of the current package (as those are the ones participating in the loop). This fixes loading GHC into a multi-unit session. Fixes #21814 - - - - - bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00 Remove a bogus #define from ClosureMacros.h - - - - - fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00 winio: make consoleReadNonBlocking not wait for any events at all. - - - - - 42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00 rts: allow NULL to be used as an invalid StgStablePtr - - - - - 3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00 RTS: Add stack marker to StgCRunAsm.S Every object file must be properly marked for non-executable stack, even if it contains no code. - - - - - a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00 Bump unix submodule Adds `config.sub` to unix's `.gitignore`, fixing #19574. - - - - - 3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00 ghci: Fix most calls to isLoaded to work in multi-mode The most egrarious thing this fixes is the report about the total number of loaded modules after starting a session. Ticket #20889 - - - - - fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00 Enable :edit command in ghci multi-mode. This works after the last change to isLoaded. Ticket #20888 - - - - - 46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00 Fix a scoping bug in the Specialiser In the call to `specLookupRule` in `already_covered`, in `specCalls`, we need an in-scope set that includes the free vars of the arguments. But we simply were not guaranteeing that: did not include the `rule_bndrs`. Easily fixed. I'm not sure how how this bug has lain for quite so long without biting us. Fixes #21828. - - - - - 6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Edit Note [idArity varies independently of dmdTypeDepth] ...and refer to it in GHC.Core.Lint.lintLetBind. Fixes #21452 - - - - - 89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Tiny documentation wibbles (comments only) - - - - - 61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix readme - - - - - 61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix bootstrap - - - - - 8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00 tarball - - - - - e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Fix scopes for deriving clauses and instance signatures (#18425) - - - - - c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Record location of filled in default method bindings This is useful for hie files to reconstruct the evidence that default methods depend on. - - - - - 9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00 testsuite: Factor out common parts from hiefile tests - - - - - 6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00 Hadrian: update documentation of settings The documentation for key-value settings was a bit out of date. This patch updates it to account for `cabal.configure.opts` and `hsc2hs.run.opts`. The user-settings document was also re-arranged, to make the key-value settings more prominent (as it doesn't involve changing the Hadrian source code, and thus doesn't require any recompilation of Hadrian). - - - - - a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00 Fix potential space leak that arise from ModuleGraphs retaining references to previous ModuleGraphs, in particular the lazy `mg_non_boot` field. This manifests in `extendMG`. Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which is only called in two places in the compiler, and should only be called at most once for every home unit: GHC.Driver.Make: mainModuleSrcPath :: Maybe String mainModuleSrcPath = do ms <- mgLookupModule mod_graph (mainModIs hue) ml_hs_file (ms_location ms) GHCI.UI: listModuleLine modl line = do graph <- GHC.getModuleGraph let this = GHC.mgLookupModule graph modl Instead `mgLookupModule` can be a linear function that looks through the entire list of `ModuleGraphNodes` Fixes #21816 - - - - - dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00 rts: Fix AdjustorPool bitmap manipulation Previously the implementation of bitmap_first_unset assumed that `__builtin_clz` would accept `uint8_t` however it apparently rather extends its argument to `unsigned int`. To fix this we simply revert to a naive implementation since handling the various corner cases with `clz` is quite tricky. This should be fine given that AdjustorPool isn't particularly hot. Ideally we would have a single, optimised bitmap implementation in the RTS but I'll leave this for future work. Fixes #21838. - - - - - ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00 Change GHCi bytecode return convention for unlifted datatypes. This changes the bytecode return convention for unlifted algebraic datatypes to be the same as for lifted types, i.e. ENTER/PUSH_ALTS instead of RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED Fixes #20849 - - - - - 5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00 Compute record-dot-syntax types Ensures type information for record-dot-syntax is included in HieASTs. See #21797 - - - - - 89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00 Add record-dot-syntax test - - - - - 4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00 Document RuntimeRep polymorphism limitations of catch#, et al As noted in #21868, several primops accepting continuations producing RuntimeRep-polymorphic results aren't nearly as polymorphic as their types suggest. Document this limitation and adapt the `UnliftedWeakPtr` test to avoid breaking this limitation in `keepAlive#`. - - - - - 4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00 Make keepAlive# out-of-line This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203 - - - - - 1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00 Suppress extra output from configure check for c++ libraries - - - - - 3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00 rel-notes: Drop mention of #21745 fix Since we have backported the fix to 9.4.1. - - - - - b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00 Align the behaviour of `dopt` and `log_dopt` Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying function `log_dopt`) were different as the latter did not take the verbosity level into account. This led to problems during the refactoring as we cannot simply replace calls to `dopt` with calls to `logHasDumpFlag`. In addition to that a subtle bug in the GHC module was fixed: `setSessionDynFlags` did not update the logger and as a consequence the verbosity value of the logger was not set appropriately. Fixes #21861 - - - - - 28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00 rts: forkOn context switches the target capability Fixes #21824 - - - - - f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Eliminate orphan Outputable instances Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and `OutputableP` instances for the Cmm AST. This makes it significantly easier to use the Cmm pretty-printers in tracing output without incurring module import cycles. - - - - - f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Move toBlockList to GHC.Cmm - - - - - fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00 compiler: Add haddock sections to GHC.Utils.Panic - - - - - 097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00 configure: Don't override Windows CXXFLAGS At some point we used the clang distribution from msys2's `MINGW64` environment for our Windows toolchain. This defaulted to using libgcc and libstdc++ for its runtime library. However, we found for a variety of reasons that compiler-rt, libunwind, and libc++ were more reliable, consequently we explicitly overrode the CXXFLAGS to use these. However, since then we have switched to use the `CLANG64` packaging, which default to these already. Consequently we can drop these arguments, silencing some redundant argument warnings from clang. Fixes #21669. - - - - - e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Check that there are no NULL ctors - - - - - 616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Introduce support for invoking finalizers on unload Addresses #20494. - - - - - cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add T20494 - - - - - 03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Rename finit field to fini fini is short for "finalizer", which does not contain a "t". - - - - - 033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Refactor handling of oc->info Previously we would free oc->info after running initializers. However, we can't do this is we want to also run finalizers. Moreover, freeing oc->info so early was wrong for another reason: we will need it in order to unregister the exception tables (see the call to `RtlDeleteFunctionTable`). In service of #20494. - - - - - f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Add finalization support This implements #20494 for the PEi386 linker. Happily, this also appears to fix `T9405`, resolving #21361. - - - - - 2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00 Loader: Implement gnu-style -l:$path syntax Gnu ld allows `-l` to be passed an absolute file path, signalled by a `:` prefix. Implement this in the GHC's loader search logic. - - - - - 5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00 Statically-link against libc++ on Windows Unfortunately on Windows we have no RPATH-like facility, making dynamic linking extremely fragile. Since we cannot assume that the user will add their GHC installation to `$PATH` (and therefore their DLL search path) we cannot assume that the loader will be able to locate our `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on Windows. Fixes #21435. - - - - - 8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run It turns out that PE objects may have multiple `.ctors`/`.dtors` sections but the RTS linker had assumed that there was only one. Fix this. Fixes #21618. - - - - - fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Respect dtor/ctor priority Previously we would run constructors and destructors in arbitrary order despite explicit priorities. Fixes #21847. - - - - - 1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add test for #21618 and #21847 - - - - - 6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Fix exception unwind unregistration RtlDeleteFunctionTable expects a pointer to the .pdata section yet we passed it the .xdata section. Happily, this fixes #21354. - - - - - d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Drop dead code - - - - - d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Use section flags to identify initializers - - - - - fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Introduce finalizer support - - - - - 5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl - - - - - 6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker/Elf: Work around GCC 6 init/fini behavior It appears that GCC 6t (at least on i386) fails to give init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY section types, instead marking them as SHT_PROGBITS. This caused T20494 to fail on Debian. - - - - - 5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Mark T13366Cxx as unbroken on Darwin - - - - - 1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Fix resolution of __dso_handle on Darwin Darwin expects a leading underscore. - - - - - a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Clean up section kinds - - - - - aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Ensure that __cxa_finalize is called on code unload - - - - - 028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00 testsuite: Fix T11829 on Centos 7 It appears that Centos 7 has a more strict C++ compiler than most distributions since std::runtime_error is defined in <stdexcept> rather than <exception>. In T11829 we mistakenly imported the latter. - - - - - a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00 hadrian: Rename documentation directories for consistency with make * Rename `docs` to `doc` * Place pdf documentation in `doc/` instead of `doc/pdfs/` Fixes #21164. - - - - - b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00 Fix incorrect proof of applyWhen’s properties - - - - - eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00 hadrian: Add multi:<pkg> and multi targets for starting a multi-repl This patch adds support to hadrian for starting a multi-repl containing all the packages which stage0 can build. In particular, there is the new user-facing command: ``` ./hadrian/ghci-multi ``` which when executed will start a multi-repl containing the `ghc` package and all it's dependencies. This is implemented by two new hadrian targets: ``` ./hadrian/build multi:<pkg> ``` Construct the arguments for a multi-repl session where the top-level package is <pkg>. For example, `./hadrian/ghci-multi` is implemented using `multi:ghc` target. There is also the `multi` command which constructs a repl for everything in stage0 which we can build. - - - - - 19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00 changelog typo - - - - - af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00 typos - - - - - 415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00 Refactor SpecConstr to use treat bindings uniformly This patch, provoked by #21457, simplifies SpecConstr by treating top-level and nested bindings uniformly (see the new scBind). * Eliminates the mysterious scTopBindEnv * Refactors scBind to handle top-level and nested definitions uniformly. * But, for now at least, continues the status quo of not doing SpecConstr for top-level non-recursive bindings. (In contrast we do specialise nested non-recursive bindings, although the original paper did not; see Note [Local let bindings].) I tried the effect of specialising top-level non-recursive bindings (which is now dead easy to switch on, unlike before) but found some regressions, so I backed off. See !8135. It's a pure refactoring. I think it'll do a better job in a few cases, but there is no regression test. - - - - - d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00 Rule matching: Don't compute the FVs if we don't look at them. - - - - - 5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 White space only in FamInstEnv - - - - - ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make transferPolyIdInfo work for CPR I don't know why this hasn't bitten us before, but it was plain wrong. - - - - - 9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Inline mapAccumLM This function is called in inner loops in the compiler, and it's overloaded and higher order. Best just to inline it. This popped up when I was looking at something else. I think perhaps GHC is delicately balanced on the cusp of inlining this automatically. - - - - - d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make SetLevels honour floatConsts This fix, in the definition of profitableFloat, is just for consistency. `floatConsts` should do what it says! I don't think it'll affect anything much, though. - - - - - d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Refactor wantToUnboxArg a bit * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg and similarly wantToUnboxResult to canUnboxResult. * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg, avoiding some yukky duplication. I decided it was clearer to give it a new data type for its return type, because I nedeed the FD_RecBox case which was not otherwise readiliy expressible. * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload * Get rid of the Unlift constructor of UnboxingDecision, eliminate two panics, and two arguments to canUnboxArg (new name). Much nicer now. - - - - - 6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00 Allow running memInventory when the concurrent nonmoving gc is enabled If the nonmoving gc is enabled and we are using a threaded RTS, we now try to grab the collector mutex to avoid memInventory and the collection racing. Before memInventory was disabled. - - - - - aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00 gitignore: don't ignore all aclocal.m4 files While GHC's own aclocal.m4 is generated by the aclocal tool, other packages' aclocal.m4 are committed in the repository. Previously `.gitignore` included an entry which covered *any* file named `aclocal.m4`, which lead to quite some confusion (e.g. see #21740). Fix this by modifying GHC's `.gitignore` to only cover GHC's own `aclocal.m4`. - - - - - 4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00 Add mapAccumM, forAccumM to Data.Traversable Approved by Core Libraries Committee in https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433 - - - - - bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00 configure: Use AC_PATH_TOOL to detect tools Previously we used AC_PATH_PROG which, as noted by #21601, does not look for tools with a target prefix, breaking cross-compilation. Fixes #21601. - - - - - e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00 driver: Fix implementation of -S We were failing to stop before running the assembler so the object file was also created. Fixes #21869 - - - - - e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00 rts/ProfHeap: Ensure new Censuses are zeroed When growing the Census array ProfHeap previously neglected to zero the new part of the array. Consequently `freeEra` would attempt to free random words that often looked suspiciously like pointers. Fixes #21880. - - - - - 81d65f7f by sheaf at 2022-07-21T15:37:22+02:00 Make withDict opaque to the specialiser As pointed out in #21575, it is not sufficient to set withDict to inline after the typeclass specialiser, because we might inline withDict in one module and then import it in another, and we run into the same problem. This means we could still end up with incorrect runtime results because the typeclass specialiser would assume that distinct typeclass evidence terms at the same type are equal, when this is not necessarily the case when using withDict. Instead, this patch introduces a new magicId, 'nospec', which is only inlined in CorePrep. We make use of it in the definition of withDict to ensure that the typeclass specialiser does not common up distinct typeclass evidence terms. Fixes #21575 - - - - - 9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00 Refactored Simplify pass * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify namespace and GHC.Core.Opt.Stats. Also removed services from configuration records. * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration. * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm` and moved the Simplify driver to GHC.Core.Opt.Simplify. * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env. * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment in GHC.Core.Opt.Simplify.Monad. * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions for those in a new module GHC.Driver.Config.Core.Opt.Simplify. Also added initialization functions for `SimplMode` to that module. * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types and the counting types and functions (`SimplCount` and `Tick`) to new module GHC.Core.Opt.Stats. * Added getter functions for the fields of `SimplMode`. The pedantic bottoms option and the platform are retrieved from the ArityOpts and RuleOpts and the getter functions allow us to retrieve values from `SpecEnv` without the knowledge where the data is stored exactly. * Moved the coercion optimization options from the top environment to `SimplMode`. This way the values left in the top environment are those dealing with monadic functionality, namely logging, IO related stuff and counting. Added a note "The environments of the Simplify pass". * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead. * Prep work before removing `InteractiveContext` from `HscEnv`. - - - - - 2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00 Make the specialiser deal better with specialised methods This patch fixes #21848, by being more careful to update unfoldings in the type-class specialiser. See the new Note [Update unfolding after specialisation] Now that we are being so much more careful about unfoldings, it turned out that I could dispense with se_interesting, and all its tricky corners. Hooray. This fixes #21368. - - - - - ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00 ghc-boot: Clean up UTF-8 codecs In preparation for moving the UTF-8 codecs into `base`: * Move them to GHC.Utils.Encoding.UTF8 * Make names more consistent * Add some Haddocks - - - - - e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00 base: Introduce GHC.Encoding.UTF8 Here we copy a subset of the UTF-8 implementation living in `ghc-boot` into `base`, with the intent of dropping the former in the future. For this reason, the `ghc-boot` copy is now CPP-guarded on `MIN_VERSION_base(4,18,0)`. Naturally, we can't copy *all* of the functions defined by `ghc-boot` as some depend upon `bytestring`; we rather just copy those which only depend upon `base` and `ghc-prim`. Further consolidation? ---------------------- Currently GHC ships with at least five UTF-8 implementations: * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this can be used at a number of types including `Addr#`, `ByteArray#`, `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this can be removed in GHC 9.6+2, when the copies in `base` will become available to `ghc-boot`. * the copy of the `ghc-boot` definition now exported by `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`, `ByteArray#`, and `ForeignPtr` * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`; this is specialised at `Addr#`. * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`; this is specialised at `Addr#` but, unlike the above, supports recovery in the presence of partial codepoints (since in IO contexts codepoints may be broken across buffers) * the implementation provided by the `text` library This does seem a tad silly. On the other hand, these implementations *do* materially differ from one another (e.g. in the types they support, the detail in errors they can report, and the ability to recover from partial codepoints). Consequently, it's quite unclear that further consolidate would be worthwhile. - - - - - f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00 Add a Note summarising GHC's UTF-8 implementations GHC has a somewhat dizzying array of UTF-8 implementations. This note describes why this is the case. - - - - - 72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00 upload_ghc_libs: Fix path to documentation The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35 but this one occurrence was note updated. Finally closes #21164. - - - - - a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00 Add test for #21871 This adds a test for #21871, which was fixed by the No Skolem Info rework (MR !7105). Fixes #21871 - - - - - 6379f942 by sheaf at 2022-07-22T08:18:46-04:00 Add test for #21360 The way record updates are typechecked/desugared changed in MR !7981. Because we desugar in the typechecker to a simple case expression, the pattern match checker becomes able to spot the long-distance information and avoid emitting an incorrect pattern match warning. Fixes #21360 - - - - - ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00 Hadrian: don't try to build "unix" on Windows - - - - - dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Implement DeepSubsumption This MR adds the language extension -XDeepSubsumption, implementing GHC proposal #511. This change mitigates the impact of GHC proposal The changes are highly localised, by design. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. The main changes are: * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010, but off in Haskell2021. -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change. -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds: it makes type inference more complicated and less predictable, but it may be convenient in practice. * The main changes are in: * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result type. Without deep subsumption, unifyExpectedType would be sufficent. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. * There are no changes to Quick Look at all. * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to GHC.Magic.Dict * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where we'd forgotten to take the free vars of the multiplicity of an Id. * I also had to fix tcSplitNestedSigmaTys When I did the shallow-subsumption patch commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f Date: Sun Feb 2 18:23:11 2020 +0000 Simple subsumption I changed tcSplitNestedSigmaTys to not look through function arrows any more. But that was actually an un-forced change. This function is used only in * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect All to do with validity checking and error messages. Acutally its fine to look under function arrows here, and quite useful a test DeepSubsumption05 (a test motivated by a build failure in the `lens` package) shows. The fix is easy. I added Note [tcSplitNestedSigmaTys]. - - - - - e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption - - - - - 67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add DeepSubsumption08 - - - - - 5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Fix the interaction of operator sections and deep subsumption Fixes DeepSubsumption08 - - - - - 918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00 Add DeepSubsumption09 - - - - - 2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00 Default implementation for mempty/(<>) Approved by: https://github.com/haskell/core-libraries-committee/issues/61 This adds a default implementation for `mempty` and `(<>)` along with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid` instances can be defined in terms of `sconcat` / `mconcat`. The description for each class has also been updated to include the equivalent set of laws for the `sconcat`-only / `mconcat`-only instances. - - - - - 73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00 ci: Disable (broken) perf-nofib See #21859 - - - - - c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00 Docs: clarify ConstraintKinds infelicity GHC doesn't consistently require the ConstraintKinds extension to be enabled, as it allows programs such as type families returning a constraint without this extension. MR !7784 fixes this infelicity, but breaking user programs was deemed to not be worth it, so we document it instead. Fixes #21061. - - - - - 5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00 More improvements to worker/wrapper This patch fixes #21888, and simplifies finaliseArgBoxities by eliminating the (recently introduced) data type FinalDecision. A delicate interaction meant that this patch commit d1c25a48154236861a413e058ea38d1b8320273f Date: Tue Jul 12 16:33:46 2022 +0100 Refactor wantToUnboxArg a bit make worker/wrapper go into an infinite loop. This patch fixes it by narrowing the handling of case (B) of Note [Boxity for bottoming functions], to deal only the arguemnts that are type variables. Only then do we drop the trimBoxity call, which is what caused the bug. I also * Added documentation of case (B), which was previously completely un-mentioned. And a regression test, T21888a, to test it. * Made unboxDeeplyDmd stop at lazy demands. It's rare anyway for a bottoming function to have a lazy argument (mainly when the data type is recursive and then we don't want to unbox deeply). Plus there is Note [No lazy, Unboxed demands in demand signature] * Refactored the Case equation for dmdAnal a bit, to do less redundant pattern matching. - - - - - b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00 Fix a small buglet in tryEtaReduce Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was making an ill-formed cast. It didn't matter, because the subsequent guard discarded it; but still worth fixing. Spurious warnings are distracting. - - - - - 3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00 Fix #21889, GHCi misbehaves with Ctrl-C on Windows On Windows, we create multiple levels of wrappers for GHCi which ultimately execute ghc --interactive. In order to handle console events properly, each of these wrappers must call FreeConsole() in order to hand off event processing to the child process. See #14150. In addition to this, FreeConsole must only be called from interactive processes (#13411). This commit makes two changes to fix this situation: 1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole` if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi. 2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`: Before: ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe After: ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe - - - - - 79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00 docs: Fix documentation of \cases Fixes #21902. - - - - - e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00 ghc-cabal: allow Cabal 3.8 to unbreak make build When bootstrapping GHC 9.4.*, the build will fail when configuring ghc-cabal as part of the make based build system due to this upper bound, as Cabal has been updated to a 3.8 release. Reference #21914, see especially https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699 - - - - - 726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Fix isEvaldUnfolding and isValueUnfolding This fixes (1) in #21831. Easy, obviously correct. - - - - - 5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Switch off eta-expansion in rules and unfoldings I think this change will make little difference except to reduce clutter. But that's it -- if it causes problems we can switch it on again. - - - - - d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Teach SpecConstr about typeDeterminesValue This patch addresses #21831, point 2. See Note [generaliseDictPats] in SpecConstr I took the opportunity to refactor the construction of specialisation rules a bit, so that the rule name says what type we are specialising at. Surprisingly, there's a 20% decrease in compile time for test perf/compiler/T18223. I took a look at it, and the code size seems the same throughout. I did a quick ticky profile which seemed to show a bit less substitution going on. Hmm. Maybe it's the "don't do eta-expansion in stable unfoldings" patch, which is part of the same MR as this patch. Anyway, since it's a move in the right direction, I didn't think it was worth looking into further. Metric Decrease: T18223 - - - - - 65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Add a 'notes' file in testsuite/tests/perf/compiler This file is just a place to accumlate notes about particular benchmarks, so that I don't keep re-inventing the wheel. - - - - - 61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00 Get the in-scope set right in FamInstEnv.injectiveBranches There was an assert error, as Gergo pointed out in #21896. I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs. And also to GHC.Core.Unify.niFixTCvSubst. I also took the opportunity to get a couple more InScopeSets right, and to change some substTyUnchecked into substTy. This MR touches a lot of other files, but only because I also took the opportunity to introduce mkInScopeSetList, and use it. - - - - - 4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00 Add location to cc phase - - - - - 96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00 Avoid as pipeline when compiling c - - - - - 2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00 testsuite: Skip test cases involving -S when testing unregisterised GHC We no longer generate .s files anyway. Metric Decrease: MultiLayerModules T10421 T13035 T13701 T14697 T16875 T18140 T18304 T18923 T9198 - - - - - 82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00 testsuite: introduce nonmoving_thread_sanity way (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae) - - - - - 4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Track segment state It can often be useful during debugging to be able to determine the state of a nonmoving segment. Introduce some state, enabled by DEBUG, to track this. (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f) - - - - - 54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Don't scavenge objects which weren't evacuated This fixes a rather subtle bug in the logic responsible for scavenging objects evacuated to the non-moving generation. In particular, objects can be allocated into the non-moving generation by two ways: a. evacuation out of from-space by the garbage collector b. direct allocation by the mutator Like all evacuation, objects moved by (a) must be scavenged, since they may contain references to other objects located in from-space. To accomplish this we have the following scheme: * each nonmoving segment's block descriptor has a scan pointer which points to the first object which has yet to be scavenged * the GC tracks a set of "todo" segments which have pending scavenging work * to scavenge a segment, we scavenge each of the unmarked blocks between the scan pointer and segment's `next_free` pointer. We skip marked blocks since we know the allocator wouldn't have allocated into marked blocks (since they contain presumably live data). We can stop at `next_free` since, by definition, the GC could not have evacuated any objects to blocks above `next_free` (otherwise `next_free wouldn't be the first free block). However, this neglected to consider objects allocated by path (b). In short, the problem is that objects directly allocated by the mutator may become unreachable (but not swept, since the containing segment is not yet full), at which point they may contain references to swept objects. Specifically, we observed this in #21885 in the following way: 1. the mutator (specifically in #21885, a `lockCAF`) allocates an object (specifically a blackhole, which here we will call `blkh`; see Note [Static objects under the nonmoving collector] for the reason why) on the non-moving heap. The bitmap of the allocated block remains 0 (since allocation doesn't affect the bitmap) and the containing segment's (which we will call `blkh_seg`) `next_free` is advanced. 2. We enter the blackhole, evaluating the blackhole to produce a result (specificaly a cons cell) in the nursery 3. The blackhole gets updated into an indirection pointing to the cons cell; it is pushed to the generational remembered set 4. we perform a GC, the cons cell is evacuated into the nonmoving heap (into segment `cons_seg`) 5. the cons cell is marked 6. the GC concludes 7. the CAF and blackhole become unreachable 8. `cons_seg` is filled 9. we start another GC; the cons cell is swept 10. we start a new GC 11. something is evacuated into `blkh_seg`, adding it to the "todo" list 12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks between `scan` and `next_free`, which includes `blkh`). We attempt to evacuate `blkh`'s indirectee, which is the previously-swept cons cell. This is unsafe, since the indirectee is no longer a valid heap object. The problem here was that the scavenging logic *assumed* that (a) was the only source of allocations into the non-moving heap and therefore *all* unmarked blocks between `scan` and `next_free` were evacuated. However, due to (b) this is not true. The solution is to ensure that that the scanned region only encompasses the region of objects allocated during evacuation. We do this by updating `scan` as we push the segment to the todo-segment list to point to the block which was evacuated into. Doing this required changing the nonmoving scavenging implementation's update of the `scan` pointer to bump it *once*, instead of after scavenging each block as was done previously. This is because we may end up evacuating into the segment being scavenged as we scavenge it. This was quite tricky to discover but the result is quite simple, demonstrating yet again that global mutable state should be used exceedingly sparingly. Fixes #21885 (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060) - - - - - 25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00 testsuite: Skip a few tests as in the nonmoving collector Residency monitoring under the non-moving collector is quite conservative (e.g. the reported value is larger than reality) since otherwise we would need to block on concurrent collection. Skip a few tests that are sensitive to residency. (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70) - - - - - 42147534 by sternenseemann at 2022-07-26T16:26:53-04:00 hadrian: add flag disabling selftest rules which require QuickCheck The hadrian executable depends on QuickCheck for building, meaning this library (and its dependencies) will need to be built for bootstrapping GHC in the future. Building QuickCheck, however, can require TemplateHaskell. When building a statically linking GHC toolchain, TemplateHaskell can be tricky to get to work, and cross-compiling TemplateHaskell doesn't work at all without -fexternal-interpreter, so QuickCheck introduces an element of fragility to GHC's bootstrap. Since the selftest rules are the only part of hadrian that need QuickCheck, we can easily eliminate this bootstrap dependency when required by introducing a `selftest` flag guarding the rules' inclusion. Closes #8699. - - - - - 9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00 Regression test for #21848 - - - - - ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00 driver: Don't create LinkNodes when -no-link is enabled Fixes #21866 - - - - - fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00 Docs: fix mistaken claim about kind signatures This patch fixes #21806 by rectifying an incorrect claim about the usage of kind variables in the header of a data declaration with a standalone kind signature. It also adds some clarifications about the number of parameters expected in GADT declarations and in type family declarations. - - - - - 2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00 testsuite: Correctly set withNativeCodeGen Fixes #21918 - - - - - f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00 Fix since annotations in GHC.Stack.CloneStack Fixes #21894 - - - - - aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00 Add -dsuppress-coercion-types to make coercions even smaller. Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)`` simply print `` `cast` <Co:11> :: ... `` - - - - - 97655ad8 by sheaf at 2022-08-02T19:27:29-04:00 User's guide: fix typo in hasfield.rst Fixes #21950 - - - - - 35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00 Remove TCvSubst and use Subst for both term and type-level subst This patch removes the TCvSubst data type and instead uses Subst as the environment for both term and type level substitution. This change is partially motivated by the existential type proposal, which will introduce types that contain expressions and therefore forces us to carry around an "IdSubstEnv" even when substituting for types. It also reduces the amount of code because "Subst" and "TCvSubst" share a lot of common operations. There isn't any noticeable impact on performance (geo. mean for ghc/alloc is around 0.0% but we have -94 loc and one less data type to worry abount). Currently, the "TCvSubst" data type for substitution on types is identical to the "Subst" data type except the former doesn't store "IdSubstEnv". Using "Subst" for type-level substitution means there will be a redundant field stored in the data type. However, in cases where the substitution starts from the expression, using "Subst" for type-level substitution saves us from having to project "Subst" into a "TCvSubst". This probably explains why the allocation is mostly even despite the redundant field. The patch deletes "TCvSubst" and moves "Subst" and its relevant functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst". Substitution on expressions is still defined in "GHC.Core.Subst" so we don't have to expose the definition of "Expr" in the hs-boot file that "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a distinct function from "isEmptySubst"; the former ignores the emptiness of "IdSubstEnv"). These exceptions mainly exist for performance reasons and will go away when "Expr" and "Type" are mutually recursively defined (we won't be able to take those shortcuts if we can't make the assumption that expressions don't appear in types). - - - - - b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00 Fix TH + defer-type-errors interaction (#21920) Previously, we had to disable defer-type-errors in splices because of #7276. But this fix is no longer necessary, the test T7276 no longer segfaults and is now correctly deferred. - - - - - fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00 Add a note about about W/W for unlifting strict arguments This fixes #21236. - - - - - fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force safeInferred to avoid retaining extra copy of DynFlags This will only have a (very) modest impact on memory but we don't want to retain old copies of DynFlags hanging around so best to force this value. - - - - - 0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force name selectors to ensure no reference to Ids enter the NameCache I observed some unforced thunks in the NameCache which were retaining a whole Id, which ends up retaining a Type.. which ends up retaining old copies of HscEnv containing stale HomeModInfo. - - - - - 0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Fix leaks in --make mode when there are module loops This patch fixes quite a tricky leak where we would end up retaining stale ModDetails due to rehydrating modules against non-finalised interfaces. == Loops with multiple boot files It is possible for a module graph to have a loop (SCC, when ignoring boot files) which requires multiple boot files to break. In this case we must perform the necessary hydration steps before and after compiling modules which have boot files which are described above for corectness but also perform an additional hydration step at the end of the SCC to remove space leaks. Consider the following example: ┌───────┐ ┌───────┐ │ │ │ │ │ A │ │ B │ │ │ │ │ └─────┬─┘ └───┬───┘ │ │ ┌────▼─────────▼──┐ │ │ │ C │ └────┬─────────┬──┘ │ │ ┌────▼──┐ ┌───▼───┐ │ │ │ │ │ A-boot│ │ B-boot│ │ │ │ │ └───────┘ └───────┘ A, B and C live together in a SCC. Say we compile the modules in order A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps (because A has a boot file). Therefore C will be hydrated relative to A, and the ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again, and so B will reference C/A,B, its interface will be hydrated relative to both A and B. Now there is a space leak because say C is a very big module, there are now two different copies of ModDetails kept alive by modules A and B. The way to avoid this space leak is to rehydrate an entire SCC together at the end of compilation so that all the ModDetails point to interfaces for .hs files. In this example, when we hydrate A, B and C together then both A and B will refer to C/A,B. See #21900 for some more discussion. ------------------------------------------------------- In addition to this simple case, there is also the potential for a leak during parallel upsweep which is also fixed by this patch. Transcibed is Note [ModuleNameSet, efficiency and space leaks] Note [ModuleNameSet, efficiency and space leaks] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During unsweep the results of compiling modules are placed into a MVar, to find the environment the module needs to compile itself in the MVar is consulted and the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking module dependencies and recreating the HUG from scratch each time is very expensive. In serial mode (-j1), this all works out fine because a module can only be compiled after its dependencies have finished compiling and not interleaved with compiling module loops. Therefore when we create the finalised or no loop interfaces, the HUG only contains finalised interfaces. In parallel mode, we have to be more careful because the HUG variable can contain non-finalised interfaces which have been started by another thread. In order to avoid a space leak where a finalised interface is compiled against a HPT which contains a non-finalised interface we have to restrict the HUG to only the visible modules. The visible modules is recording in the ModuleNameSet, this is propagated upwards whilst compiling and explains which transitive modules are visible from a certain point. This set is then used to restrict the HUG before the module is compiled to only the visible modules and thus avoiding this tricky space leak. Efficiency of the ModuleNameSet is of utmost importance because a union occurs for each edge in the module graph. Therefore the set is represented directly as an IntSet which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode. See test "jspace" for an example which used to trigger this problem. Fixes #21900 - - - - - 1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Store interfaces in ModIfaceCache more directly I realised hydration was completely irrelavant for this cache because the ModDetails are pruned from the result. So now it simplifies things a lot to just store the ModIface and Linkable, which we can put into the cache straight away rather than wait for the final version of a HomeModInfo to appear. - - - - - 6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00 cmm: Remove unused ReadOnlyData16 We don't actually emit rodata16 sections anywhere. - - - - - 16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00 findExternalRules: Don't needlessly traverse the list of rules. - - - - - 52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00 Remove backported items from 9.6 release notes They have been backported to 9.4 in commits 5423d84bd9a28f, 13c81cb6be95c5, 67ccbd6b2d4b9b. - - - - - 78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00 ci: Fix pages job The job has been failing because we don't bundle haddock docs anymore in the docs dist created by hadrian. Fixes #21789 - - - - - 037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00 codeGen/X86: Don't clobber switch variable in switch generation Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was safe to clobber the switch variable when generating code for a jump table since we were at the end of a block. However, this assumption is wrong; the register could be live in the jump target. Fixes #21968. - - - - - 50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00 Fix equality operator in jspace test - - - - - e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Improve BUILD_PAP comments - - - - - 41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Make dropTail comment a haddock comment - - - - - ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Add one more sanity check in stg_restore_cccs - - - - - 1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00 StgToCmm: Fix isSimpleScrut when profiling is enabled. When profiling is enabled we must enter functions that might represent thunks in order for their sccs to show up in the profile. We might allocate even if the function is already evaluated in this case. So we can't consider any potential function thunk to be a simple scrut when profiling. Not doing so caused profiled binaries to segfault. - - - - - fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Change `-fprof-late` to insert cost centres after unfolding creation. The former behaviour of adding cost centres after optimization but before unfoldings are created is not available via the flag `prof-late-inline` instead. I also reduced the overhead of -fprof-late* by pushing the cost centres into lambdas. This means the cost centres will only account for execution of functions and not their partial application. Further I made LATE_CC cost centres it's own CC flavour so they now won't clash with user defined ones if a user uses the same string for a custom scc. LateCC: Don't put cost centres inside constructor workers. With -fprof-late they are rarely useful as the worker is usually inlined. Even if the worker is not inlined or we use -fprof-late-linline they are generally not helpful but bloat compile and run time significantly. So we just don't add sccs inside constructor workers. ------------------------- Metric Decrease: T13701 ------------------------- - - - - - f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00 gitlab-ci: Fix hadrian bootstrapping of release pipelines Previously we would attempt to test hadrian bootstrapping in the `validate` build flavour. However, `ci.sh` refuses to run validation builds during release pipelines, resulting in job failures. Fix this by testing bootstrapping in the `release` flavour during release pipelines. We also attempted to record perf notes for these builds, which is redundant work and undesirable now since we no longer build in a consistent flavour. - - - - - c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00 compiler: Eliminate two uses of foldr in favor of foldl' These two uses constructed maps, which is a case where foldl' is generally more efficient since we avoid constructing an intermediate O(n)-depth stack. - - - - - d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00 rts: Fix code style - - - - - 57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00 genprimopcode: Drop ArrayArray# references As ArrayArray# no longer exists - - - - - 7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00 base: Organize Haddocks in GHC.Conc.Sync - - - - - aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00 Add primop to list threads A user came to #ghc yesterday wondering how best to check whether they were leaking threads. We ended up using the eventlog but it seems to me like it would be generally useful if Haskell programs could query their own threads. - - - - - 6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00 rts: Move thread labels into TSO This eliminates the thread label HashTable and instead tracks this information in the TSO, allowing us to use proper StgArrBytes arrays for backing the label and greatly simplifying management of object lifetimes when we expose them to the user with the coming `threadLabel#` primop. - - - - - 1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00 Add a primop to query the label of a thread - - - - - 43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00 base: Share finalization thread label For efficiency's sake we float the thread label assigned to the finalization thread to the top-level, ensuring that we only need to encode the label once. - - - - - 1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00 users-guide: Add release notes entry for thread introspection support - - - - - 09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix binary distribution install attributes Previously we would use plain `cp` to install various parts of the binary distribution. However, `cp`'s behavior w.r.t. file attributes is quite unclear; for this reason it is much better to rather use `install`. Fixes #21965. - - - - - 2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix installation of system-cxx-std-lib package conf - - - - - 7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00 gitlab-ci: Bump Docker images To give the ARMv7 job access to lld, fixing #21875. - - - - - afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Don't use mk/config.mk.in Ultimately we want to drop mk/config.mk so here I extract the bits needed by the Hadrian bindist installation logic into a Hadrian-specific file. While doing this I fixed binary distribution installation, #21901. - - - - - b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Fix naming of cross-compiler wrappers - - - - - 78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00 hadrian: Extend xattr Darwin hack to cover /lib As noted in #21506, it is now necessary to remove extended attributes from `/lib` as well as `/bin` to avoid SIP issues on Darwin. Fixes #21506. - - - - - 20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00 NCG(x86): Compile add+shift as lea if possible. - - - - - 742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00 dataToTag#: Skip runtime tag check if argument is infered tagged This addresses one part of #21710. - - - - - 1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00 rts: remove redundant stg_traceCcszh This out-of-line primop has no Haskell wrapper and hasn't been used anywhere in the tree. Furthermore, the code gets in the way of !7632, so it should be garbage collected. - - - - - a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00 Document a divergence from the report in parsing function lhss. GHC is happy to parse `(f) x y = x + y` when it should be a parse error based on the Haskell report. Seems harmless enough so we won't fix it but it's documented now. Fixes #19788 - - - - - 5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00 gitlab-ci: Add release job for aarch64/debian 11 - - - - - 5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Introduce validation job for aarch64 cross-compilation Begins to address #11958. - - - - - e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00 Bump process submodule - - - - - ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Add basic support for cross-compiler testiing Here we add a simple qemu-based test for cross-compilers. - - - - - 50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00 rts: Ensure that Array# card arrays are initialized In #19143 I noticed that newArray# failed to initialize the card table of newly-allocated arrays. However, embarrassingly, I then only fixed the issue in newArrayArray# and, in so doing, introduced the potential for an integer underflow on zero-length arrays (#21962). Here I fix the issue in newArray#, this time ensuring that we do not underflow in pathological cases. Fixes #19143. - - - - - e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00 testsuite: Add test for #21962 - - - - - c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00 gitlab-ci: Don't use coreutils on Darwin In general we want to ensure that the tested environment is as similar as possible to the environment the user will use. In the case of Darwin, this means we want to use the system's BSD command-line utilities, not coreutils. This would have caught #21974. - - - - - 1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00 hadrian: Fix bindist installation on Darwin It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does. - - - - - 681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00 hadrian: Fix access mode of installed package registration files Previously hadrian's bindist Makefile would modify package registrations placed by `install` via a shell pipeline and `mv`. However, the use of `mv` means that if umask is set then the user may otherwise end up with package registrations which are inaccessible. Fix this by ensuring that the mode is 0644. - - - - - e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00 Cleanups around pretty-printing * Remove hack when printing OccNames. No longer needed since e3dcc0d5 * Remove unused `pprCmms` and `instance Outputable Instr` * Simplify `pprCLabel` (no need to pass platform) * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by ImmLit, but that can take just a String instead. * Remove instance `Outputable CLabel` - proper output of labels needs a platform, and is done by the `OutputableP` instance - - - - - 66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00 rts/linker: Resolve iconv_* on FreeBSD FreeBSD's libiconv includes an implementation of the iconv_* functions in libc. Unfortunately these can only be resolved using dlvsym, which is how the RTS linker usually resolves such functions. To fix this we include an ad-hoc special case for iconv_*. Fixes #20354. - - - - - 5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00 system-cxx-std-lib: Add support for FreeBSD libcxxrt - - - - - ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00 gitlab-ci: Bump to use freebsd13 runners - - - - - d71a2051 by sheaf at 2022-08-09T13:47:28-04:00 Fix size_up_alloc to account for UnliftedDatatypes The size_up_alloc function mistakenly considered any type that isn't lifted to not allocate anything, which is wrong. What we want instead is to check the type isn't boxed. This accounts for (BoxedRep Unlifted). Fixes #21939 - - - - - 76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. - - - - - 7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. - - - - - dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00 Updates language extension documentation Adding a 'Status' field with a few values: - Deprecated - Experimental - InternalUseOnly - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98' Those values are pulled from the existing descriptions or elsewhere in the documentation. While at it, include the :implied by: where appropriate, to provide more detail. Fixes #21475 - - - - - 823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00 hadrian RunRest: add type signature for stageNumber avoids warning seen on 9.4.1: src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults] • Defaulting the following constraints to type ‘Integer’ (Show a0) arising from a use of ‘show’ at src/Settings/Builders/RunTest.hs:264:53-84 (Num a0) arising from a use of ‘stageNumber’ at src/Settings/Builders/RunTest.hs:264:59-83 • In the second argument of ‘(++)’, namely ‘show (stageNumber (C.stage ctx))’ In the second argument of ‘($)’, namely ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’ In the expression: arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | 264 | , arg "-e", arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compilation tested locally - - - - - f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00 Add support for external static plugins (#20964) This patch adds a new command-line flag: -fplugin-library=<file-path>;<unit-id>;<module>;<args> used like this: -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"] It allows a plugin to be loaded directly from a shared library. With this approach, GHC doesn't compile anything for the plugin and doesn't load any .hi file for the plugin and its dependencies. As such GHC doesn't need to support two environments (one for plugins, one for target code), which was the more ambitious approach tracked in #14335. Fix #20964 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Fix ARMv7 build It appears that the CI refactoring carried out in 5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some critical configuration: setting the build/host/target platforms and forcing use of a non-broken linker. - - - - - 596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Run ARMv7 jobs when ~ARM label is used - - - - - 7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00 hadrian: Don't attempt to install documentation if doc/ doesn't exist Previously we would attempt to install documentation even if the `doc` directory doesn't exist (e.g. due to `--docs=none`). This would result in the surprising side-effect of the entire contents of the bindist being installed in the destination documentation directory. Fix this. Fixes #21976. - - - - - 67575f20 by normalcoder at 2022-08-10T15:38:34-04:00 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - - - - - 45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00 Note [Trimming auto-rules]: State that this improves compiler perf. - - - - - 5c24b1b3 by Bodigrim at 2022-08-10T22:41:50-04:00 Document that threadDelay / timeout are susceptible to overflows on 32-bit machines - - - - - ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 Updates haddock submodule - - - - - dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00 Revert "gitlab-ci: Add release job for aarch64/debian 11" This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46. The job was not tested before being merged and fails CI (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392) Ticket #22005 - - - - - ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00 typo - - - - - cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00 CmmToLlvm: Don't aliasify builtin LLVM variables Our aliasification logic would previously turn builtin LLVM variables into aliases, which apparently confuses LLVM. This manifested in initializers failing to be emitted, resulting in many profiling failures with the LLVM backend. Fixes #22019. - - - - - dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00 run_ci: remove monoidal-containers Fixes #21492 MonoidalMap is inlined and used to implement Variables, as before. The top-level value "jobs" is reimplemented as a regular Map, since it doesn't use the monoidal union anyway. - - - - - 64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00 CmmToAsm/AArch64: correct a typo - - - - - f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00 Fix #21979 - compact-share failing with -O I don't have good reason to believe the optimization level should affect if sharing works or not here. So limit the test to the normal way. - - - - - 68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix reference to dead llvm-version substitution Fixes #22052. - - - - - 28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix incorrect reference to `:extension: role - - - - - 71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Add :ghc-flag: reference - - - - - 385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00 hadrian: Place manpage in docroot This relocates it from docs/ to doc/ - - - - - 84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00 Bump haddock submodule Includes merge of `main` into `ghc-head` as well as some Haddock users guide fixes. - - - - - 59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00 base: Add changelog entries from ghc-9.2 Closes #21922. - - - - - a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00 relnotes: Add "included libraries" section As noted in #21988, some users rely on this. - - - - - a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Rephrase the rewrite rule documentation Previously the wording was a tad unclear. Fix this. Closes #21114. - - - - - 3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00 Implement Response File support for HPC This is an improvement to HPC authored by Richard Wallace (https://github.com/purefn) and myself. I have received permission from him to attempt to upstream it. This improvement was originally implemented as a patch to HPC via input-output-hk/haskell.nix: https://github.com/input-output-hk/haskell.nix/pull/1464 Paraphrasing Richard, HPC currently requires all inputs as command line arguments. With large projects this can result in an argument list too long error. I have only seen this error in Nix, but I assume it can occur is a plain Unix environment. This MR adds the standard response file syntax support to HPC. For example you can now pass a file to the command line which contains the arguments. ``` hpc @response_file_1 @response_file_2 ... The contents of a Response File must have this format: COMMAND ... example: report my_library.tix --include=ModuleA --include=ModuleB ``` Updates hpc submodule Co-authored-by: Richard Wallace <rwallace at thewallacepack.net> Fixes #22050 - - - - - 436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00 ghc-heap: Fix decoding of TSO closures An extra field was added to the TSO structure in 6d1700b6 but the decoding logic in ghc-heap was not updated for this new field. Fixes #22046 - - - - - a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00 driver: Honour -x option The -x option is used to manually specify which phase a file should be started to be compiled from (even if it lacks the correct extension). I just failed to implement this when refactoring the driver. In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to preprocess source files using GHC. I added a test to exercise this case. Fixes #22044 - - - - - e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00 Be more careful in chooseInferredQuantifiers This fixes #22065. We were failing to retain a quantifier that was mentioned in the kind of another retained quantifier. Easy to fix. - - - - - 714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00 testsuite: Add test for #21583 - - - - - 989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00 compiler: Drop --build-id=none hack Since 2011 the object-joining implementation has had a hack to pass `--build-id=none` to `ld` when supported, seemingly to work around a linker bug. This hack is now unnecessary and may break downstream users who expect objects to have valid build-ids. Remove it. Closes #22060. - - - - - 519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00 Make ru_fn field strict to avoid retaining Ids It's better to perform this projection from Id to Name strictly so we don't retain an old Id (hence IdInfo, hence Unfolding, hence everything etc) - - - - - 7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force `getOccFS bndr` to avoid retaining reference to Bndr. This is another symptom of #19619 - - - - - 4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force unfoldings when they are cleaned-up in Tidy and CorePrep If these thunks are not forced then the entire unfolding for the binding is live throughout the whole of CodeGen despite the fact it should have been discarded. Fixes #22071 - - - - - 2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00 haddock docs: Fix links from identifiers to dependent packages When implementing the base_url changes I made the pretty bad mistake of zipping together two lists which were in different orders. The simpler thing to do is just modify `haddockDependencies` to also return the package identifier so that everything stays in sync. Fixes #22001 - - - - - 9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00 Revert "Refactor SpecConstr to use treat bindings uniformly" This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729. This refactoring introduced quite a severe residency regression (900MB live from 650MB live when compiling mmark), see #21993 for a reproducer and more discussion. Ticket #21993 - - - - - 9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00 tc: warn about lazy annotations on unlifted arguments (fixes #21951) - - - - - e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00 Fix #22048 where we failed to drop rules for -fomit-interface-pragmas. Now we also filter the local rules (again) which fixes the issue. - - - - - 51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00 Print constraints in quotes (#21167) This patch improves the uniformity of error message formatting by printing constraints in quotes, as we do for types. Fix #21167 - - - - - ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00 19217 Implicitly quantify type variables in :kind command - - - - - 9939e95f by MorrowM at 2022-08-21T16:51:38-04:00 Recognize file-header pragmas in GHCi (#21507) - - - - - fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00 hadrian: Fix bootstrapping with ghc-9.4 The error was that we were trying to link together containers from boot package library (which depends template-haskell in boot package library) template-haskell from in-tree package database So the fix is to build containers in stage0 (and link against template-haskell built in stage0). Fixes #21981 - - - - - b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00 Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942. * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence * `ParensT` constructor is now always printed parenthesized * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down * using `>=` instead of former `>` to match the Core type printing logic * some test outputs have changed, losing extraneous parentheses - - - - - fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00 Fix and test for issue #21723 - - - - - 33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00 Test for issue #21942 - - - - - c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00 Updated the changelog - - - - - 80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00 hadrian: Don't duplicate binaries on installation Previously we used `install` on symbolic links, which ended up copying the target file rather than installing a symbolic link. Fixes #22062. - - - - - b929063e by M Farkas-Dyck at 2022-08-24T02:37:01-04:00 Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`. Closes #22092. - - - - - 112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00 driver: don't actually merge objects when ar -L works - - - - - a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00 rts: Consistently use MiB in stats output Previously we would say `MB` even where we meant `MiB`. - - - - - a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694, #21755. It also makes sure that #21948 and fix to #21694. * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * To make "no free join points in arityType" work out I had to avoid trying to use eta-expansion for runRW#. This entailed a few changes in the Simplifier's treatment of runRW#. See GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#] * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * Rewrote Note [Combining case branches: optimistic one-shot-ness] * arityType previously treated join points differently to other let-bindings. This patch makes them unform; arityType analyses the RHS of all bindings to get its ArityType, and extends am_sigs. I realised that, now we have am_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. * And finally, it was the strange treatment of join-point Ids in arityType (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring, which treats them uniformly; but without breaking #18328. In fact, the arity for recursive join bindings is pretty tricky; see the long Note [Arity for recursive join bindings] in GHC.Core.Opt.Simplify.Utils. That led to more refactoring, including deciding that an Id could have an Arity that is bigger than its JoinArity; see Note [Invariants on join points], item 2(b) in GHC.Core * Make sure that the "demand threshold" for join points in DmdAnal is no bigger than the join-arity. In GHC.Core.Opt.DmdAnal see Note [Demand signatures are computed for a threshold arity based on idArity] * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity, where it more properly belongs. * Remove an old, redundant hack in FloatOut. The old Note was Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels. Compile time improves very slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- T18223(normal) ghc/alloc 725,808,720 747,839,216 +3.0% BAD T6048(optasm) ghc/alloc 105,006,104 101,599,472 -3.2% GOOD geo. mean -0.2% minimum -3.2% maximum +3.0% For some reason Windows was better T10421(normal) ghc/alloc 125,888,360 124,129,168 -1.4% GOOD T18140(normal) ghc/alloc 85,974,520 83,884,224 -2.4% GOOD T18698b(normal) ghc/alloc 236,764,568 234,077,288 -1.1% GOOD T18923(normal) ghc/alloc 75,660,528 73,994,512 -2.2% GOOD T6048(optasm) ghc/alloc 112,232,512 108,182,520 -3.6% GOOD geo. mean -0.6% I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3% increase in exchange for goodness elsewhere. Metric Decrease: T10421 T18140 T18698b T18923 T6048 Metric Increase: T18223 - - - - - 909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00 upload_ghc_libs: Add means of passing Hackage credentials - - - - - 28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00 Scrub some partiality in `CommonBlockElim`. - - - - - 54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00 hadrian: Fix whitespace Previously this region of Settings.Packages was incorrectly indented. - - - - - c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00 validate: Drop --legacy flag In preparation for removal of the legacy `make`-based build system. - - - - - 822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00 gitlab-ci: Drop make build validation jobs In preparation for removal of the `make`-based build system - - - - - 6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop make build system Here we at long last remove the `make`-based build system, it having been replaced with the Shake-based Hadrian build system. Users are encouraged to refer to the documentation in `hadrian/doc` and this [1] blog post for details on using Hadrian. Closes #17527. [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html - - - - - dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00 Remove testsuite/tests/perf/haddock/.gitignore As noted in #16802, this is no longer needed. Closes #16802. - - - - - fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop hc-build script This has not worked for many, many years and relied on the now-removed `make`-based build system. - - - - - 659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mkdirhier This is only used by nofib's dead `dist` target - - - - - 4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mk/{build,install,config}.mk.in - - - - - 46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00 compiler: Drop comment references to make - - - - - d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add inits1 and tails1 to Data.List.NonEmpty See https://github.com/haskell/core-libraries-committee/issues/67 - - - - - 8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add since annotations and changelog entries - - - - - 6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00 Fix redundant import This fixes a build error on x86_64-linux-alpine3_12-validate. See the function 'loadExternalPlugins' defined in this file. - - - - - 4786acf7 by sheaf at 2022-08-26T15:05:23-04:00 Pmc: consider any 2 dicts of the same type equal This patch massages the keys used in the `TmOracle` `CoreMap` to ensure that dictionaries of coherent classes give the same key. That is, whenever we have an expression we want to insert or lookup in the `TmOracle` `CoreMap`, we first replace any dictionary `$dict_abcd :: ct` with a value of the form `error @ct`. This allows us to common-up view pattern functions with required constraints whose arguments differed only in the uniques of the dictionaries they were provided, thus fixing #21662. This is a rather ad-hoc change to the keys used in the `TmOracle` `CoreMap`. In the long run, we would probably want to use a different representation for the keys instead of simply using `CoreExpr` as-is. This more ambitious plan is outlined in #19272. Fixes #21662 Updates unix submodule - - - - - f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00 Remove label style from printing context Previously, the SDocContext used for code generation contained information whether the labels should use Asm or C style. However, at every individual call site, this is known statically. This removes the parameter to 'PprCode' and replaces every 'pdoc' used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'. The OutputableP instance is now used only for dumps. The output of T15155 changes, it now uses the Asm style (which is faithful to what actually happens). - - - - - 1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00 boot: cleanup legacy args Cleanup legacy boot script args, following removal of the legacy make build system. - - - - - 95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00 Improve SpecConstr for evals As #21763 showed, we were over-specialising in some cases, when the function involved was doing a simple 'eval', but not taking the value apart, or branching on it. This MR fixes the problem. See Note [Do not specialise evals]. Nofib barely budges, except that spectral/cichelli allocates about 3% less. Compiler bytes-allocated improves a bit geo. mean -0.1% minimum -0.5% maximum +0.0% The -0.5% is on T11303b, for what it's worth. - - - - - 565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Revert "Revert "Refactor SpecConstr to use treat bindings uniformly"" This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8. This commit was originally reverted due to an increase in space usage. This was diagnosed as because the SCE increased in size and that was being retained by another leak. See #22102 - - - - - 82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Avoid retaining bindings via ModGuts held on the stack It's better to overwrite the bindings fields of the ModGuts before starting an iteration as then all the old bindings can be collected as soon as the simplifier has processed them. Otherwise we end up with the old bindings being alive until right at the end of the simplifier pass as the mg_binds field is only modified right at the end. - - - - - 64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00 Force imposs_deflt_cons in filterAlts This fixes a pretty serious space leak as the forced thunk would retain `Alt b` values which would then contain reference to a lot of old bindings and other simplifier gunk. The OtherCon unfolding was not forced on subsequent simplifier runs so more and more old stuff would be retained until the end of simplification. Fixing this has a drastic effect on maximum residency for the mmark package which goes from ``` 45,005,401,056 bytes allocated in the heap 17,227,721,856 bytes copied during GC 818,281,720 bytes maximum residency (33 sample(s)) 9,659,144 bytes maximum slop 2245 MiB total memory in use (0 MB lost due to fragmentation) ``` to ``` 45,039,453,304 bytes allocated in the heap 13,128,181,400 bytes copied during GC 331,546,608 bytes maximum residency (40 sample(s)) 7,471,120 bytes maximum slop 916 MiB total memory in use (0 MB lost due to fragmentation) ``` See #21993 for some more discussion. - - - - - a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Use Solo to avoid retaining the SCE but to avoid performing the substitution The use of Solo here allows us to force the selection into the SCE to obtain the Subst but without forcing the substitution to be applied. The resulting thunk is placed into a lazy field which is rarely forced, so forcing it regresses peformance. - - - - - 161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00 Fix a nasty loop in Tidy As the remarkably-simple #22112 showed, we were making a black hole in the unfolding of a self-recursive binding. Boo! It's a bit tricky. Documented in GHC.Iface.Tidy, Note [tidyTopUnfolding: avoiding black holes] - - - - - 68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnIllegalHsigDefaultMethods TcRnBadGenericMethod TcRnWarningMinimalDefIncomplete TcRnDefaultMethodForPragmaLacksBinding TcRnIgnoreSpecialisePragmaOnDefMethod TcRnBadMethodErr TcRnNoExplicitAssocTypeOrDefaultDeclaration - - - - - cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00 Fix a bug in anyInRnEnvR This bug was a subtle error in anyInRnEnvR, introduced by commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06 Author: Andreas Klebinger <klebinger.andreas at gmx.at> Date: Sat Jul 9 01:19:52 2022 +0200 Rule matching: Don't compute the FVs if we don't look at them. The net result was #22028, where a rewrite rule would wrongly match on a lambda. The fix to that function is easy. - - - - - 0154bc80 by sheaf at 2022-08-30T06:05:41-04:00 Various Hadrian bootstrapping fixes - Don't always produce a distribution archive (#21629) - Use correct executable names for ghc-pkg and hsc2hs on windows (we were missing the .exe file extension) - Fix a bug where we weren't using the right archive format on Windows when unpacking the bootstrap sources. Fixes #21629 - - - - - 451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00 ci: Attempt using normal submodule cloning strategy We do not use any recursively cloned submodules, and this protects us from flaky upstream remotes. Fixes #22121 - - - - - 9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: stray "--" - - - - - 3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: syntatic -> syntactic - - - - - 7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00 Add a missing trimArityType This buglet was exposed by #22114, a consequence of my earlier refactoring of arity for join points. - - - - - e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump binary submodule to 0.8.9.1 - - - - - 4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump stm submodule to 2.5.1.0 - - - - - 837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00 users-guide: Document system-cxx-std-lib - - - - - f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00 Update submodule containers to 0.6.6 - - - - - 4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00 Update submodule process to 1.6.15.0 - - - - - 1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00 Bump directory submodule to 1.3.7.1 - - - - - 7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00 Bump text submodule to 2.0.1 - - - - - fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00 Bump deepseq submodule to 1.4.8.0 - - - - - a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00 Add dates to base, ghc-prim changelogs - - - - - 2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00 Update autoconf scripts Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983 - - - - - e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00 Bump bytestring submodule to 0.11.3.1 - - - - - f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00 Update submodule Cabal to tag Cabal-v3.8.1.0 closes #21931 - - - - - e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00 Refine in-tree compiler args for --test-compiler=stage1 Some of the logic to calculate in-tree arguments was not correct for the stage1 compiler. Namely we were not correctly reporting whether we were building static or dynamic executables and whether debug assertions were enabled. Fixes #22096 - - - - - 6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00 Make ghcDebugAssertions into a Stage predicate (Stage -> Bool) We also care whether we have debug assertions enabled for a stage one compiler, but the way which we turned on the assertions was quite different from the stage2 compiler. This makes the logic for turning on consistent across both and has the advantage of being able to correct determine in in-tree args whether a flavour enables assertions or not. Ticket #22096 - - - - - 15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00 Add regression test for #21550 This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5 "Use local instances with least superclass depth" - - - - - 7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00 Minor cleanup - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused), isCoVar_maybe (duplicated by getCoVar_maybe) - Replace a few occurrences of voidPrimId with (# #). void# is a deprecated synonym for the unboxed tuple. - Use showSDoc in :show linker. This makes it consistent with the other :show commands - - - - - 31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - 7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00 Fix bootstrap with ghc-9.0 It turns out Solo is a very recent addition to base, so for older GHC versions we just defined it inline here the one place we use it in the compiler. - - - - - d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00 DmdAnal: Don't panic in addCaseBndrDmd (#22039) Rather conservatively return Top. See Note [Untyped demand on case-alternative binders]. I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and `fieldBndrDmds`. Fixes #22039. - - - - - 25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00 gitlab-ci: Ensure that ghc derivation is in scope Previously the lint-ci job attempted to use cabal-install (specifically `cabal update`) without a GHC in PATH. However, cabal-install-3.8 appears to want GHC, even for `cabal update`. - - - - - f37b621f by sheaf at 2022-09-06T11:51:53+00:00 Update instances.rst, clarifying InstanceSigs Fixes #22103 - - - - - d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00 Fix :add docs in user guide - - - - - 808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00 ci: remove unused build_make/test_make in ci script - - - - - d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00 typo - - - - - fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00 typos - - - - - a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00 whitespace - - - - - 04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Minor SDoc cleanup Change calls to renderWithContext with showSDocOneLine; it's more efficient and explanatory. Remove polyPatSig (unused) - - - - - 7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Remove Outputable Char instance Use 'text' instead of 'ppr'. Using 'ppr' on the list "hello" rendered as "h,e,l,l,o". - - - - - 77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Export liftA2 from Prelude Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details. - - - - - 442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Add changelog entry for liftA2 export from Prelude - - - - - fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule containers to one with liftA2 warnings fixed - - - - - f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule Cabal to one with liftA2 warnings fixed - - - - - a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Isolate some Applicative hidings to GHC.Prelude By reexporting the entirety of Applicative from GHC.Prelude, we can save ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude. This also has the benefit of isolating this type of change to GHC.Prelude, so that people in the future don't have to think about it. - - - - - 9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00 CmmToC: enable 64-bit CallishMachOp on 32-bit targets Normally, the unregisterised builds avoid generating 64-bit CallishMachOp in StgToCmm, so CmmToC doesn't support these. However, there do exist cases where we'd like to invoke cmmToC for other cmm inputs which may contain such CallishMachOps, and it's a rather low effort to add support for these since they only require calling into existing ghc-prim cbits. - - - - - 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by M Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00 base: make Foreign.Marshal.Pool use RTS internal arena for allocation `Foreign.Marshal.Pool` used to call `malloc` once for each allocation request. Each `Pool` maintained a list of allocated pointers, and traverses the list to `free` each one of those pointers. The extra O(n) overhead is apparently bad for a `Pool` that serves a lot of small allocation requests. This patch uses the RTS internal arena to implement `Pool`, with these benefits: - Gets rid of the extra O(n) overhead. - The RTS arena is simply a bump allocator backed by the block allocator, each allocation request is likely faster than a libc `malloc` call. Closes #14762 #18338. - - - - - 37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00 Misc cleanup * Replace catMaybes . map f with mapMaybe f * Use concatFS to concatenate multiple FastStrings * Fix documentation of -exclude-module * Cleanup getIgnoreCount in GHCi.UI - - - - - b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00 Give better errors for code corrupted by Unicode smart quotes (#21843) Previously, we emitted a generic and potentially confusing error during lexical analysis on programs containing smart quotes (“/”/‘/’). This commit adds smart quote-aware lexer errors. - - - - - cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00 Make T21839c's ghc/max threshold more forgiving - - - - - 4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00 Be more careful when reporting unbound RULE binders See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds. Fixes #22471. - - - - - e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00 PPC NCG: Fix generating assembler code Fixes #22479 - - - - - f2f9ef07 by Bodigrim at 2022-11-20T18:39:30-05:00 Extend documentation for Data.IORef - - - - - ef511b23 by Simon Peyton Jones at 2022-11-20T18:40:05-05:00 Buglet in GHC.Tc.Module.checkBootTyCon This lurking bug used the wrong function to compare two types in GHC.Tc.Module.checkBootTyCon It's hard to trigger the bug, which only came up during !9343, so there's no regression test in this MR. - - - - - 451aeac3 by Bodigrim at 2022-11-20T18:40:44-05:00 Add since pragmas for c_interruptible_open and hostIsThreaded - - - - - 8d6aaa49 by Duncan Coutts at 2022-11-22T02:06:16-05:00 Introduce CapIOManager as the per-cap I/O mangager state Rather than each I/O manager adding things into the Capability structure ad-hoc, we should have a common CapIOManager iomgr member of the Capability structure, with a common interface to initialise etc. The content of the CapIOManager struct will be defined differently for each I/O manager implementation. Eventually we should be able to have the CapIOManager be opaque to the rest of the RTS, and known just to the I/O manager implementation. We plan for that by making the Capability contain a pointer to the CapIOManager rather than containing the structure directly. Initially just move the Unix threaded I/O manager's control FD. - - - - - 8901285e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Add hook markCapabilityIOManager To allow I/O managers to have GC roots in the Capability, within the CapIOManager structure. Not yet used in this patch. - - - - - 5cf709c5 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move APPEND_TO_BLOCKED_QUEUE from cmm to C The I/O and delay blocking primitives for the non-threaded way currently access the blocked_queue and sleeping_queue directly. We want to move where those queues are to make their ownership clearer: to have them clearly belong to the I/O manager impls rather than to the scheduler. Ultimately we will want to change their representation too. It's inconvenient to do that if these queues are accessed directly from cmm code. So as a first step, replace the APPEND_TO_BLOCKED_QUEUE with a C version appendToIOBlockedQueue(), and replace the open-coded sleeping_queue insertion with insertIntoSleepingQueue(). - - - - - ced9acdb by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move {blocked,sleeping}_queue from scheduler global vars to CapIOManager The blocked_queue_{hd,tl} and the sleeping_queue are currently cooperatively managed between the scheduler and (some but not all of) the non-threaded I/O manager implementations. They lived as global vars with the scheduler, but are poked by I/O primops and the I/O manager backends. This patch is a step on the path towards making the management of I/O or timer blocking belong to the I/O managers and not the scheduler. Specifically, this patch moves the {blocked,sleeping}_queue from being global vars in the scheduler to being members of the CapIOManager struct within each Capability. They are not yet exclusively used by the I/O managers: they are still poked from a couple other places, notably in the scheduler before calling awaitEvent. - - - - - 0f68919e by Duncan Coutts at 2022-11-22T02:06:17-05:00 Remove the now-unused markScheduler The global vars {blocked,sleeping}_queue are now in the Capability and so get marked there via markCapabilityIOManager. - - - - - 39a91f60 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move macros for checking for pending IO or timers from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler. - - - - - 664b034b by Duncan Coutts at 2022-11-22T02:06:17-05:00 Replace EMPTY_{BLOCKED,SLEEPING}_QUEUE macros by function These are the macros originaly from Scheduler.h, previously moved to IOManager.h, and now replaced with a single inline function anyPendingTimeoutsOrIO(). We can use a single function since the two macros were always checked together. Note that since anyPendingTimeoutsOrIO is defined for all IO manager cases, including threaded, we do not need to guard its use by cpp #if !defined(THREADED_RTS) - - - - - 32946220 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Expand emptyThreadQueues inline for clarity It was not really adding anything. The name no longer meant anything since those I/O and timeout queues do not belong to the scheuler. In one of the two places it was used, the comments already had to explain what it did, whereas now the code matches the comment nicely. - - - - - 9943baf9 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Move the awaitEvent declaration into IOManager.h And add or adjust comments at the use sites of awaitEvent. - - - - - 054dcc9d by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to awaitEvent It is currently only used in the non-threaded RTS so it works to use MainCapability, but it's a bit nicer to pass the cap anyway. It's certainly shorter. - - - - - 667fe5a4 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Pass the Capability *cap explicitly to appendToIOBlockedQueue And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS. - - - - - 7181b074 by Duncan Coutts at 2022-11-22T02:06:17-05:00 Reveiew feedback: improve one of the TODO comments The one about the nonsense (const False) test on WinIO for there being any IO or timers pending, leading to unnecessary complication later in the scheduler. - - - - - e5b68183 by Andreas Klebinger at 2022-11-22T02:06:52-05:00 Optimize getLevity. Avoid the intermediate data structures allocated by splitTyConApp. This avoids ~0.5% of allocations for a build using -O2. Fixes #22254 - - - - - de5fb348 by Andreas Klebinger at 2022-11-22T02:07:28-05:00 hadrian:Set TNTC when running testsuite. - - - - - 9d61c182 by Oleg Grenrus at 2022-11-22T15:59:34-05:00 Add unsafePtrEquality# restricted to UnliftedTypes - - - - - e817c871 by Jonathan Dowland at 2022-11-22T16:00:14-05:00 utils/unlit: adjust parser to match Report spec The Haskell 2010 Report says that, for Latex-style Literate format, "Program code begins on the first line following a line that begins \begin{code}". (This is unchanged from the 98 Report) However the unlit.c implementation only matches a line that contains "\begin{code}" and nothing else. One consequence of this is that one cannot suffix Latex options to the code environment. I.e., this does not work: \begin{code}[label=foo,caption=Foo Code] Adjust the matcher to conform to the specification from the Report. The Haskell Wiki currently recommends suffixing a '%' to \begin{code} in order to deliberately hide a code block from Haskell. This is bad advice, as it's relying on an implementation quirk rather than specified behaviour. None-the-less, some people have tried to use it, c.f. <https://mail.haskell.org/pipermail/haskell-cafe/2009-September/066780.html> An alternative solution is to define a separate, equivalent Latex environment to "code", that is functionally identical in Latex but ignored by unlit. This should not be a burden: users are required to manually define the code environment anyway, as it is not provided by the Latex verbatim or lstlistings packages usually used for presenting code in documents. Fixes #3549. - - - - - 0b7fef11 by Teo Camarasu at 2022-11-23T12:44:33-05:00 Fix eventlog all option Previously it didn't enable/disable nonmoving_gc and ticky event types Fixes #21813 - - - - - 04d0618c by Arnaud Spiwack at 2022-11-23T12:45:14-05:00 Expand Note [Linear types] with the stance on linting linearity Per the discussion on #22123 - - - - - e1538516 by Lawton Nichols at 2022-11-23T12:45:55-05:00 Add documentation on custom Prelude modules (#22228) Specifically, custom Prelude modules that are named `Prelude`. - - - - - b5c71454 by Sylvain Henry at 2022-11-23T12:46:35-05:00 Don't let configure perform trivial substitutions (#21846) Hadrian now performs substitutions, especially to generate .cabal files from .cabal.in files. Two benefits: 1. We won't have to re-configure when we modify thing.cabal.in. Hadrian will take care of this for us. 2. It paves the way to allow the same package to be configured differently by Hadrian in the same session. This will be useful to fix #19174: we want to build a stage2 cross-compiler for the host platform and a stage1 compiler for the cross target platform in the same Hadrian session. - - - - - 99aca26b by nineonine at 2022-11-23T12:47:11-05:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 040bfdc3 by M Farkas-Dyck at 2022-11-23T21:59:03-05:00 Scrub some no-warning pragmas. - - - - - 178c1fd8 by Vladislav Zavialov at 2022-11-23T21:59:39-05:00 Check if the SDoc starts with a single quote (#22488) This patch fixes pretty-printing of character literals inside promoted lists and tuples. When we pretty-print a promoted list or tuple whose first element starts with a single quote, we want to add a space between the opening bracket and the element: '[True] -- ok '[ 'True] -- ok '['True] -- not ok If we don't add the space, we accidentally produce a character literal '['. Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST and tried to guess if it would be rendered with a single quote. However, it missed the case when the inner type was itself a character literal: '[ 'x'] -- ok '['x'] -- not ok Instead of adding this particular case, I opted for a more future-proof solution: check the SDoc directly. This way we can detect if the single quote is actually there instead of trying to predict it from the AST. The new function is called spaceIfSingleQuote. - - - - - 11627c42 by Matthew Pickering at 2022-11-23T22:00:15-05:00 notes: Fix references to HPT space leak note Updating this note was missed when updating the HPT to the HUG. Fixes #22477 - - - - - 86ff1523 by Andrei Borzenkov at 2022-11-24T17:24:51-05:00 Convert diagnostics in GHC.Rename.Expr to proper TcRnMessage (#20115) Problem: avoid usage of TcRnMessageUnknown Solution: The following `TcRnMessage` messages has been introduced: TcRnNoRebindableSyntaxRecordDot TcRnNoFieldPunsRecordDot TcRnIllegalStaticExpression TcRnIllegalStaticFormInSplice TcRnListComprehensionDuplicateBinding TcRnEmptyStmtsGroup TcRnLastStmtNotExpr TcRnUnexpectedStatementInContext TcRnIllegalTupleSection TcRnIllegalImplicitParameterBindings TcRnSectionWithoutParentheses Co-authored-by: sheaf <sam.derbyshire at gmail.com> - - - - - d198a19a by Cheng Shao at 2022-11-24T17:25:29-05:00 rts: fix missing Arena.h symbols in RtsSymbols.c It was an unfortunate oversight in !8961 and broke devel2 builds. - - - - - 5943e739 by Bodigrim at 2022-11-25T04:38:28-05:00 Assorted fixes to avoid Data.List.{head,tail} - - - - - 1f1b99b8 by sheaf at 2022-11-25T04:38:28-05:00 Review suggestions for assorted fixes to avoid Data.List.{head,tail} - - - - - 13d627bb by Vladislav Zavialov at 2022-11-25T04:39:04-05:00 Print unticked promoted data constructors (#20531) Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi at wzrd.ht> - - - - - d10dc6bd by Simon Peyton Jones at 2022-11-25T22:31:27+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 2da5c38a by Will Hawkins at 2022-11-26T04:05:04-05:00 Redirect output of musttail attribute test Compilation output from test for support of musttail attribute leaked to the console. - - - - - 0eb1c331 by Cheng Shao at 2022-11-28T08:55:53+00:00 Move hs_mulIntMayOflo cbits to ghc-prim It's only used by wasm NCG at the moment, but ghc-prim is a more reasonable place for hosting out-of-line primops. Also, we only need a single version of hs_mulIntMayOflo. - - - - - 36b53a9d by Cheng Shao at 2022-11-28T09:05:57+00:00 compiler: generate ccalls for clz/ctz/popcnt in wasm NCG We used to generate a single wasm clz/ctz/popcnt opcode, but it's wrong when it comes to subwords, so might as well generate ccalls for them. See #22470 for details. - - - - - d4134e92 by Cheng Shao at 2022-11-28T23:48:14-05:00 compiler: remove unused MO_U_MulMayOflo We actually only emit MO_S_MulMayOflo and never emit MO_U_MulMayOflo anywhere. - - - - - 8d15eadc by Apoorv Ingle at 2022-11-29T03:09:31-05:00 Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order Fixes: #217093 Associated to #19415 This change * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero; * Removes `cc_fundeps` in CDictCan as the check was incomplete; * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities * Adds 2 new tests for validating the change - testsuites/typecheck/should_compile/T21703.hs and - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs) * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors * Changes in Notes: - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances] - Added Note [Kind Equality Orientation] to visualize the kind flipping - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties] - - - - - 646969d4 by Krzysztof Gogolewski at 2022-11-29T03:10:13-05:00 Change printing of sized literals to match the proposal Literals in Core were printed as e.g. 0xFF#16 :: Int16#. The proposal 451 now specifies syntax 0xFF#Int16. This change affects the Core printer only - more to be done later. Part of #21422. - - - - - 02e282ec by Simon Peyton Jones at 2022-11-29T03:10:48-05:00 Be a bit more selective about floating bottoming expressions This MR arranges to float a bottoming expression to the top only if it escapes a value lambda. See #22494 and Note [Floating to the top] in SetLevels. This has a generally beneficial effect in nofib +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || -0.93% | | imaginary/rfib || -0.05% | | real/fem || -0.03% | | real/fluid || -0.01% | | real/fulsom || +0.05% | | real/gamteb || -0.27% | | real/gg || -0.10% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/scs || -11.13% | | shootout/k-nucleotide || -0.01% | | shootout/n-body || -0.08% | | shootout/reverse-complement || -0.00% | | shootout/spectral-norm || -0.02% | | spectral/fibheaps || -0.20% | | spectral/hartel/fft || -1.04% | | spectral/hartel/solid || +0.33% | | spectral/hartel/wave4main || -0.35% | | spectral/mate || +0.76% | +===============================++==========+ | geom mean || -0.12% | The effect on compile time is generally slightly beneficial Metrics: compile_time/bytes allocated ---------------------------------------------- MultiLayerModulesTH_OneShot(normal) +0.3% PmSeriesG(normal) -0.2% PmSeriesT(normal) -0.1% T10421(normal) -0.1% T10421a(normal) -0.1% T10858(normal) -0.1% T11276(normal) -0.1% T11303b(normal) -0.2% T11545(normal) -0.1% T11822(normal) -0.1% T12150(optasm) -0.1% T12234(optasm) -0.3% T13035(normal) -0.2% T16190(normal) -0.1% T16875(normal) -0.4% T17836b(normal) -0.2% T17977(normal) -0.2% T17977b(normal) -0.2% T18140(normal) -0.1% T18282(normal) -0.1% T18304(normal) -0.2% T18698a(normal) -0.1% T18923(normal) -0.1% T20049(normal) -0.1% T21839r(normal) -0.1% T5837(normal) -0.4% T6048(optasm) +3.2% BAD T9198(normal) -0.2% T9630(normal) -0.1% TcPlugin_RewritePerf(normal) -0.4% hard_hole_fits(normal) -0.1% geo. mean -0.0% minimum -0.4% maximum +3.2% The T6048 outlier is hard to pin down, but it may be the effect of reading in more interface files definitions. It's a small program for which compile time is very short, so I'm not bothered about it. Metric Increase: T6048 - - - - - ab23dc5e by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Mark unpack_sums_6 as fragile due to #22504 This test is explicitly dependent upon runtime, which is generally not appropriate given that the testsuite is run in parallel and generally saturates the CPU. - - - - - def47dd3 by Ben Gamari at 2022-11-29T03:11:25-05:00 testsuite: Don't use grep -q in unpack_sums_7 `grep -q` closes stdin as soon as it finds the pattern it is looking for, resulting in #22484. - - - - - cc25d52e by Sylvain Henry at 2022-11-29T09:44:31+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump array submodule Work funded by IOG. Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 68c966cd by sheaf at 2022-11-30T09:31:25-05:00 Fix @since annotations on WithDict and Coercible Fixes #22453 - - - - - a3a8e9e9 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Be more careful in GHC.Tc.Solver.Interact.solveOneFromTheOther We were failing to account for the cc_pend_sc flag in this important function, with the result that we expanded superclasses forever. Fixes #22516. - - - - - a9d9b8c0 by Simon Peyton Jones at 2022-11-30T09:32:03-05:00 Use mkNakedFunTy in tcPatSynSig As #22521 showed, in tcPatSynSig we make a "fake type" to kind-generalise; and that type has unzonked type variables in it. So we must not use `mkFunTy` (which checks FunTy's invariants) via `mkPhiTy` when building this type. Instead we need to use `mkNakedFunTy`. Easy fix. - - - - - 31462d98 by Andreas Klebinger at 2022-11-30T14:50:58-05:00 Properly cast values when writing/reading unboxed sums. Unboxed sums might store a Int8# value as Int64#. This patch makes sure we keep track of the actual value type. See Note [Casting slot arguments] for the details. - - - - - 10a2a7de by Oleg Grenrus at 2022-11-30T14:51:39-05:00 Move Void to GHC.Base... This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files. - - - - - b4cfa8e2 by Sebastian Graf at 2022-11-30T14:52:24-05:00 DmdAnal: Reflect the `seq` of strict fields of a DataCon worker (#22475) See the updated `Note [Data-con worker strictness]` and the new `Note [Demand transformer for data constructors]`. Fixes #22475. - - - - - d87f28d8 by Baldur Blöndal at 2022-11-30T21:16:36+01:00 Make Functor a quantified superclass of Bifunctor. See https://github.com/haskell/core-libraries-committee/issues/91 for discussion. This change relates Bifunctor with Functor by requiring second = fmap. Moreover this change is a step towards unblocking the major version bump of bifunctors and profunctors to major version 6. This paves the way to move the Profunctor class into base. For that Functor first similarly becomes a superclass of Profunctor in the new major version 6. - - - - - 72cf4c5d by doyougnu at 2022-12-01T12:36:44-05:00 FastString: SAT bucket_match Metric Decrease: MultiLayerModulesTH_OneShot - - - - - afc2540d by Simon Peyton Jones at 2022-12-01T12:37:20-05:00 Add a missing varToCoreExpr in etaBodyForJoinPoint This subtle bug showed up when compiling a library with 9.4. See #22491. The bug is present in master, but it is hard to trigger; the new regression test T22491 fails in 9.4. The fix was easy: just add a missing varToCoreExpr in etaBodyForJoinPoint. The fix is definitely right though! I also did some other minor refatoring: * Moved the preInlineUnconditionally test in simplExprF1 to before the call to joinPointBinding_maybe, to avoid fruitless eta-expansion. * Added a boolean from_lam flag to simplNonRecE, to avoid two fruitless tests, and commented it a bit better. These refactorings seem to save 0.1% on compile-time allocation in perf/compiler; with a max saving of 1.4% in T9961 Metric Decrease: T9961 - - - - - 81eeec7f by M Farkas-Dyck at 2022-12-01T12:37:56-05:00 CI: Forbid the fully static build on Alpine to fail. To do so, we mark some tests broken in this configuration. - - - - - c5d1bf29 by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Remove ARMv7 jobs These jobs fail (and are allowed to fail) nearly every time. Soon they won't even be able to run at all, as we won't currently have runners that can run them. Fixing the latter problem is tracked in #22409. I went ahead and removed all settings and configurations. - - - - - d82992fd by Bryan Richter at 2022-12-01T12:37:56-05:00 CI: Fix CI lint Failure was introduced by conflicting changes to gen_ci.hs that did *not* trigger git conflicts. - - - - - ce126993 by Simon Peyton Jones at 2022-12-02T01:22:12-05:00 Refactor TyCon to have a top-level product This patch changes the representation of TyCon so that it has a top-level product type, with a field that gives the details (newtype, type family etc), #22458. Not much change in allocation, but execution seems to be a bit faster. Includes a change to the haddock submodule to adjust for API changes. - - - - - 74c767df by Matthew Pickering at 2022-12-02T01:22:48-05:00 ApplicativeDo: Set pattern location before running exhaustiveness checker This improves the error messages of the exhaustiveness checker when checking statements which have been moved around with ApplicativeDo. Before: Test.hs:2:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 2 | let x = () | ^^^^^^^^^^ After: Test.hs:4:3: warning: [GHC-62161] [-Wincomplete-uni-patterns] Pattern match(es) are non-exhaustive In a pattern binding: Patterns of type ‘Maybe ()’ not matched: Nothing | 4 | ~(Just res1) <- seq x (pure $ Nothing @()) | Fixes #22483 - - - - - 85ecc1a0 by Matthew Pickering at 2022-12-02T19:46:43-05:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 108c319f by Krzysztof Gogolewski at 2022-12-02T19:47:18-05:00 Fix linearity checking in Lint Lint was not able to see that x*y <= x*y, because this inequality was decomposed to x <= x*y && y <= x*y, but there was no rule to see that x <= x*y. Fixes #22546. - - - - - bb674262 by Bryan Richter at 2022-12-03T04:38:46-05:00 Mark T16916 fragile See https://gitlab.haskell.org/ghc/ghc/-/issues/16966 - - - - - 5d267d46 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 Refactor: FreshOrReuse instead of addTyClTyVarBinds This is a refactoring that should have no effect on observable behavior. Prior to this change, GHC.HsToCore.Quote contained a few closely related functions to process type variable bindings: addSimpleTyVarBinds, addHsTyVarBinds, addQTyVarBinds, and addTyClTyVarBinds. We can classify them by their input type and name generation strategy: Fresh names only Reuse bound names +---------------------+-------------------+ [Name] | addSimpleTyVarBinds | | [LHsTyVarBndr flag GhcRn] | addHsTyVarBinds | | LHsQTyVars GhcRn | addQTyVarBinds | addTyClTyVarBinds | +---------------------+-------------------+ Note how two functions are missing. Because of this omission, there were two places where a LHsQTyVars value was constructed just to be able to pass it to addTyClTyVarBinds: 1. mk_qtvs in addHsOuterFamEqnTyVarBinds -- bad 2. mkHsQTvs in repFamilyDecl -- bad This prevented me from making other changes to LHsQTyVars, so the main goal of this refactoring is to get rid of those workarounds. The most direct solution would be to define the missing functions. But that would lead to a certain amount of code duplication. To avoid code duplication, I factored out the name generation strategy into a function parameter: data FreshOrReuse = FreshNamesOnly | ReuseBoundNames addSimpleTyVarBinds :: FreshOrReuse -> ... addHsTyVarBinds :: FreshOrReuse -> ... addQTyVarBinds :: FreshOrReuse -> ... - - - - - c189b831 by Vladislav Zavialov at 2022-12-03T04:39:22-05:00 addHsOuterFamEqnTyVarBinds: use FreshNamesOnly for explicit binders Consider this example: [d| instance forall a. C [a] where type forall b. G [a] b = Proxy b |] When we process "forall b." in the associated type instance, it is unambiguously the binding site for "b" and we want a fresh name for it. Therefore, FreshNamesOnly is more fitting than ReuseBoundNames. This should not have any observable effect but it avoids pointless lookups in the MetaEnv. - - - - - 42512264 by Ross Paterson at 2022-12-03T10:32:45+00:00 Handle type data declarations in Template Haskell quotations and splices (fixes #22500) This adds a TypeDataD constructor to the Template Haskell Dec type, and ensures that the constructors it contains go in the TyCls namespace. - - - - - 1a767fa3 by Vladislav Zavialov at 2022-12-05T05:18:50-05:00 Add BufSpan to EpaLocation (#22319, #22558) The key part of this patch is the change to mkTokenLocation: - mkTokenLocation (RealSrcSpan r _) = TokenLoc (EpaSpan r) + mkTokenLocation (RealSrcSpan r mb) = TokenLoc (EpaSpan r mb) mkTokenLocation used to discard the BufSpan, but now it is saved and can be retrieved from LHsToken or LHsUniToken. This is made possible by the following change to EpaLocation: - data EpaLocation = EpaSpan !RealSrcSpan + data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan) | ... The end goal is to make use of the BufSpan in Parser/PostProcess/Haddock. - - - - - cd31acad by sheaf at 2022-12-06T15:45:58-05:00 Hadrian: fix ghcDebugAssertions off-by-one error Commit 6b2f7ffe changed the logic that decided whether to enable debug assertions. However, it had an off-by-one error, as the stage parameter to the function inconsistently referred to the stage of the compiler being used to build or the stage of the compiler we are building. This patch makes it consistent. Now the parameter always refers to the the compiler which is being built. In particular, this patch re-enables assertions in the stage 2 compiler when building with devel2 flavour, and disables assertions in the stage 2 compiler when building with validate flavour. Some extra performance tests are now run in the "validate" jobs because the stage2 compiler no longer contains assertions. ------------------------- Metric Decrease: CoOpt_Singletons MultiComponentModules MultiComponentModulesRecomp MultiLayerModulesTH_OneShot T11374 T12227 T12234 T13253-spj T13701 T14683 T14697 T15703 T17096 T17516 T18304 T18478 T18923 T5030 T9872b TcPlugin_RewritePerf Metric Increase: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T13386 T13719 T3294 T9233 T9675 parsing001 ------------------------- - - - - - 21d66db1 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInstallNameTool - - - - - aaaaa79b by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of askOtool - - - - - 4e28f49e by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of runInjectRPaths - - - - - a7422580 by mrkun at 2022-12-06T15:46:38-05:00 Push DynFlags out of Linker.MacOS - - - - - e902d771 by Matthew Craven at 2022-12-08T08:30:23-05:00 Fix bounds-checking buglet in Data.Array.Byte ...another manifestation of #20851 which I unfortunately missed in my first pass. - - - - - 8d36c0c6 by Gergő Érdi at 2022-12-08T08:31:03-05:00 Remove copy-pasted definitions of `graphFromEdgedVertices*` - - - - - c5d8ed3a by Gergő Érdi at 2022-12-08T08:31:03-05:00 Add version of `reachableGraph` that avoids loop for cyclic inputs by building its result connected component by component Fixes #22512 - - - - - 90cd5396 by Krzysztof Gogolewski at 2022-12-08T08:31:39-05:00 Mark Type.Reflection.Unsafe as Unsafe This module can be used to construct ill-formed TypeReps, so it should be Unsafe. - - - - - 2057c77d by Ian-Woo Kim at 2022-12-08T08:32:19-05:00 Truncate eventlog event for large payload (#20221) RTS eventlog events for postCapsetVecEvent are truncated if payload is larger than EVENT_PAYLOAD_SIZE_MAX Previously, postCapsetVecEvent records eventlog event with payload of variable size larger than EVENT_PAYLOAD_SIZE_MAX (2^16) without any validation, resulting in corrupted data. For example, this happens when a Haskell binary is invoked with very long command line arguments exceeding 2^16 bytes (see #20221). Now we check the size of accumulated payload messages incrementally, and truncate the message just before the payload size exceeds EVENT_PAYLOAD_SIZE_MAX. RTS will warn the user with a message showing how many arguments are truncated. - - - - - 9ec76f61 by Cheng Shao at 2022-12-08T08:32:59-05:00 hadrian: don't add debug info to non-debug ways of rts Hadrian used to pass -g when building all ways of rts. It makes output binaries larger (especially so for wasm backend), and isn't needed by most users out there, so this patch removes that flag. In case the debug info is desired, we still pass -g3 when building the debug way, and there's also the debug_info flavour transformer which ensures -g3 is passed for all rts ways. - - - - - 7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00 Restore show (typeRep @[]) == "[]" The Show instance for TypeRep [] has changed in 9.5 to output "List" because the name of the type constructor changed. This seems to be accidental and is inconsistent with TypeReps of saturated lists, which are printed as e.g. "[Int]". For now, I'm restoring the old behavior; in the future, maybe we should show TypeReps without puns (List, Tuple, Type). - - - - - 216deefd by Matthew Pickering at 2022-12-08T22:45:27-05:00 Add test for #22162 - - - - - 5d0a311f by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job to test interface file determinism guarantees In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180 - - - - - 0a76d7d4 by Matthew Pickering at 2022-12-08T22:45:27-05:00 ci: Add job for testing interface stability across builds The idea is that both the bindists should product libraries with the same ABI and interface hash. So the job checks with ghc-pkg to make sure the computed ABI is the same. In future this job can be extended to check for the other facets of interface determinism. Fixes #22180 - - - - - 74c9bf91 by Matthew Pickering at 2022-12-08T22:45:27-05:00 backpack: Be more careful when adding together ImportAvails There was some code in the signature merging logic which added together the ImportAvails of the signature and the signature which was merged into it. This had the side-effect of making the merged signature depend on the signature (via a normal module dependency). The intention was to propagate orphan instances through the merge but this also messed up recompilation logic because we shouldn't be attempting to load B.hi when mergeing it. The fix is to just combine the part of ImportAvails that we intended to (transitive info, orphan instances and type family instances) rather than the whole thing. - - - - - d122e022 by Matthew Pickering at 2022-12-08T22:45:27-05:00 Fix mk_mod_usage_info if the interface file is not already loaded In #22217 it was observed that the order modules are compiled in affects the contents of an interface file. This was because a module dependended on another module indirectly, via a re-export but the interface file for this module was never loaded because the symbol was never used in the file. If we decide that we depend on a module then we jolly well ought to record this fact in the interface file! Otherwise it could lead to very subtle recompilation bugs if the dependency is not tracked and the module is updated. Therefore the best thing to do is just to make sure the file is loaded by calling the `loadSysInterface` function. This first checks the caches (like we did before) but then actually goes to find the interface on disk if it wasn't loaded. Fixes #22217 - - - - - ea25088d by lrzlin at 2022-12-08T22:46:06-05:00 Add initial support for LoongArch Architecture. - - - - - 9eb9d2f4 by Bodigrim at 2022-12-08T22:46:47-05:00 Update submodule mtl to 2.3.1, parsec to 3.1.15.1, haddock and Cabal to HEAD - - - - - 08d8fe2a by Bodigrim at 2022-12-08T22:46:47-05:00 Allow mtl-2.3 in hadrian - - - - - 3807a46c by Bodigrim at 2022-12-08T22:46:47-05:00 Support mtl-2.3 in check-exact - - - - - ef702a18 by Bodigrim at 2022-12-08T22:46:47-05:00 Fix tests - - - - - 3144e8ff by Sebastian Graf at 2022-12-08T22:47:22-05:00 Make (^) INLINE (#22324) So that we get to cancel away the allocation for the lazily used base. We can move `powImpl` (which *is* strict in the base) to the top-level so that we don't duplicate too much code and move the SPECIALISATION pragmas onto `powImpl`. The net effect of this change is that `(^)` plays along much better with inlining thresholds and loopification (#22227), for example in `x2n1`. Fixes #22324. - - - - - 1d3a8b8e by Matthew Pickering at 2022-12-08T22:47:59-05:00 Typeable: Fix module locations of some definitions in GHC.Types There was some confusion in Data.Typeable about which module certain wired-in things were defined in. Just because something is wired-in doesn't mean it comes from GHC.Prim, in particular things like LiftedRep and RuntimeRep are defined in GHC.Types and that's the end of the story. Things like Int#, Float# etc are defined in GHC.Prim as they have no Haskell definition site at all so we need to generate type representations for them (which live in GHC.Types). Fixes #22510 - - - - - 0f7588b5 by Sebastian Graf at 2022-12-08T22:48:34-05:00 Make `drop` and `dropWhile` fuse (#18964) I copied the fusion framework we have in place for `take`. T18964 asserts that we regress neither when fusion fires nor when it doesn't. Fixes #18964. - - - - - 26e71562 by Sebastian Graf at 2022-12-08T22:49:10-05:00 Do not strictify a DFun's parameter dictionaries (#22549) ... thus fixing #22549. The details are in the refurbished and no longer dead `Note [Do not strictify a DFun's parameter dictionaries]`. There's a regression test in T22549. - - - - - 36093407 by John Ericson at 2022-12-08T22:49:45-05:00 Delete `rts/package.conf.in` It is a relic of the Make build system. The RTS now uses a `package.conf` file generated the usual way by Cabal. - - - - - b0cc2fcf by Krzysztof Gogolewski at 2022-12-08T22:50:21-05:00 Fixes around primitive literals * The SourceText of primitive characters 'a'# did not include the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#. We can now remove the function pp_st_suffix, which was a hack to add the # back. * Negative primitive literals shouldn't use parentheses, as described in Note [Printing of literals in Core]. Added a testcase to T14681. - - - - - aacf616d by Bryan Richter at 2022-12-08T22:50:56-05:00 testsuite: Mark conc024 fragile on Windows - - - - - ed239a24 by Ryan Scott at 2022-12-09T09:42:16-05:00 Document TH splices' interaction with INCOHERENT instances Top-level declaration splices can having surprising interactions with `INCOHERENT` instances, as observed in #22492. This patch resolves #22492 by documenting this strange interaction in the GHC User's Guide. [ci skip] - - - - - 1023b432 by Mike Pilgrem at 2022-12-09T09:42:56-05:00 Fix #22300 Document GHC's extensions to valid whitespace - - - - - 79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Add support for environments that don't have setImmediate - - - - - 5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00 Fix bound thread status - - - - - 65335d10 by Matthew Pickering at 2022-12-09T20:15:45-05:00 Update containers submodule This contains a fix necessary for the multi-repl to work on GHC's code base where we try to load containers and template-haskell into the same session. - - - - - 4937c0bb by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-multi: Put interface files in separate directories Before we were putting all the interface files in the same directory which was leading to collisions if the files were called the same thing. - - - - - 8acb5b7b by Matthew Pickering at 2022-12-09T20:15:45-05:00 hadrian-toolargs: Add filepath to allowed repl targets - - - - - 5949d927 by Matthew Pickering at 2022-12-09T20:15:45-05:00 driver: Set correct UnitId when rehydrating modules We were not setting the UnitId before rehydrating modules which just led to us attempting to find things in the wrong HPT. The test for this is the hadrian-multi command (which is now added as a CI job). Fixes #22222 - - - - - ab06c0f0 by Matthew Pickering at 2022-12-09T20:15:45-05:00 ci: Add job to test hadrian-multi command I am not sure this job is good because it requires booting HEAD with HEAD, but it should be fine. - - - - - fac3e568 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hadrian: Update bootstrap plans to 9.2.* series and 9.4.* series. This updates the build plans for the most recent compiler versions, as well as fixing the hadrian-bootstrap-gen script to a specific GHC version. - - - - - 195b08b4 by Matthew Pickering at 2022-12-09T20:16:20-05:00 ci: Bump boot images to use ghc-9.4.3 Also updates the bootstrap jobs to test booting 9.2 and 9.4. - - - - - c658c580 by Matthew Pickering at 2022-12-09T20:16:20-05:00 hlint: Removed redundant UnboxedSums pragmas UnboxedSums is quite confusingly implied by UnboxedTuples, alas, just the way it is. See #22485 - - - - - b3e98a92 by Oleg Grenrus at 2022-12-11T12:26:17-05:00 Add heqT, a kind-heterogeneous variant of heq CLC proposal https://github.com/haskell/core-libraries-committee/issues/99 - - - - - bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00 Document that Bifunctor instances for tuples are lawful only up to laziness - - - - - 5d1a1881 by Bryan Richter at 2022-12-12T16:22:36-05:00 Mark T21336a fragile - - - - - c30accc2 by Matthew Pickering at 2022-12-12T16:23:11-05:00 Add test for #21476 This issues seems to have been fixed since the ticket was made, so let's add a test and move on. Fixes #21476 - - - - - e9d74a3e by Sebastian Graf at 2022-12-13T22:18:39-05:00 Respect -XStrict in the pattern-match checker (#21761) We were missing a call to `decideBangHood` in the pattern-match checker. There is another call in `matchWrapper.mk_eqn_info` which seems redundant but really is not; see `Note [Desugaring -XStrict matches in Pmc]`. Fixes #21761. - - - - - 884790e2 by Gergő Érdi at 2022-12-13T22:19:14-05:00 Fix loop in the interface representation of some `Unfolding` fields As discovered in #22272, dehydration of the unfolding info of a recursive definition used to involve a traversal of the definition itself, which in turn involves traversing the unfolding info. Hence, a loop. Instead, we now store enough data in the interface that we can produce the unfolding info without this traversal. See Note [Tying the 'CoreUnfolding' knot] for details. Fixes #22272 Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 9f301189 by Alan Zimmerman at 2022-12-13T22:19:50-05:00 EPA: When splitting out header comments, keep ones for first decl Any comments immediately preceding the first declaration are no longer kept as header comments, but attach to the first declaration instead. - - - - - 8b1f1b45 by Sylvain Henry at 2022-12-13T22:20:28-05:00 JS: fix object file name comparison (#22578) - - - - - e9e161bb by Bryan Richter at 2022-12-13T22:21:03-05:00 configure: Bump min bootstrap GHC version to 9.2 - - - - - bf710859 by Ben Gamari at 2022-12-14T20:01:39-05:00 compiler: Ensure that GHC toolchain is first in search path As noted in #22561, it is important that GHC's toolchain look first for its own headers and libraries to ensure that the system's are not found instead. If this happens things can break in surprising ways (e.g. see #22561). - - - - - 21 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - + .gitlab/upload_ghc_libs.py - CODEOWNERS - HACKING.md - − MAKEHELP.md - − Makefile - README.md - − appveyor.yml - bindisttest/Makefile - − bindisttest/ghc.mk - boot - compiler/.hlint.yaml - compiler/CodeGen.Platform.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/669dcba23426ea38d890c67f60681c73cd0e302a...bf710859af79d5375d67ee210929d376d8b8489c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/669dcba23426ea38d890c67f60681c73cd0e302a...bf710859af79d5375d67ee210929d376d8b8489c You're receiving 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 Dec 15 01:33:39 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Dec 2022 20:33:39 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 15 commits: hadrian: Don't enable TSAN in stage0 build Message-ID: <639a79739626a_17049759ec01512fe@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2304ae83 by Ben Gamari at 2022-12-14T20:33:30-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - facd8702 by Ben Gamari at 2022-12-14T20:33:30-05:00 cmm: Introduce blockConcat - - - - - 6b5d5197 by Ben Gamari at 2022-12-14T20:33:30-05:00 cmm: Introduce MemoryOrderings - - - - - 0e8d5d36 by Ben Gamari at 2022-12-14T20:33:31-05:00 llvm: Respect memory specified orderings - - - - - 856e6209 by Ben Gamari at 2022-12-14T20:33:31-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 6476199f by Ben Gamari at 2022-12-14T20:33:31-05:00 cmm/Parser: Reduce some repetition - - - - - d7b2c3e1 by Ben Gamari at 2022-12-14T20:33:31-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 71ac7e4a by Ben Gamari at 2022-12-14T20:33:31-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - f5658062 by Ben Gamari at 2022-12-14T20:33:31-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 781d7321 by Ben Gamari at 2022-12-14T20:33:31-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 035dc6e8 by Ben Gamari at 2022-12-14T20:33:31-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - a07fa570 by Ben Gamari at 2022-12-14T20:33:31-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 7054d785 by Matthew Pickering at 2022-12-14T20:33:31-05:00 Package Imports: Get candidate packages also from re-exported modules Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333 - - - - - 53e8cb9e by Simon Peyton Jones at 2022-12-14T20:33:32-05:00 Fix bogus test in Lint The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation. - - - - - 6787d12f by Ryan Scott at 2022-12-14T20:33:32-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/State.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - hadrian/src/Flavour.hs - rts/HeapStackCheck.cmm The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fdcba2cfbd09937edbe915b59497d67237661505...6787d12f98487a07ac0e0f5ae8b4023844b158eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fdcba2cfbd09937edbe915b59497d67237661505...6787d12f98487a07ac0e0f5ae8b4023844b158eb You're receiving 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 Dec 15 04:54:02 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 14 Dec 2022 23:54:02 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 16 commits: hadrian: Don't enable TSAN in stage0 build Message-ID: <639aa86a10bd9_17049759eac196564@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 286607a4 by Ben Gamari at 2022-12-14T23:53:52-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - f16b5e05 by Ben Gamari at 2022-12-14T23:53:52-05:00 cmm: Introduce blockConcat - - - - - 4689f25b by Ben Gamari at 2022-12-14T23:53:52-05:00 cmm: Introduce MemoryOrderings - - - - - 6e369553 by Ben Gamari at 2022-12-14T23:53:52-05:00 llvm: Respect memory specified orderings - - - - - eab018d6 by Ben Gamari at 2022-12-14T23:53:52-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - c069fb53 by Ben Gamari at 2022-12-14T23:53:52-05:00 cmm/Parser: Reduce some repetition - - - - - 12b08543 by Ben Gamari at 2022-12-14T23:53:52-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - a6422e88 by Ben Gamari at 2022-12-14T23:53:52-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 5731e5b3 by Ben Gamari at 2022-12-14T23:53:52-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - b5f29ee4 by Ben Gamari at 2022-12-14T23:53:52-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 266d8012 by Ben Gamari at 2022-12-14T23:53:52-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 5db5a1dd by Ben Gamari at 2022-12-14T23:53:53-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - c9dc7676 by Matthew Pickering at 2022-12-14T23:53:53-05:00 Package Imports: Get candidate packages also from re-exported modules Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333 - - - - - 93e6c644 by Ben Gamari at 2022-12-14T23:53:54-05:00 compiler: Ensure that MutVar operations have necessary barriers Here we add acquire and release barriers in readMutVar# and writeMutVar#, which are necessary for soundness. Fixes #22468. - - - - - 659a55b4 by Simon Peyton Jones at 2022-12-14T23:53:54-05:00 Fix bogus test in Lint The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation. - - - - - ee45fd95 by Ryan Scott at 2022-12-14T23:53:55-05:00 checkValidInst: Don't expand synonyms when splitting sigma types Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570. - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Unit/Finder.hs - compiler/GHC/Unit/State.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - hadrian/src/Flavour.hs - rts/HeapStackCheck.cmm The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6787d12f98487a07ac0e0f5ae8b4023844b158eb...ee45fd9521be13104be1dc752f1474794a8585fe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6787d12f98487a07ac0e0f5ae8b4023844b158eb...ee45fd9521be13104be1dc752f1474794a8585fe You're receiving 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 Dec 15 08:54:29 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 15 Dec 2022 03:54:29 -0500 Subject: [Git][ghc/ghc][master] 12 commits: hadrian: Don't enable TSAN in stage0 build Message-ID: <639ae0c5ab350_17049759e70229430@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 75855643 by Ben Gamari at 2022-12-15T03:54:02-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - da7b51d8 by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm: Introduce blockConcat - - - - - 34f6b09c by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm: Introduce MemoryOrderings - - - - - 43beaa7b by Ben Gamari at 2022-12-15T03:54:02-05:00 llvm: Respect memory specified orderings - - - - - 8faf74fc by Ben Gamari at 2022-12-15T03:54:02-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 6cc3944a by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm/Parser: Reduce some repetition - - - - - 6c9862c4 by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 748490d2 by Ben Gamari at 2022-12-15T03:54:02-05:00 cmm/Parser: Atomic load syntax Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural. - - - - - 28c6781a by Ben Gamari at 2022-12-15T03:54:02-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - d97aa311 by Ben Gamari at 2022-12-15T03:54:02-05:00 Hadrian: Drop TSAN_ENABLED define from flavour This is redundant since the TSANUtils.h already defines it. - - - - - 86974ef1 by Ben Gamari at 2022-12-15T03:54:02-05:00 hadrian: Enable Cmm instrumentation in TSAN flavour - - - - - 93723290 by Ben Gamari at 2022-12-15T03:54:02-05:00 rts: Ensure that global regs are never passed as fun call args This is in general unsafe as they may be clobbered if they are mapped to caller-saved machine registers. See Note [Register parameter passing]. - - - - - 26 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - hadrian/src/Flavour.hs - rts/HeapStackCheck.cmm - + rts/TSANUtils.c - rts/include/rts/TSANUtils.h - rts/rts.cabal.in Changes: ===================================== compiler/GHC/Cmm/Config.hs ===================================== @@ -19,6 +19,7 @@ data CmmConfig = CmmConfig , cmmDoLinting :: !Bool -- ^ Do Cmm Linting Optimization or not , cmmOptElimCommonBlks :: !Bool -- ^ Eliminate common blocks or not , cmmOptSink :: !Bool -- ^ Perform sink after stack layout or not + , cmmOptThreadSanitizer :: !Bool -- ^ Instrument memory accesses for ThreadSanitizer , cmmGenStackUnwindInstr :: !Bool -- ^ Generate stack unwinding instructions (for debugging) , cmmExternalDynamicRefs :: !Bool -- ^ Generate code to link against dynamic libraries , cmmDoCmmSwitchPlans :: !Bool -- ^ Should the Cmm pass replace Stg switch statements ===================================== compiler/GHC/Cmm/ContFlowOpt.hs ===================================== @@ -10,7 +10,7 @@ where import GHC.Prelude hiding (succ, unzip, zip) -import GHC.Cmm.Dataflow.Block +import GHC.Cmm.Dataflow.Block hiding (blockConcat) import GHC.Cmm.Dataflow.Collections import GHC.Cmm.Dataflow.Graph import GHC.Cmm.Dataflow.Label ===================================== compiler/GHC/Cmm/Dataflow/Block.hs ===================================== @@ -14,6 +14,7 @@ module GHC.Cmm.Dataflow.Block , IndexedCO , Block(..) , blockAppend + , blockConcat , blockCons , blockFromList , blockJoin @@ -136,6 +137,8 @@ blockJoin f b t = BlockCC f b t blockAppend :: Block n e O -> Block n O x -> Block n e x blockAppend = cat +blockConcat :: [Block n O O] -> Block n O O +blockConcat = foldr blockAppend emptyBlock -- Taking apart ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -94,6 +94,10 @@ $white_no_nl+ ; "!=" { kw CmmT_Ne } "&&" { kw CmmT_BoolAnd } "||" { kw CmmT_BoolOr } + "%relaxed" { kw CmmT_Relaxed } + "%acquire" { kw CmmT_Acquire } + "%release" { kw CmmT_Release } + "%seq_cst" { kw CmmT_SeqCst } "True" { kw CmmT_True } "False" { kw CmmT_False } @@ -183,6 +187,10 @@ data CmmToken | CmmT_False | CmmT_True | CmmT_likely + | CmmT_Relaxed + | CmmT_Acquire + | CmmT_Release + | CmmT_SeqCst deriving (Show) -- ----------------------------------------------------------------------------- ===================================== compiler/GHC/Cmm/MachOp.hs ===================================== @@ -24,6 +24,7 @@ module GHC.Cmm.MachOp , machOpMemcpyishAlign -- Atomic read-modify-write + , MemoryOrdering(..) , AtomicMachOp(..) ) where @@ -662,10 +663,12 @@ data CallishMachOp | MO_BSwap Width | MO_BRev Width - -- Atomic read-modify-write. + -- | Atomic read-modify-write. Arguments are @[dest, n]@. | MO_AtomicRMW Width AtomicMachOp - | MO_AtomicRead Width - | MO_AtomicWrite Width + -- | Atomic read. Arguments are @[addr]@. + | MO_AtomicRead Width MemoryOrdering + -- | Atomic write. Arguments are @[addr, value]@. + | MO_AtomicWrite Width MemoryOrdering -- | Atomic compare-and-swap. Arguments are @[dest, expected, new]@. -- Sequentially consistent. -- Possible future refactoring: should this be an'MO_AtomicRMW' variant? @@ -680,6 +683,14 @@ data CallishMachOp | MO_ResumeThread deriving (Eq, Show) +-- | C11 memory ordering semantics. +data MemoryOrdering + = MemOrderRelaxed -- ^ relaxed ordering + | MemOrderAcquire -- ^ acquire ordering + | MemOrderRelease -- ^ release ordering + | MemOrderSeqCst -- ^ sequentially consistent + deriving (Eq, Ord, Show) + -- | The operation to perform atomically. data AtomicMachOp = AMO_Add ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -194,6 +194,27 @@ convention. Note if a field is longer than a word (e.g. a D_ on a 32-bit machine) then the call will push as many words as necessary to the stack to accommodate it (e.g. 2). +Memory ordering +--------------- + +Cmm respects the C11 memory model and distinguishes between non-atomic and +atomic memory accesses. In C11 fashion, atomic accesses can provide a number of +memory ordering guarantees. These are supported in Cmm syntax as follows: + + W_[ptr] = ...; // a non-atomic store + %relaxed W_[ptr] = ...; // an atomic store with relaxed ordering semantics + %release W_[ptr] = ...; // an atomic store with release ordering semantics + + x = W_(ptr); // a non-atomic load + x = %relaxed W_[ptr]; // an atomic load with relaxed ordering + x = %acquire W_[ptr]; // an atomic load with acquire ordering + // or equivalently... + x = prim %load_acquire64(ptr); + +Here we used W_ as an example but these operations can be used on all Cmm +types. + +See Note [Heap memory barriers] in SMP.h for details. ----------------------------------------------------------------------------- -} @@ -313,6 +334,10 @@ import qualified Data.ByteString.Char8 as BS8 'True' { L _ (CmmT_True ) } 'False' { L _ (CmmT_False) } 'likely'{ L _ (CmmT_likely)} + 'relaxed'{ L _ (CmmT_Relaxed)} + 'acquire'{ L _ (CmmT_Acquire)} + 'release'{ L _ (CmmT_Release)} + 'seq_cst'{ L _ (CmmT_SeqCst)} 'CLOSURE' { L _ (CmmT_CLOSURE) } 'INFO_TABLE' { L _ (CmmT_INFO_TABLE) } @@ -627,8 +652,23 @@ stmt :: { CmmParse () } | lreg '=' expr ';' { do reg <- $1; e <- $3; withSourceNote $2 $4 (emitAssign reg e) } + + -- Use lreg instead of local_reg to avoid ambiguity + | lreg '=' mem_ordering type '[' expr ']' ';' + { do reg <- $1; + let lreg = case reg of + { CmmLocal r -> r + ; other -> pprPanic "CmmParse:" (ppr reg <> text "not a local register") + } ; + mord <- $3; + let { ty = $4; w = typeWidth ty }; + e <- $6; + let op = MO_AtomicRead w mord; + withSourceNote $2 $7 $ code (emitPrimCall [lreg] op [e]) } + | mem_ordering type '[' expr ']' '=' expr ';' + { do mord <- $1; withSourceNote $3 $8 (doStore (Just mord) $2 $4 $7) } | type '[' expr ']' '=' expr ';' - { withSourceNote $2 $7 (doStore $1 $3 $6) } + { withSourceNote $2 $7 (doStore Nothing $1 $3 $6) } -- Gah! We really want to say "foreign_results" but that causes -- a shift/reduce conflict with assignment. We either @@ -678,6 +718,14 @@ unwind_regs | GLOBALREG '=' expr_or_unknown { do e <- $3; return [($1, e)] } +-- | A memory ordering +mem_ordering :: { CmmParse MemoryOrdering } +mem_ordering + : 'relaxed' { do return MemOrderRelaxed } + | 'release' { do return MemOrderRelease } + | 'acquire' { do return MemOrderAcquire } + | 'seq_cst' { do return MemOrderSeqCst } + -- | Used by unwind to indicate unknown unwinding values. expr_or_unknown :: { CmmParse (Maybe CmmExpr) } @@ -953,6 +1001,7 @@ exprMacros profile align_check = listToUFM [ platform = profilePlatform profile -- we understand a subset of C-- primitives: +machOps :: UniqFM FastString (Width -> MachOp) machOps = listToUFM $ map (\(x, y) -> (mkFastString x, y)) [ ( "add", MO_Add ), @@ -1073,37 +1122,32 @@ callishMachOps platform = listToUFM $ ( "suspendThread", (MO_SuspendThread,) ), ( "resumeThread", (MO_ResumeThread,) ), - ("prefetch0", (MO_Prefetch_Data 0,)), - ("prefetch1", (MO_Prefetch_Data 1,)), - ("prefetch2", (MO_Prefetch_Data 2,)), - ("prefetch3", (MO_Prefetch_Data 3,)), - - ( "popcnt8", (MO_PopCnt W8,)), - ( "popcnt16", (MO_PopCnt W16,)), - ( "popcnt32", (MO_PopCnt W32,)), - ( "popcnt64", (MO_PopCnt W64,)), - - ( "pdep8", (MO_Pdep W8,)), - ( "pdep16", (MO_Pdep W16,)), - ( "pdep32", (MO_Pdep W32,)), - ( "pdep64", (MO_Pdep W64,)), - - ( "pext8", (MO_Pext W8,)), - ( "pext16", (MO_Pext W16,)), - ( "pext32", (MO_Pext W32,)), - ( "pext64", (MO_Pext W64,)), - - ( "cmpxchg8", (MO_Cmpxchg W8,)), - ( "cmpxchg16", (MO_Cmpxchg W16,)), - ( "cmpxchg32", (MO_Cmpxchg W32,)), - ( "cmpxchg64", (MO_Cmpxchg W64,)), - - ( "xchg8", (MO_Xchg W8,)), - ( "xchg16", (MO_Xchg W16,)), - ( "xchg32", (MO_Xchg W32,)), - ( "xchg64", (MO_Xchg W64,)) + ( "prefetch0", (MO_Prefetch_Data 0,)), + ( "prefetch1", (MO_Prefetch_Data 1,)), + ( "prefetch2", (MO_Prefetch_Data 2,)), + ( "prefetch3", (MO_Prefetch_Data 3,)) + ] ++ concat + [ allWidths "popcnt" MO_PopCnt + , allWidths "pdep" MO_Pdep + , allWidths "pext" MO_Pext + , allWidths "cmpxchg" MO_Cmpxchg + , allWidths "xchg" MO_Xchg + , allWidths "load_relaxed" (\w -> MO_AtomicRead w MemOrderAcquire) + , allWidths "load_acquire" (\w -> MO_AtomicRead w MemOrderAcquire) + , allWidths "load_seqcst" (\w -> MO_AtomicRead w MemOrderSeqCst) + , allWidths "store_release" (\w -> MO_AtomicWrite w MemOrderRelease) + , allWidths "store_seqcst" (\w -> MO_AtomicWrite w MemOrderSeqCst) ] where + allWidths + :: String + -> (Width -> CallishMachOp) + -> [(FastString, a -> (CallishMachOp, a))] + allWidths name f = + [ (mkFastString $ name ++ show (widthInBits w), (f w,)) + | w <- [W8, W16, W32, W64] + ] + memcpyLikeTweakArgs :: (Int -> CallishMachOp) -> [CmmExpr] -> (CallishMachOp, [CmmExpr]) memcpyLikeTweakArgs op [] = pgmError "memcpy-like function requires at least one argument" memcpyLikeTweakArgs op args@(_:_) = @@ -1347,8 +1391,12 @@ primCall results_code name args_code let (p, args') = f args code (emitPrimCall (map fst results) p args') -doStore :: CmmType -> CmmParse CmmExpr -> CmmParse CmmExpr -> CmmParse () -doStore rep addr_code val_code +doStore :: Maybe MemoryOrdering + -> CmmType + -> CmmParse CmmExpr -- ^ address + -> CmmParse CmmExpr -- ^ value + -> CmmParse () +doStore mem_ord rep addr_code val_code = do platform <- getPlatform addr <- addr_code val <- val_code @@ -1362,7 +1410,7 @@ doStore rep addr_code val_code let coerce_val | val_width /= rep_width = CmmMachOp (MO_UU_Conv val_width rep_width) [val] | otherwise = val - emitStore addr coerce_val + emitStore mem_ord addr coerce_val -- ----------------------------------------------------------------------------- -- If-then-else and boolean expressions ===================================== compiler/GHC/Cmm/Pipeline.hs ===================================== @@ -19,6 +19,7 @@ import GHC.Cmm.LayoutStack import GHC.Cmm.ProcPoint import GHC.Cmm.Sink import GHC.Cmm.Switch.Implement +import GHC.Cmm.ThreadSanitizer import GHC.Types.Unique.Supply @@ -98,6 +99,13 @@ cpsTop logger platform cfg proc = else pure g dump Opt_D_dump_cmm_switch "Post switch plan" g + ----------- ThreadSanitizer instrumentation ----------------------------- + g <- {-# SCC "annotateTSAN" #-} + if cmmOptThreadSanitizer cfg + then runUniqSM $ annotateTSAN platform g + else return g + dump Opt_D_dump_cmm_thread_sanitizer "ThreadSanitizer instrumentation" g + ----------- Proc points ------------------------------------------------- let call_pps :: ProcPointSet -- LabelMap ===================================== compiler/GHC/Cmm/ThreadSanitizer.hs ===================================== @@ -0,0 +1,285 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} + +-- | Annotate a CmmGraph with ThreadSanitizer instrumentation calls. +module GHC.Cmm.ThreadSanitizer (annotateTSAN) where + +import GHC.Prelude + +import GHC.StgToCmm.Utils (get_GlobalReg_addr) +import GHC.Platform +import GHC.Platform.Regs (activeStgRegs, callerSaves) +import GHC.Cmm +import GHC.Cmm.Utils +import GHC.Cmm.CLabel +import GHC.Cmm.Dataflow +import GHC.Cmm.Dataflow.Block +import GHC.Cmm.Dataflow.Graph +import GHC.Data.FastString +import GHC.Types.Basic +import GHC.Types.ForeignCall +import GHC.Types.Unique +import GHC.Types.Unique.Supply + +import Data.Maybe (fromMaybe) + +data Env = Env { platform :: Platform + , uniques :: [Unique] + } + +annotateTSAN :: Platform -> CmmGraph -> UniqSM CmmGraph +annotateTSAN platform graph = do + env <- Env platform <$> getUniquesM + return $ modifyGraph (mapGraphBlocks (annotateBlock env)) graph + +mapBlockList :: (forall e' x'. n e' x' -> Block n e' x') + -> Block n e x -> Block n e x +mapBlockList f (BlockCO n rest ) = f n `blockAppend` mapBlockList f rest +mapBlockList f (BlockCC n rest m) = f n `blockAppend` mapBlockList f rest `blockAppend` f m +mapBlockList f (BlockOC rest m) = mapBlockList f rest `blockAppend` f m +mapBlockList _ BNil = BNil +mapBlockList f (BMiddle blk) = f blk +mapBlockList f (BCat a b) = mapBlockList f a `blockAppend` mapBlockList f b +mapBlockList f (BSnoc a n) = mapBlockList f a `blockAppend` f n +mapBlockList f (BCons n a) = f n `blockAppend` mapBlockList f a + +annotateBlock :: Env -> Block CmmNode e x -> Block CmmNode e x +annotateBlock env = mapBlockList (annotateNode env) + +annotateNode :: Env -> CmmNode e x -> Block CmmNode e x +annotateNode env node = + case node of + CmmEntry{} -> BlockCO node BNil + CmmComment{} -> BMiddle node + CmmTick{} -> BMiddle node + CmmUnwind{} -> BMiddle node + CmmAssign{} -> annotateNodeOO env node + CmmStore lhs rhs align -> + let ty = cmmExprType (platform env) rhs + rhs_nodes = annotateLoads env (collectExprLoads rhs) + lhs_nodes = annotateLoads env (collectExprLoads lhs) + st = tsanStore env align ty lhs + in rhs_nodes `blockAppend` lhs_nodes `blockAppend` st `blockSnoc` node + CmmUnsafeForeignCall (PrimTarget op) formals args -> + let node' = fromMaybe (BMiddle node) (annotatePrim env op formals args) + arg_nodes = blockConcat $ map (annotateExpr env) args + in arg_nodes `blockAppend` node' + CmmUnsafeForeignCall{} -> annotateNodeOO env node + CmmBranch{} -> annotateNodeOC env node + CmmCondBranch{} -> annotateNodeOC env node + CmmSwitch{} -> annotateNodeOC env node + CmmCall{} -> annotateNodeOC env node + CmmForeignCall{} -> annotateNodeOC env node + +annotateNodeOO :: Env -> CmmNode O O -> Block CmmNode O O +annotateNodeOO env node = + annotateLoads env (collectLoadsNode node) `blockSnoc` node + +annotateNodeOC :: Env -> CmmNode O C -> Block CmmNode O C +annotateNodeOC env node = + annotateLoads env (collectLoadsNode node) `blockJoinTail` node + +annotateExpr :: Env -> CmmExpr -> Block CmmNode O O +annotateExpr env expr = + annotateLoads env (collectExprLoads expr) + +data Load = Load CmmType AlignmentSpec CmmExpr + +annotateLoads :: Env -> [Load] -> Block CmmNode O O +annotateLoads env loads = + blockConcat + [ tsanLoad env align ty addr + | Load ty align addr <- loads + ] + +collectLoadsNode :: CmmNode e x -> [Load] +collectLoadsNode node = + foldExp (\exp rest -> collectExprLoads exp ++ rest) node [] + +-- | Collect all of the memory locations loaded from by a 'CmmExpr'. +collectExprLoads :: CmmExpr -> [Load] +collectExprLoads (CmmLit _) = [] +collectExprLoads (CmmLoad e ty align) = [Load ty align e] +collectExprLoads (CmmReg _) = [] +collectExprLoads (CmmMachOp _op args) = foldMap collectExprLoads args +collectExprLoads (CmmStackSlot _ _) = [] +collectExprLoads (CmmRegOff _ _) = [] + +-- | Generate TSAN instrumentation for a 'CallishMachOp' occurrence. +annotatePrim :: Env + -> CallishMachOp -- ^ the applied operation + -> [CmmFormal] -- ^ results + -> [CmmActual] -- ^ arguments + -> Maybe (Block CmmNode O O) + -- ^ 'Just' a block of instrumentation, if applicable +annotatePrim env (MO_AtomicRMW w aop) [dest] [addr, val] = Just $ tsanAtomicRMW env MemOrderSeqCst aop w addr val dest +annotatePrim env (MO_AtomicRead w mord) [dest] [addr] = Just $ tsanAtomicLoad env mord w addr dest +annotatePrim env (MO_AtomicWrite w mord) [] [addr, val] = Just $ tsanAtomicStore env mord w val addr +annotatePrim env (MO_Xchg w) [dest] [addr, val] = Just $ tsanAtomicExchange env MemOrderSeqCst w val addr dest +annotatePrim env (MO_Cmpxchg w) [dest] [addr, expected, new] + = Just $ tsanAtomicCas env MemOrderSeqCst MemOrderSeqCst w addr exp
FlavourSplit Sections Extra arguments
default
+
-O
-H32m
-O2
-H32m
quick + -O0
-H64m
-O0
-H64m
quick-validate + -O0
-H64m
-Werror
-O0
-H64m
-Werror
quick-debug + -O0
-H64m
-O0
-H64m
quickest + -O0
-H64m
-O0
-H64m
perf + Yes (on supported platforms) -O
-H64m
-O
-H64m
bench + -O
-H64m
-O
-H64m
devel1 + -O
-H64m
-O
-H64m
devel2 + -O
-H64m
-O
-H64m
validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
slow-validate + -O0
-H64m
-fllvm-fill-undef-with-garbage
static + -O
-H64m
-fPIC -static
-O
-H64m
-fPIC -static